提交 41ca1f74 编写于 作者: L luqiong

【test】整理用例plugins/anchor

上级 963fda19
......@@ -5,17 +5,14 @@ test( '插入锚点后切换源码', function() {
var range = te.obj[1];
var body = editor.body;
stop();
//1.2版本,ie中‘’-〉' '
var br = baidu.editor.browser.ie ? '&nbsp;' : '<br />';
var br = baidu.editor.browser.ie ? '&nbsp;' : '<br />'; //1.2版本,ie中‘’-〉'&nbsp;'
setTimeout( function() {
editor.setContent( '<p>' + br + '</p>' );
range.setStart( body.firstChild, 0 ).collapse( 1 ).select();
editor.execCommand( 'anchor', 'hello' );
//1.2版本后,在img前有的不可见字符没有删去,这里改成之比较img内的内容
// ua.checkHTMLSameStyle( '<img anchorname="hello" class="anchorclass">' + br, editor.document, body.firstChild, '检查锚点html' );
ua.checkHTMLSameStyle( '<img anchorname="hello" class="anchorclass">' + br, editor.document, body.firstChild, '检查锚点html' ); //1.2版本后,在img前有的不可见字符没有删去,这里改成之比较img内的内容
ok(body.getElementsByTagName('img')[0].attributes['anchorname'].nodeValue=="hello"&&body.getElementsByTagName('img')[0].attributes['class'].nodeValue=="anchorclass",'检查锚点');
editor.execCommand( 'source' );
/*切到源码模式下会有一个超时*/
editor.execCommand( 'source' ); /*切到源码模式下会有一个超时*/
setTimeout( function() {
var tas = editor.iframe.parentNode.getElementsByTagName( 'textarea' );
ok( tas[0].value.indexOf( '<a name="hello"' ) != -1 || tas[0].value.indexOf( '<a anchorname="1"' ) != -1, '查看是否转换成功' );
......@@ -29,55 +26,18 @@ test( '插入锚点后切换源码', function() {
}, 10 );
}, 20 );
} );
//两次设定textarea中的内容总会出错,把这个用例拆成两个
//test( '在源码模式设置超链接的name属性,切换到编辑器模式检查超链接是否变为锚点', function() {
// var editor = te.obj[0];
// editor.setContent( '' );
// var body = editor.body;
// stop();
// /*切到源码模式下会有一个超时*/
// setTimeout( function() {
// editor.execCommand( 'source' );
// setTimeout( function() {
// var ta = editor.iframe.parentNode.getElementsByTagName( 'textarea' )[0];
// /*这种情况认为是锚点*/
//// ta.value
//// ta.textContent='<p><a name="source" anchorname="1"></a></p>';
// ta.value = '<p><a name="source" anchorname="1"></a></p>';
// setTimeout( function() {
// editor.execCommand( 'source' );
// ua.checkHTMLSameStyle( '<img anchorname="source" class="anchorclass">', editor.document, body.firstChild, '检查锚点html' );
// /*这种情况不应当转换为锚点*/
// editor.execCommand( 'source' );
// setTimeout( function() {
//// ta = editor.iframe.parentNode.getElementsByTagName( 'textarea' )[0];
// editor.iframe.parentNode.getElementsByTagName( 'textarea' )[0].value = '<p><a name="source">你好</a></p>';
// setTimeout( function() {
// editor.execCommand( 'source' );
// equal( body.firstChild.firstChild.tagName.toLowerCase(), 'a', 'a标签不会转化' );
// /*用例结束前等一下,因为还有个超时操作会获取窗口*/
// setTimeout( function() {
// start();
// }, 50 );
// }, 50 );
// }, 50 );
// }, 20 );
// }, 10 );
// }, 20 );
//} );
test( '在源码模式设置超链接的name属性,切换到编辑器模式检查超链接是否变为锚点', function() {
var editor = te.obj[0];
var body = editor.body;
stop();
setTimeout(function(){
editor.setContent( '' );
/*切到源码模式下会有一个超时*/
setTimeout( function() {
editor.execCommand( 'source' );
setTimeout( function() {
var ta = editor.iframe.parentNode.getElementsByTagName( 'textarea' )[0];
/*这种情况认为是锚点*/
ta.value = '<p><a name="source" anchorname="1"></a></p>';
ta.value = '<p><a name="source" anchorname="1"></a></p>'; /*这种情况认为是锚点*/
setTimeout( function() {
editor.execCommand( 'source' );
ua.checkHTMLSameStyle( '<img anchorname="source" class="anchorclass">', editor.document, body.firstChild, '检查锚点html' );
......@@ -88,22 +48,20 @@ test( '在源码模式设置超链接的name属性,切换到编辑器模式检
},100);
} );
test( '在源码模式设置超链接没有name属性,切换到编辑器模式检查超链接不变为锚点', function() {
var editor = te.obj[0];
editor.setContent( '' );
var body = editor.body;
stop();
/*切到源码模式下会有一个超时*/
setTimeout( function() {
editor.execCommand( 'source' );
setTimeout( function() {
var ta = editor.iframe.parentNode.getElementsByTagName( 'textarea' )[0];
ta.value = '<p><a name="source">你好</a></p>';
ta.value = '<p><a name="source" href="www.baidu.com">你好</a></p>';
setTimeout( function() {
editor.execCommand( 'source' );
ua.manualDeleteFillData(editor.body);
equal( body.firstChild.firstChild.tagName.toLowerCase(), 'a', 'a标签不会转化' );
start();
}, 50 );
......@@ -120,7 +78,6 @@ test( '已存在锚点', function() {
range.selectNode(body.firstChild).select();
editor.execCommand( 'anchor', 'hello' );
var name=body.firstChild.firstChild.getAttribute('anchorname');
// equal(ua.getChildHTML(editor.body),'<p><img anchorname=\"hello\" class=\"anchorclass\" _src=\"undefined\"></p>','更改name');
equal(name, 'hello', '更改name');
editor.setContent( '<p><img anchorname="1" class="anchorclass"/></p>' );
range.selectNode(body.firstChild).select();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册