Ticket #2935: 2935_8.patch
File 2935_8.patch, 40.9 KB (added by , 15 years ago) |
---|
-
_source/tests/core/dom/windowtestpopup2.html
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <title>Popup Testing Window 2</title> 4 </head> 5 <body> 6 </body> 7 </html> 8 No newline at end of file -
_source/tests/core/dom/range.html
1294 1294 assert.areSame( 0, range.endOffset, 'range.endOffset' ); 1295 1295 assert.isTrue( range.collapsed, 'range.collapsed' ); 1296 1296 }, 1297 /** 1298 * Test extract text nodes contents. 1299 */ 1300 test_extractContents_Other_7 : function() 1301 { 1302 var container = CKEDITOR.document.getById( 'playground' ); 1303 container.setHtml( '' ); 1304 var textNode = new CKEDITOR.dom.text( 'text content' ); 1305 container.append( textNode ); 1306 1307 var range = new CKEDITOR.dom.range( doc ); 1308 1309 range.setStartAfter( textNode ); 1310 range.setEndBefore( textNode ); 1311 1312 var docFrag = range.extractContents(); 1313 1314 var tmpDiv = doc.createElement( 'div' ); 1315 docFrag.appendTo( tmpDiv ); 1297 1316 1317 assert.areSame( 'text content', getInnerHtml( tmpDiv.$ ), 1318 'Extracted HTML doesn\'t match.' ); 1319 assert.areSame( '', getInnerHtml( 'playground' ), 1320 'HTML doesn\'t match after extracted.' ); 1321 1322 assert.areSame( textNode, 1323 range.startContainer.$, 'range.startContainer' ); 1324 assert.areSame( 0, range.startOffset, 'range.startOffset' ); 1325 assert.areSame( textNode, 1326 range.endContainer.$, 'range.endContainer' ); 1327 assert.areSame( 12, range.endOffset, 'range.endOffset' ); 1328 assert.areSame( 1, container.getChildren().count(), 'Text nodes breaked.' ); 1329 }, 1330 1298 1331 test_cloneContents_W3C_1 : function() 1299 1332 { 1300 1333 // W3C DOM Range Specs - Section 2.7 - Example 1 … … 1510 1543 assert.areSame( 3, range.endOffset, 'range.endOffset' ); 1511 1544 assert.isFalse( range.collapsed, 'range.collapsed' ); 1512 1545 }, 1546 1547 /** 1548 * Make sure clone doesn't break text nodes. 1549 */ 1550 test_cloneContents_Other_5 : function() 1551 { 1552 var container = CKEDITOR.document.getById( 'playground' ); 1553 container.setHtml( '' ); 1554 var textNode = new CKEDITOR.dom.text( 'text content' ); 1555 container.append( textNode ); 1556 1557 var range = new CKEDITOR.dom.range( doc ); 1558 1559 range.setStart( textNode, 5 ); 1560 range.setEndBefore( textNode ); 1561 1562 var docFrag = range.cloneContents(); 1563 1564 var tmpDiv = doc.createElement( 'div' ); 1565 docFrag.appendTo( tmpDiv ); 1566 1567 assert.areSame( 'content', getInnerHtml( tmpDiv.$ ), 1568 'Cloned HTML doesn\'t match.' ); 1569 assert.areSame( 'text content', getInnerHtml( 'playground' ), 1570 'HTML doesn\'t match after cloning.' ); 1571 1572 assert.areSame( document.getElementById( 'playground' ).firstChild, 1573 range.startContainer.$, 'range.startContainer' ); 1574 assert.areSame( 5, range.startOffset, 'range.startOffset' ); 1575 assert.areSame( document.getElementById( 'playground' ), 1576 range.endContainer.$, 'range.endContainer' ); 1577 assert.areSame( 1, range.endOffset, 'range.endOffset' ); 1578 assert.areSame( 1, container.getChildren().count(), 1579 'Keep text nodes breaked.' ); 1580 }, 1513 1581 1514 1582 test_createBookmark2_1 : function() 1515 1583 { -
_source/tests/core/dom/windowtestpopup1.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Popup Testing Window 1</title> 5 </head> 6 <body> 7 </body> 8 </html> 9 No newline at end of file -
_source/tests/core/dom/documentFragment.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.dom.documentFragment</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 13 CKEDITOR.test.addTestCase( (function() 14 { 15 // Local reference to the "assert" object. 16 var assert = YAHOO.util.Assert; 17 18 return { 19 20 /** 21 * Test dom native listener invoked correct times. 22 */ 23 test_addEventListener1 : function() 24 { 25 var element = CKEDITOR.document.getById( 'nativeEvent' ), callbackCount = 0; 26 element.on( 'click', function() 27 { 28 callbackCount++; 29 } ); 30 element.on( 'click', function() 31 { 32 callbackCount++; 33 } ); 34 action.click( element.$ ); 35 // waits and then run assertion 36 this.wait( function() 37 { 38 assert.areEqual( 2, callbackCount, 39 'Event handler should be invoked ' + 2 + ' times.' ); 40 }, 500 ); 41 }, 42 43 /** 44 * Test prevent and stop dom native event. 45 */ 46 test_addEventListener2 : function() 47 { 48 var element = CKEDITOR.document.getById( 'nativeEvent' ), innerElement = CKEDITOR.document 49 .getById( 'nativeEventInner' ), preventFailed = false, stopFailed = false; 50 // Test stop propagation 51 element.on( 'click', function() 52 { 53 stopFailed = true; 54 } ); 55 innerElement.on( 'click', function( evt ) 56 { 57 evt.data.preventDefault( true ); 58 } ); 59 // Test prevent others 60 innerElement.on( 'click', function() 61 { 62 preventFailed = true; 63 } ); 64 65 action.click( innerElement.$ ); 66 // waits and then run assertion 67 this.wait( function() 68 { 69 assert.isFalse( preventFailed, 'Prevent event failed.' ); 70 assert.isFalse( stopFailed, 'Stop event failed.' ); 71 }, 500 ); 72 }, 73 name : document.title 74 }; 75 })() ); 76 77 //]]> 78 </script> 79 </head> 80 <body> 81 <div id="fragmentContainer1"></div> 82 <div id="fragmentContainer2"><div id="fragmentSibling1"></div></div> 83 </body> 84 </html> 85 No newline at end of file -
_source/tests/core/dom/nodelist.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.dom.nodelist</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 13 CKEDITOR.test.addTestCase( ( function() 14 { 15 // Shortcuts 16 var assert = YAHOO.util.Assert, arrayAssert = YAHOO.util.ArrayAssert; 17 18 return { 19 /** 20 * Test nodes list of type: HTMLCollection/NodeList 21 */ 22 test_nodeList1 : function() 23 { 24 var container = document.getElementById( 'nodesContainer1' ); 25 var nativeList = container.getElementsByTagName( 'span' ), 26 children = new CKEDITOR.dom.element( 27 container ).getChildren(); 28 var nodeList = new CKEDITOR.dom.nodeList( nativeList ), nodeListCollection = []; 29 assert.areSame( 3, nodeList.count(), 'Items num doesn\'t match.' ); 30 31 var i, l = nodeList.count(); 32 for ( i = 0 ; i < l ; i++ ) 33 { 34 nodeListCollection.push( nodeList.getItem( i ) ); 35 } 36 arrayAssert.itemsAreEquivalent( children, 37 nodeListCollection, function( item1, item2 ) 38 { 39 return item1.equals( item2 ); 40 }, 'Specific item in nodelist doesn\'t match.' ); 41 }, 42 43 /** 44 * Test HTMLSelectElement options property 45 */ 46 test_nodeList2 : function() 47 { 48 var select = CKEDITOR.document.getById( 'select1' ); 49 var nativeList = select.$.options, resultList = select 50 .getElementsByTag( 'option' ); 51 52 var nodeList = new CKEDITOR.dom.nodeList( nativeList ), 53 nodeListCollection = []; 54 assert.areSame( 3, nodeList.count(), 'Items num doesn\'t match.' ); 55 56 var i, l = nodeList.count(); 57 for ( i = 0 ; i < l ; i++ ) 58 { 59 nodeListCollection.push( nodeList.getItem( i ) ); 60 } 61 arrayAssert.itemsAreEquivalent( resultList, 62 nodeListCollection, function( item1, item2 ) 63 { 64 return item1.equals( item2 ); 65 }, 'Specific item in nodelist doesn\'t match.' ); 66 }, 67 68 ///////////// 69 70 name :document.title 71 }; 72 } )() ); 73 //]]> 74 </script> 75 </head> 76 <body> 77 <div id="nodesContainer1"><span>text<span>text</span></span><span>text</span></div> 78 <select id="select1"><optgroup><option>label</option><option>label</option></optgroup><option>label</option></select> 79 </body> 80 </html> 81 No newline at end of file -
_source/tests/core/dom/element.html
15 15 // Local reference to the "assert" object. 16 16 var assert = CKEDITOR.test.assert; 17 17 var getInnerHtml = CKEDITOR.test.getInnerHtml; 18 18 19 function trimExpando(str){ 20 var newStr = str.replace(/\s?_cke_[\w]+=\".*?\"\s?/gi,''); 21 return newStr; 22 } 23 19 24 return { 20 25 test_$ : function() 21 26 { … … 46 51 var element = new CKEDITOR.dom.element( document.getElementById( 'test1' ) ); 47 52 assert.isNull( element.getNameAtt() ); 48 53 }, 54 /** 55 * Test dynamic created all elements which support 'name' attribute. 56 */ 57 test_getNameAtt2 : function() 58 { 59 var supportNameTags = [ 'a', 'applet', 'button', 'embed', 'form', 60 'frame', 'iframe', 'input', 'meta', 'object', 'param', 'select' ], element; 61 62 var i, l = supportNameTags.length; 63 for ( i = 0 ; i < l ; i++ ) 64 { 65 element = new CKEDITOR.dom.element( supportNameTags[ i ] ); 66 element.setAttribute( 'name', 'test' ); 67 assert.areEqual( 'test', element.getNameAtt(), 68 'name attribute doesn\'t match on ' + supportNameTags[ i ] ); 69 } 70 }, 49 71 50 72 test_getName : function() 51 73 { … … 75 97 76 98 assert.areEqual( '', nativeElement.style.display ); 77 99 }, 100 /** 101 * Test display inheritance 102 */ 103 test_show2 : function() 104 { 105 var element = CKEDITOR.document.getById( 'show2' ); 106 element.show(); 107 assert.areEqual( 'block', element.getComputedStyle( 'display' ), 108 '"display" doesn\'t match' ); 109 }, 110 111 /** 112 * Test visibility inheritance 113 */ 114 test_show3 : function() 115 { 116 var element = CKEDITOR.document.getById( 'show2' ); 117 element.show(); 118 assert.areEqual( 'visible', element.getComputedStyle( 'visibility' ), 119 '"visibility" doesn\'t match' ); 120 }, 78 121 79 122 test_createFromHtml : function() 80 123 { … … 233 276 assert.areEqual( 'absolute', document.getElementById( 'setStyle' ).style.position ); 234 277 assert.areEqual( 'right', document.getElementById( 'setStyle' ).style.cssFloat ); 235 278 }, 279 /** 280 * Test boundary opacity style values. 281 */ 282 test_setOpacity : function() 283 { 284 var opacityValues = [ 1, 0.5, 0 ]; 285 286 var i, l = opacityValues.length; 287 for ( i = 0 ; i < l ; i++ ) 288 { 289 var element = new CKEDITOR.dom.element( 'span' ); 290 element.setOpacity( opacityValues[ i ] ); 291 assert.areEqual( opacityValues[ i ], element 292 .getComputedStyle( 'opacity' ), "Opacity style value of " 293 + opacityValues[ i ] + " doesn\'t match." ); 294 } 295 }, 236 296 237 297 test_setText1 : function() 238 298 { … … 400 460 var element = new CKEDITOR.dom.element( document.getElementById( 'tabIndexScriptDef' ) ); 401 461 assert.areEqual( null, element.getAttribute( 'tabindex' ) ); 402 462 }, 463 464 test_getAttribute_Style : function() 465 { 466 var element = new CKEDITOR.dom.element( 'span' ); 467 if ( CKEDITOR.env.ie ) 468 element.$.style.cssText = 'float:right'; 469 else 470 element.$.setAttribute( 'style', 'float:right' ); 471 472 assert.areSame( 'float: right;', element.getAttribute( 'style' ) ); 473 }, 403 474 404 475 test_getTabIndex1 : function() 405 476 { … … 486 557 var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] ); 487 558 assert.isTrue( element.hasAttributes() ); 488 559 }, 560 /** 561 * Test dynamic attribute existence 562 */ 563 test_hasAttributes3 : function() 564 { 565 var element = new CKEDITOR.dom.element( 'span' ); 566 element.setAttribute( 'class', 'testclass' ); 567 element.removeAttribute( 'class' ); 568 assert.isFalse( element.hasAttributes() ); 569 }, 570 571 /** 572 * Test attribute abbreviation 573 */ 574 test_hasAttributes4 : function() 575 { 576 var element = CKEDITOR.document.getById( 'attributed1' ); 577 assert.isTrue( element.hasAttributes() ); 578 }, 579 /** 580 * Test 'float' style computed value 581 */ 582 test_getComputedStyle1 : function() 583 { 584 var element = document.createElement( 'span' ); 585 if ( CKEDITOR.env.ie ) 586 element.style.cssText = 'float:right'; 587 else 588 element.setAttribute( 'style', 'float:right' ); 589 590 element = new CKEDITOR.dom.element( element ); 591 assert.areSame( 'right', element.getComputedStyle( 'float' ), 592 'float style doesn\'t match' ); 593 element.remove(); 594 }, 595 596 /** 597 * Test box-model computed styles. 598 */ 599 test_getComputedStyle2 : function() 600 { 601 var element = CKEDITOR.document.getById( 'test-computed' ); 602 var nativeElement = element.$; 603 604 nativeElement.style.zoom = 1; 605 nativeElement.style.border = 'medium solid #000'; 606 607 var bw = CKEDITOR.env.ie ? 4 : 3; 608 var h = nativeElement.offsetHeight - 20 - 2 * bw; 609 assert.areEqual( bw + 'px', element 610 .getComputedStyle( 'border-top-width' ), 611 'borderTopWidth: medium doesn\'t match' ); 612 assert.areEqual( h, Math.round( parseFloat( element 613 .getComputedStyle( 'height' ) ) ), 614 'height: auto (offset minus padding and border) doesn\'t match' ); 615 nativeElement.style.padding = '1em'; 616 assert.areEqual( '16px', element.getComputedStyle( 'padding-top' ), 617 'padding:1em doesn\'t match' ); 618 nativeElement.style.margin = 'auto'; 619 assert.areEqual( '0px', element.getComputedStyle( 'margin-top' ), 620 'margin:auto doesn\'t match' ); 621 assert.areEqual( 493, 622 parseInt( element.getComputedStyle( 'width' ) ), 623 'percent:width (from CSS) doesn\'t match' ); 624 assert.areEqual( 'visible', 625 element.getComputedStyle( 'visibility' ), 626 'visibility doesn\'t match' ); 627 nativeElement.parentNode.style.visibility = 'hidden'; 628 assert.areEqual( 'hidden', 629 element.getComputedStyle( 'visibility' ), 630 'visibility doesn\'t match' ); 631 nativeElement.parentNode.style.visibility = 'visible'; 632 assert.areEqual( 2, element.getComputedStyle( 'z-index' ), 633 'element.getComputedStyle("zIndex") doesn\'t match' ); 634 }, 635 test_getComputedStyle2 : function() 636 { 637 var element = new CKEDITOR.dom.element( 'span' ); 638 element.setOpacity( 0.75 ); 639 assert.areSame( 0.75, element.getComputedStyle( 'opacity' ), 640 'opacity style doesn\'t match' ); 641 element.remove(); 642 }, 643 644 test_moveChildren1 : function() 645 { 646 var source = CKEDITOR.document.getById('childrenParent1'), 647 target = CKEDITOR.document.getById('childrenTarget1'), 648 firstChild = CKEDITOR.document.getById('firstChild1'); 649 650 source.moveChildren(target); 651 assert.areSame(firstChild.$, target.$.childNodes[1]); 652 }, 653 654 test_moveChildren2 : function() 655 { 656 var source = CKEDITOR.document.getById('childrenParent2'), 657 target = CKEDITOR.document.getById('childrenTarget2'), 658 secondChild = CKEDITOR.document.getById('firstChild2'); 659 660 source.moveChildren(target, true); 661 assert.areSame(secondChild.$, target.$.childNodes[0]); 662 }, 663 664 665 666 test_Markers : function() 667 { 668 var element1 = new CKEDITOR.dom.element( 'span' ), 669 element2 = new CKEDITOR.dom.element( 'span' ), 670 db = {}; 671 var markerName = 'fck_test_touched'; 672 673 CKEDITOR.dom.element.setMarker(db, element1, markerName, true); 674 assert.areSame(true, element1.getCustomData(markerName), 'Set marker of value: '+true+' failed.'); 675 CKEDITOR.dom.element.setMarker(db, element2, markerName, 1); 676 assert.areSame(1, element2.getCustomData(markerName), 'Set marker of value: '+1+' failed.'); 677 678 CKEDITOR.dom.element.clearAllMarkers(db); 679 assert.isNull(element1.getCustomData(markerName), 'Bounch clear markers failed.'); 680 assert.isNull(element2.getCustomData(markerName), 'Bounch clear markers failed.'); 681 682 }, 683 684 test_breakParent1 : function() 685 { 686 CKEDITOR.document.getById( 'breakParentLeaf1' ).breakParent( 687 CKEDITOR.document.getById( 'breakParentRoot1' ) ); 688 assert.areEqual( CKEDITOR.document.getById( 'breakParentResult1' ) 689 .getHtml(), trimExpando( CKEDITOR.document.getById( 690 'breakParentContainer1' ).getHtml() ) ); 691 }, 692 693 test_breakParent2 : function() 694 { 695 CKEDITOR.document.getById( 'breakParentLeaf2' ).breakParent( 696 CKEDITOR.document.getById( 'breakParentRoot2' ) ); 697 assert.areEqual( CKEDITOR.document.getById( 'breakParentResult2' ) 698 .getHtml(), trimExpando( CKEDITOR.document.getById( 699 'breakParentContainer2' ).getHtml() ) ); 700 }, 489 701 490 702 name : document.title 491 703 }; … … 493 705 494 706 //]]> 495 707 </script> 708 <style type="text/css" media="screen"> 709 #test-computed { 710 width:50%; 711 margin:auto; 712 padding:10px; 713 z-index: 2; 714 } 715 </style> 496 716 </head> 497 717 <body> 498 718 <textarea id="test1" rows="10" cols="80"></textarea> … … 515 735 B</div> 516 736 <big>Test</big> 517 737 <small title="Testing">Test</small> 738 <input id="attributed1" checked /> 739 <div style="display:none"><div id="show2"></div></div> 740 <div style="visibility:hidden"><div id="show3"></div></div> 741 <div id="childrenParent1"><span id="firstChild1">text</span></div> 742 <div id="childrenTarget1"><span>text</span></div> 743 <div id="childrenParent2"><span id="firstChild2">text</span></div> 744 <div id="childrenTarget2"><span>text</span></div> 745 <div id="test-computed">test computed style</div> 746 747 <div id="breakParentContainer1"><b id="breakParentRoot1">This <i>is some<span id="breakParentLeaf1"></span> sample</i> test text</b></div> 748 <pre id="breakParentResult1"><b id="breakParentRoot1">This <i>is some</i></b><span id="breakParentLeaf1"></span><b id="breakParentRoot1"><i> sample</i> test text</b></pre> 749 750 <div id="breakParentContainer2"><b>This <i id="breakParentRoot2">is some<span id="breakParentLeaf2"></span> sample</i> test text</b></div> 751 <pre id="breakParentResult2"><b>This <i id="breakParentRoot2">is some</i><span id="breakParentLeaf2"></span><i id="breakParentRoot2"> sample</i> test text</b></pre> 752 518 753 </body> 519 754 </html> -
_source/tests/core/dom/window.html
41 41 { 42 42 assert.isTrue( loadCalled ); 43 43 }, 44 45 // The following two test case require browser's popup-blocker been turned off 46 47 /** 48 * Test compat and quirk mode has same view size. 49 */ 50 test_getViewPaneSize1 : function() 51 { 52 var windowUrls = [ 'windowtestpopup1.html', 'windowtestpopup2.html' ]; 53 var i, l = windowUrls.length; 54 for ( i = 0 ; i < l ; i++ ) 55 { 56 // Standardize window size by popup new window. 57 var newWindow = window.open( windowUrls[ i ], 'testWindow', 58 'height=500,width=500' ); 59 var size = ( new CKEDITOR.dom.window( newWindow ) ) 60 .getViewPaneSize(); 61 assert.areEqual( 500, size.width, 62 'Width of viewport doesn\'t match.' ); 63 assert.areEqual( 500, size.height, 64 'Height of viewport doesn\'t match.' ); 65 newWindow.close(); 66 } 67 }, 44 68 69 /** 70 * Test focus between main window and popups. 71 */ 72 test_focus1 : function() 73 { 74 var newWindow = window.open( 'windowtestpopup1.html', 'testWindow', 75 'height=500,width=500' ); 76 var win = new CKEDITOR.dom.window( newWindow ), count = 0; 77 win.on( 'focus', function() 78 { 79 count++; 80 } ); 81 win.focus(); 82 this.wait( function() 83 { 84 assert.areEqual( 1, count ); 85 newWindow.close(); 86 }, 500 ); 87 }, 88 89 /** 90 * Test focus between main window and inline frames. 91 */ 92 test_focus2 : function() 93 { 94 var innerWindow = document.getElementById( 'innerFrame1' ).contentWindow; 95 innerWindow.focus(); 96 var win = CKEDITOR.document.getWindow(), count = 0; 97 win.on( 'focus', function() 98 { 99 count++; 100 } ); 101 win.focus(); 102 this.wait( function() 103 { 104 assert.areEqual( 1, count ); 105 }, 500 ); 106 }, 107 45 108 name : document.title 46 109 }; 47 110 })() ); … … 50 113 </script> 51 114 </head> 52 115 <body> 53 < div id="test1"></div>116 <iframe id="innerFrame1" src='windowtestpopup1.html'></iframe> 54 117 </body> 55 118 </html> -
_source/tests/core/dom/document.html
89 89 assert.areSame( document.body, doc.getBody().$, '1st call failed' ); 90 90 assert.areSame( document.body, doc.getBody().$, '2nd call failed' ); 91 91 }, 92 test_createText : function() 93 { 94 var doc = new CKEDITOR.dom.document( document ), contentText = 'text content'; 95 var textNode = doc.createText( contentText ); 96 assert.areSame( contentText, textNode.getText(), 97 'Create text node content doesn\'t match.' ); 92 98 99 }, 100 101 test_getByAddress1 : function() 102 { 103 var doc = new CKEDITOR.dom.document( document ); 104 var node = doc.getByAddress( [ 1, 3, 0, 1, 0, 0 ] ); 105 assert.areSame( 'target', node.getText(), 106 'Addressing target doesn\'t match.' ); 107 }, 108 /** 109 * Test get address of normalized text nodes. 110 */ 111 test_getByAddress2 : function() 112 { 113 var doc = new CKEDITOR.dom.document( document ); 114 var target = doc.getById( 'addressTarget2' ); 115 target.insertBeforeMe( new CKEDITOR.dom.text( 'text' ) ); 116 target.insertBeforeMe( new CKEDITOR.dom.text( 'text' ) ); 117 var node = doc.getByAddress( [ 1, 5, 1, 0 ], true ); 118 assert.areSame( 'target', node.getText(), 119 'Addressing normalized target doesn\'t match.' ); 120 }, 93 121 name : document.title 94 122 }; 95 123 })() ); … … 99 127 </head> 100 128 <body> 101 129 <div id="test1"></div> 130 <div><p>text<span><b id="addressTarget1">target</b>text</span>text</p></div> 131 <span ><b id="addressTarget2">target</b></span> 102 132 </body> 103 133 </html> -
_source/tests/core/dom/elementpath.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.dom.elementpath</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 13 CKEDITOR.test.addTestCase( ( function() 14 { 15 // Refering to 'The Web Design Group(htmlhelp.com/reference/html40)' 16 var html4BlocklevelElementNames = [ 'address', 'blockquote', 'center', 'dir', 17 'div', 'dl', 'fieldset', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 18 'isindex', 'menu', 'noframes', 'noscript', 'ol', 'p', 'pre', 'table', 'ul', 19 'dd', 'dt', 'frameset', 'li', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr' ]; 20 var html4InlineElementNames = [ 'a', 'abbr', 'acronym', 'b', 'basefont', 'bdo', 21 'big', 'br', 'cite', 'code', 'dfn', 'em', 'font', 'i', 'img', 'input', 22 'kbd', 'label', 'q', 's', 'samp', 'select', 'small', 'span', 'strike', 23 'strong', 'sub', 'sup', 'textarea', 'tt', 'u', 'var' ]; 24 // var html4InlineOrBlocklevelNames = 25 // ['applet','button','del','iframe','ins','map','object','script']; 26 27 // Same as element set defined in _source/core/dom/elementpath.js 28 var blockLimitElementNames = [ 'div', 'td', 'th', 'tfoot', 'caption', 'form' ]; 29 30 // Shortcuts 31 var assert = YAHOO.util.Assert, arrayAssert = YAHOO.util.ArrayAssert; 32 33 return 34 { 35 /** 36 * Test element classificaton completeness. 37 */ 38 test_elementPath1 : function() 39 { 40 var body = CKEDITOR.document.getBody(); 41 var i, l = blockLimitElementNames.length, 42 j, s = html4BlocklevelElementNames.length, 43 k, t = html4InlineElementNames.length; 44 var blocklimit, block, inline, path; 45 46 for ( i = 0 ; i < l ; i++ ) 47 { 48 blocklimit = body.append( new CKEDITOR.dom.element( 49 blockLimitElementNames[ i ] ) ); 50 for ( j = 0 ; j < s ; j++ ) 51 { 52 block = blocklimit.append( new CKEDITOR.dom.element( 53 html4BlocklevelElementNames[ j ] ) ); 54 for ( k = 0 ; k < t ; k++ ) 55 { 56 inline = block.append( new CKEDITOR.dom.element( 57 html4InlineElementNames[ k ] ) ); 58 59 path = new CKEDITOR.dom.elementPath( inline ); 60 assert.isTrue( inline.equals( path.lastElement ), 61 'Last path element ' + html4InlineElementNames[ k ] + ' doesn\'t match.' ); 62 assert.isTrue( block.equals( path.block ), 63 'Block element ' + html4BlocklevelElementNames[ j ] + ' doesn\'t match.' ); 64 assert .isTrue( blocklimit.equals( path.blockLimit ), 65 'Block limit element ' + blockLimitElementNames[ i ] + ' doesn\'t match.' ); 66 arrayAssert.itemsAreEquivalent( path.elements, [ 67 inline, block, blocklimit, body ], function( item1, item2 ) 68 { 69 return item1.equals( item2 ); 70 }, 71 'Element path elements doesn\'t match.' ); 72 73 inline.remove(); 74 } 75 76 block.remove(); 77 } 78 79 blocklimit.remove(); 80 } 81 }, 82 83 ///////////// 84 85 name :document.title 86 }; 87 } )() ); 88 //]]> 89 </script> 90 </head> 91 <body> 92 </body> 93 </html> 94 No newline at end of file -
_source/tests/core/dom/domobject.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.dom.domobject</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 13 CKEDITOR.test.addTestCase( (function() 14 { 15 // Local reference to mthe "assert" object. 16 var assert = YAHOO.util.Assert, action = YAHOO.util.UserAction; 17 18 return { 19 20 /** 21 * Test dom native listener invoked correct times. 22 */ 23 test_AddEventListener1 : function() 24 { 25 var element = CKEDITOR.document.getById( 'nativeEvent' ), callbackCount = 0; 26 element.on( 'click', function() 27 { 28 callbackCount++; 29 } ); 30 element.on( 'click', function() 31 { 32 callbackCount++; 33 } ); 34 action.click( element.$ ); 35 // waits and then run assertion 36 this.wait( function() 37 { 38 assert.areEqual( 2, callbackCount, 39 'Event handler should be invoked ' + 2 + ' times.' ); 40 }, 500 ); 41 }, 42 43 /** 44 * Test prevent and stop dom native event. 45 */ 46 test_AddEventListener2 : function() 47 { 48 var element = CKEDITOR.document.getById( 'nativeEvent' ), innerElement = CKEDITOR.document 49 .getById( 'nativeEventInner' ), preventFailed = false, stopFailed = false; 50 // Test stop propagation 51 element.on( 'click', function() 52 { 53 stopFailed = true; 54 } ); 55 innerElement.on( 'click', function( evt ) 56 { 57 evt.data.preventDefault( true ); 58 } ); 59 // Test prevent others 60 innerElement.on( 'click', function() 61 { 62 preventFailed = true; 63 } ); 64 65 action.click( innerElement.$ ); 66 // waits and then run assertion 67 this.wait( function() 68 { 69 assert.isFalse( preventFailed, 'Prevent event failed.' ); 70 assert.isFalse( stopFailed, 'Stop event failed.' ); 71 }, 500 ); 72 }, 73 name : document.title 74 }; 75 })() ); 76 77 //]]> 78 </script> 79 </head> 80 <body> 81 <div id='nativeEvent'><span id='nativeEventInner'></span></div> 82 </body> 83 </html> 84 No newline at end of file -
_source/tests/core/dom/domwalker.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CKEDITOR.dom.domwalker</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% 7 <script type="text/javascript" src="../../../ckeditor.js"></script> 8 %REMOVE_LINE% --> 9 <script type="text/javascript" src="../../test.js"></script> 10 <script type="text/javascript"> 11 //<![CDATA[ 12 CKEDITOR.test.addTestCase( ( function() 13 { 14 // Local reference to the "assert" object. 15 var assert = CKEDITOR.test.assert; 16 17 // Temporary 'getName' compensate for textnode. 18 CKEDITOR.dom.text.prototype.getName = function() 19 { 20 return '#text'; 21 }; 22 23 var tranverseSequence = [ "div", "h1", "a", "#text", "ul", "li", "#text", 24 "li", "#text", "br", "table", "tbody", "tr", "td", "#text", "span", 25 "form", "fieldset", "legend", "#text", "label", "#text", "input" ]; 26 return { 27 28 test_forward : function() 29 { 30 var steps = [], resultSteps = tranverseSequence.concat(); 31 32 var walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 33 .getById( 'walkerStartMark1' ) ); 34 walker.on( 'step', function( evt ) 35 { 36 var node = evt.data.node; 37 steps.push( node.getName() ); 38 } ); 39 walker.forward( function( evt ) 40 { 41 var to = evt.data.to; 42 var id; 43 if ( ( to.type == CKEDITOR.NODE_ELEMENT ) 44 && ( id = to.getAttribute( 'id' ) ) 45 && id == 'walkerEndMark' ) 46 this.stop(); 47 } ); 48 assert.isTrue( CKEDITOR.tools.arrayCompare( resultSteps, steps ), 49 'Walking steps forward doesn\'t match.' ); 50 }, 51 52 test_reverse : function() 53 { 54 var steps = [], resultSteps = tranverseSequence.concat().reverse(); 55 56 var walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 57 .getById( 'walkerEndMark' ) ); 58 walker.on( 'step', function( evt ) 59 { 60 var node = evt.data.node; 61 steps.push( node.getName() ); 62 } ); 63 walker.reverse( function( evt ) 64 { 65 var to = evt.data.to; 66 var id; 67 if ( ( to.type == CKEDITOR.NODE_ELEMENT ) 68 && ( id = to.getAttribute( 'id' ) ) 69 && id == 'walkerStartMark1' ) 70 this.stop(); 71 } ); 72 assert.isTrue( CKEDITOR.tools.arrayCompare( resultSteps, steps ), 73 'Walking steps reversely doesn\'t match.' ); 74 }, 75 76 test_stopBlockBoundary1 : function() 77 { 78 var walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 79 .getById( 'walkerStartMark2' ) ); 80 var endNode = walker.forward( CKEDITOR.dom.domWalker 81 .blockBoundary() ).node, resultNode = CKEDITOR.document 82 .getById( 'walkerEndMark2' ); 83 assert.isTrue( resultNode.equals( endNode ), 84 'Walking foward doesn\'t stop at block boundaries.' ); 85 86 walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 87 .getById( 'walkerStartMark3' ) ); 88 var startNode = walker.reverse( CKEDITOR.dom.domWalker 89 .blockBoundary() ).node; 90 resultNode = CKEDITOR.document.getById( 'walkerEndMark3' ); 91 assert.isTrue( resultNode.equals( startNode ), 92 'Walking reversely doesn\'t stop at block boundaries.' ); 93 }, 94 95 test_stopBlockBoundary2 : function() 96 { 97 var walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 98 .getById( 'walkerStartMark6' ) ); 99 var endNode = walker.forward( CKEDITOR.dom.domWalker 100 .blockBoundary() ).node, resultNode = CKEDITOR.document 101 .getById( 'walkerEndMark6' ); 102 assert.isTrue( resultNode.equals( endNode ), 103 'Walking forward doesn\'t stop at block boundaries.' ); 104 }, 105 106 test_stopListItemBoundary : function() 107 { 108 var walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 109 .getById( 'walkerStartMark4' ) ); 110 var endNode = walker.forward( CKEDITOR.dom.domWalker 111 .listItemBoundary() ).node, resultNode = CKEDITOR.document 112 .getById( 'walkerEndMark4' ); 113 assert.isTrue( resultNode.equals( endNode ), 114 'Walking forward doesn\'t stop at list items boundaries.' ); 115 116 walker = new CKEDITOR.dom.domWalker( CKEDITOR.document 117 .getById( 'walkerStartMark5' ) ); 118 var startNode = walker.reverse( CKEDITOR.dom.domWalker 119 .blockBoundary() ).node; 120 resultNode = CKEDITOR.document.getById( 'walkerEndMark5' ); 121 assert.isTrue( resultNode.equals( startNode ), 122 'Walking reversely doesn\'t stop at list items boundaries.' ); 123 }, 124 125 name :document.title 126 }; 127 } )() ); 128 //]]> 129 </script> 130 </head> 131 <body> 132 <span id="walkerStartMark1"></span><div><h1><a>text</a></h1><ul><li>text</li><li>text</li></ul><br/><table><tbody><tr><td>text</td></tr></tbody></table><span><form><fieldset><legend>text</legend><label>text</label><input type="text"/></fieldset></form></span></div><span id="walkerEndMark"></span> 133 134 <span id="walkerStartMark2"></span><span><b>text</b>text<input id="walkerEndMark2" type="hidden" /><p>text</p></span> 135 <span><p>text</p><input id="walkerEndMark3" type="hidden" /><b>text</b><span id="walkerStartMark3"></span></span> 136 137 <span id="walkerStartMark4"></span><span><b>text</b>text<input id="walkerEndMark4" type="hidden" /><br/></span> 138 <ul><li><input id="walkerEndMark5" type="hidden" /><b>text</b><span id="walkerStartMark5"></span></li></ul> 139 140 <table><tr><td><span id="walkerStartMark6"><span>text</span><input id="walkerEndMark6" type="hidden" /></td><td></td></tr></table> 141 </body> 142 </html> 143 No newline at end of file -
_source/tests/core/tools.html
46 46 assert.areSame( 'Good' , target.prop6, 'prop6 doesn\'t match' ); 47 47 assert.areSame( fakeArray , target.prop7, 'prop7 doesn\'t match' ); 48 48 }, 49 49 /** 50 * Test arguments and context object correctness. 51 */ 52 test_bind : function() 53 { 54 var context = {}, 55 args = ['string',1,true, /^/]; 56 var unbind = function(){ 57 assert.areSame( context, this, 'function context object doesn\'t match'); 58 var i, l = arguments.length; 59 for (i = 0; i < l; i++) { 60 assert.areSame( arguments[i], args[i], 'argument '+i+' doesn\t match'); 61 } 62 }; 63 64 CKEDITOR.tools.bind( unbind, context )(args[0], 65 args[1], args[2], args[3]); 66 }, 67 68 /** 69 * Test strict comparison of array element 70 */ 71 test_indexOf : function() 72 { 73 var array = [ 1 ]; 74 75 assert.areSame( -1, CKEDITOR.tools.indexOf(array, '1'), 'Doesn\'t distinguish array element type'); 76 }, 77 50 78 test_isArray1 : function() 51 79 { 52 80 assert.isTrue( CKEDITOR.tools.isArray( [] ) ); … … 66 94 { 67 95 assert.isFalse( CKEDITOR.tools.isArray( window.x ) ); 68 96 }, 69 97 test_isArray5 : function() 98 { 99 var iframe = document.createElement('iframe'); 100 document.body.appendChild(iframe); 101 xArray = window.frames[window.frames.length-1].Array; 102 var array = new xArray(1,2,3); // [1,2,3] 103 assert.isTrue ( CKEDITOR.tools.isArray(array) ); 104 }, 70 105 test_htmlEncode1 : function() 71 106 { 72 107 assert.areSame( '<b>Test</b>', CKEDITOR.tools.htmlEncode( '<b>Test</b>' ) ); -
_source/tests/plugins/editingblock/editingblock.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Plugin: editingblock</title> 5 <link rel="stylesheet" type="text/css" href="../../test.css" /> 6 <script type="text/javascript" src="../../../../ckeditor_source.js"></script> 7 <script type="text/javascript" src="../../test.js"></script> 8 <script type="text/javascript"> 9 //<![CDATA[ 10 var testCase; 11 12 CKEDITOR.test.addTestCase( testCase = ( function() 13 { 14 // Local references. 15 var assert = YAHOO.util.Assert; 16 17 return { 18 /** 19 * Test init with 'wysiwyg' mode 20 */ 21 test_instanceReadyEvent1 : function() 22 { 23 var editor = CKEDITOR.replace( 'editor1' ); 24 var count = 0; 25 editor.on( 'instanceReady', function() 26 { 27 count++; 28 } ); 29 this.wait( function() 30 { 31 assert.areEqual( 1, count, 'Mode "wysiwyg" doesn\'t fully interacted ready.' ); 32 }, 1000 ); 33 }, 34 35 /** 36 * Test init with 'source' mode 37 */ 38 test_instanceReadyEvent2 : function() 39 { 40 var editor = CKEDITOR.replace( 'editor2', 41 { 42 startupMode :'source' 43 } ); 44 var count = 0; 45 editor.on( 'instanceReady', function() 46 { 47 count++; 48 } ); 49 50 this.wait( function() 51 { 52 assert.areEqual( 1, count, 'Mode "source" doesn\'t fully interacted ready.' ); 53 }, 1000 ); 54 }, 55 56 name :document.title 57 }; 58 } )() ); 59 //]]> 60 </script> 61 </head> 62 <body> 63 <textarea id="editor1" name="editor1"></textarea> 64 <textarea id="editor2" name="editor2"></textarea> 65 </body> 66 </html> 67 No newline at end of file