module('plugins.source'); //test('初始化进入源码模式',function(){ // if(ua.browser.ie>0 && ua.browser.ie<8) // return 0; // var div = document.createElement('div'); // document.body.appendChild(div); // div.id = 'e'; // var editor = UE.getEditor('e');//,{sourceEditorFirst:true} // stop(); //// editor.ready(function(){ //// setTimeout(function(){ ////// equal(editor.queryCommandState('source'),1,'源码高亮'); //// equal(editor.queryCommandState('bold'),-1,'加粗灰色'); //////// start(); //// },100); //// }); //}); test('chrome删除后切换源码再切换回来,光标没了', function () { //opera 取不到range值 if (ua.browser.opera) return 0; var editor = te.obj[0]; var div = te.dom[0]; editor.render(div); editor.setContent('hello'); var range = editor.selection.getRange(); range.selectNode(editor.body.firstChild).select(); editor.execCommand('cleardoc'); stop(); expect(2); //source 包含超时操作,ie下必须有同步操作,否则会报错 setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); start(); }, 20); }, 20); range = editor.selection.getRange(); equal(range.startContainer.nodeType, 1, '光标定位在p里'); equal(range.startContainer.tagName.toLowerCase(), 'p', 'startContainer为p'); te.dom.push(div); }); //TODO 1.2.6 /*trace 986*/ //test( '切换源码,视频地址被添加了网站前缀', function () { // if ( !ua.browser.ie ) { // var editor = te.obj[0]; // var range = te.obj[1]; // editor.setContent( '
hellobaidu
'); stop(); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { var html = editor.getContent(); equal(html, 'hellobaidu
'); start(); }, 100); }, 100); }, 100); // var html = '\nhello\n\tbaidu\n\n
'; //无奈的验证,有不可见字符 //多余不可见字符的的bug已经修改了,现在用例字符串长度:53 // ok(html.length>=58&&html.length<=60,'切换源码不会多空行'); }); /*trace 710*/ test('设置源码内容没有p标签,切换源码后会自动添加', function () { var editor = te.obj[0]; editor.setContent('helloworld你好啊大家好,你在干嘛呢。谢谢,不用谢~~%199hello
'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { var childs = editor.body.childNodes; ok(childs.length, 3, '3个p'); for (var index = 0; index < 3; index++) { equal(childs[0].tagName.toLowerCase(), 'p', '第' + index + '个孩子为p'); } start(); }, 100); }, 100); }, 100); }, 100); stop(); }); test('切换源码去掉空的span', function () { var editor = te.obj[0]; editor.setContent('切换源码去掉空的span
'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); start(); }, 100); }, 100); stop(); equal(editor.getContent(), '切换源码去掉空的span
'); }); test('b,i标签,切换源码后自动转换成strong和em', function () { var editor = te.obj[0]; editor.setContent('加粗的内容斜体的内容加粗且斜体
'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); start(); }, 100); }, 100); stop(); equal(editor.getContent(), '加粗的内容斜体的内容加粗且斜体
'); }); test(' trace 3739 trace 1734 range的更新/特殊符号的转换', function () { var editor = te.obj[0]; editor.setContent('"<>
'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); equal(editor.getContent(), '"<>
'); editor.setContent("'
'
' + br + '
_baidu_page_break_tag_' + br + '
' ); document.body.removeChild(div); start(); }, 50); }, 50); stop(); }); //TODO 1.2.6 //test( 'trace 1977 1949 插入代码,源码中对应的标签是pre', function () { // var div = document.body.appendChild( document.createElement( 'div' ) ); // $( div ).css( 'width', '500px' ).css( 'height', '500px' ).css( 'border', '1px solid #ccc' ); // var editor = te.obj[2]; // editor.render(div); // var range = new baidu.editor.dom.Range( editor.document ); // var body = editor.body; // stop(); // setTimeout(function(){ // editor.setContent( '<a href=\"http://net.tutsplus.com\" class=\"logo\">Nettuts+</a>' ); // //highlightcode空格问题 //// equal( editor.getContent().substring( 0, 116 ), '
<a href=\"http://net.tutsplus.com\" class=\"logo\">Nettuts+</a>' ); // te.dom.push( div ); // } // start(); // },50); //} ); test('不以http://开头的超链接绝对路径网址', function () { if (ua.browser.ie == 9)return 0;//TODO 1.2.6 var editor = te.obj[0]; editor.setContent(''); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); equal(editor.getContent(), ''); start(); }, 100); }, 100); stop(); }); test('trace 1727:插入超链接后再插入空格,空格不能被删除', function () { var editor = te.obj[0]; editor.setContent('
绝对路径网址 ddd
'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); equal(editor.body.innerHTML.toLowerCase(), '绝对路径网址 ddd
', '查看空格是否被删除'); start(); }, 100); }, 100); stop(); }); //TODO 1.2.6 空style未删除 //test( '关于空格的问题', function () { // var editor = te.obj[0]; // var html = 'dd jj
ll kdkd baidu
x
'; setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); equal(editor.body.firstChild.firstChild.tagName.toLowerCase(), 'span', 'font转换成span'); if (ua.browser.gecko || ua.browser.ie) equal($(editor.body.firstChild.firstChild).css('font-size'), '16px', '检查style'); else equal($(editor.body.firstChild.firstChild).css('font-size'), '16px', '检查style'); var EMstyle = $(editor.body.firstChild.firstChild).css('color'); ok(EMstyle == 'rgb(255, 0, 0)' || EMstyle == 'red' || EMstyle == '#ff0000', '检查style'); equal(ua.getChildHTML(editor.body.firstChild.firstChild), 'x', 'b转成strong,i转成em '); start(); }, 20); }, 20); stop(); // } }); test('trace 3334:img和a之间不会产生多余空格', function () { var editor = te.obj[0]; editor.setContent(''); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); setTimeout(function () { editor.execCommand('source'); ua.manualDeleteFillData(editor.body); var html = ''; ua.checkSameHtml(editor.body.innerHTML.toLowerCase(), html, '查看img和a之间是否会产生多余空格'); start(); }, 20); }, 20); }, 20); stop(); }); test('trace 3334:table中td不会产生多余空格', function () { var editor = te.obj[0]; editor.execCommand('inserttable'); var br = baidu.editor.browser.ie ? '' : '