Ticket #2935: 2935_9.patch

File 2935_9.patch, 45.1 KB (added by Garry Yao, 15 years ago)

Covering htmlwritter and refacting documentFragment

  • _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

     
    12941294                        assert.areSame( 0, range.endOffset, 'range.endOffset' );
    12951295                        assert.isTrue( range.collapsed, 'range.collapsed' );
    12961296                },
     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 );
    12971316
     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               
    12981331                test_cloneContents_W3C_1 : function()
    12991332                {
    13001333                        // W3C DOM Range Specs - Section 2.7 - Example 1
     
    15101543                        assert.areSame( 3, range.endOffset, 'range.endOffset' );
    15111544                        assert.isFalse( range.collapsed, 'range.collapsed' );
    15121545                },
     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            },
    15131581
    15141582                test_createBookmark2_1 : function()
    15151583                {
  • _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[
     12CKEDITOR.test.addTestCase( ( function()
     13{
     14        // Local reference to the "assert" object.
     15        var assert = YAHOO.util.Assert;
     16
     17        return
     18        {
     19            /**
     20                 * Test append documentFragment to document node
     21                 */
     22            test_docFragmentAppend1 : function()
     23            {
     24                    var frag = new CKEDITOR.dom.documentFragment( CKEDITOR.document );
     25                    var inner = new CKEDITOR.dom.element( 'b' );
     26                    frag.append( inner );
     27                    var container = CKEDITOR.document.getById( 'fragmentContainer1' );
     28                    frag.appendTo( container );
     29                    assert.isTrue( container.getLast().equals( inner ) );
     30            },
     31
     32            /**
     33                 * Test append documentFragment to document node
     34                 */
     35            test_docFragmentAppend2 : function()
     36            {
     37                    var frag = new CKEDITOR.dom.documentFragment( CKEDITOR.document );
     38                    var inner = new CKEDITOR.dom.element( 'b' );
     39                    frag.append( inner );
     40                    var container = CKEDITOR.document.getById( 'fragmentContainer3' );
     41                    container.append( frag );
     42                    assert.isTrue( container.getLast().equals( inner ) );
     43            },
     44
     45            /**
     46                 * Test insert documentFragment after document node
     47                 */
     48            test_docFragmentInsertAfter : function()
     49            {
     50                    var frag = new CKEDITOR.dom.documentFragment( CKEDITOR.document );
     51                    var inner = new CKEDITOR.dom.element( 'b' );
     52                    frag.append( inner );
     53                    var container = CKEDITOR.document.getById( 'fragmentContainer2' );
     54                    var sibling = CKEDITOR.document.getById( 'fragmentSibling1' );
     55                    frag.insertAfterNode( sibling );
     56                    assert.isTrue( container.getLast().equals( inner ) );
     57            },
     58            name :document.title
     59        };
     60} )() );
     61
     62        //]]>
     63        </script>
     64</head>
     65<body>
     66        <div id="fragmentContainer1"></div>
     67        <div id="fragmentContainer2"><div id="fragmentSibling1"></div></div>
     68        <div id="fragmentContainer3"></div>
     69</body>
     70</html>
     71 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
     13CKEDITOR.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

     
    1515        // Local reference to the "assert" object.
    1616        var assert = CKEDITOR.test.assert;
    1717        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       
    1924        return {
    2025                test_$ : function()
    2126                {
     
    4651                        var element = new CKEDITOR.dom.element( document.getElementById( 'test1' ) );
    4752                        assert.isNull( element.getNameAtt() );
    4853                },
     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                },
    4971
    5072                test_getName : function()
    5173                {
     
    7597
    7698                        assert.areEqual( '', nativeElement.style.display );
    7799                },
     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                },
    78121
    79                 test_createFromHtml : function()
     122                test_createFromHtml1 : function()
    80123                {
    81124                        var element = CKEDITOR.dom.element.createFromHtml( '<p>My test</p>' );
    82125                        assert.areEqual( 'p', element.getName(), 'element name doesn\'t match' );
     
    82125                        assert.areEqual( 'p', element.getName(), 'element name doesn\'t match' );
    83126                        assert.areEqual( 'My test', element.$.innerHTML, 'the innerHTML doesn\'t match' );
    84127                },
     128               
     129                /**
     130                 * Test return {@link CKEDITOR.dom.documentFragment} when
     131                 * {@link CKEDITOR.dom.element.createFromHtml} receive argument of
     132                 * partly-formed or subsets of html snippets.
     133                 */
     134            test_createFromHtml2 : function()
     135            {
     136                    var element = CKEDITOR.dom.element
     137                        .createFromHtml( '<p>My test</p><p>My test</p>' );
     138                    assert.areEqual( CKEDITOR.NODE_DOCUMENT_FRAGMENT, element.type,
     139                        'element type doesn\'t match' );
     140
     141                    var container = CKEDITOR.dom.element( 'div' );
     142                    element.appendTo( container );
     143                    assert.areEqual( '<p>My test</p><p>My test</p>', container
     144                        .getHtml(), 'element content doesn\'t match' );
     145            },
    85146
    86147                test_append1 : function()
    87148                {
     
    233294                        assert.areEqual( 'absolute', document.getElementById( 'setStyle' ).style.position );
    234295                        assert.areEqual( 'right', document.getElementById( 'setStyle' ).style.cssFloat );
    235296                },
     297                /**
     298                 * Test boundary opacity style values.
     299                 */
     300                test_setOpacity : function()
     301                {
     302                        var opacityValues = [ 1, 0.5, 0 ];
     303       
     304                        var i, l = opacityValues.length;
     305                        for ( i = 0 ; i < l ; i++ )
     306                        {
     307                                var element = new CKEDITOR.dom.element( 'span' );
     308                                element.setOpacity( opacityValues[ i ] );
     309                                assert.areEqual( opacityValues[ i ], element
     310                                    .getComputedStyle( 'opacity' ), "Opacity style value of "
     311                                    + opacityValues[ i ] + " doesn\'t match." );
     312                        }
     313                },
    236314
    237315                test_setText1 : function()
    238316                {
     
    400478                        var element = new CKEDITOR.dom.element( document.getElementById( 'tabIndexScriptDef' ) );
    401479                        assert.areEqual( null, element.getAttribute( 'tabindex' ) );
    402480                },
     481               
     482                test_getAttribute_Style : function()
     483            {
     484                    var element = new CKEDITOR.dom.element( 'span' );
     485                    if ( CKEDITOR.env.ie )
     486                            element.$.style.cssText = 'float:right';
     487                    else
     488                            element.$.setAttribute( 'style', 'float:right' );
     489
     490                    assert.areSame( 'float: right;', element.getAttribute( 'style' ) );
     491            },
    403492
    404493                test_getTabIndex1 : function()
    405494                {
     
    486575                        var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] );
    487576                        assert.isTrue( element.hasAttributes() );
    488577                },
     578                /**
     579                 * Test dynamic attribute existence
     580                 */
     581            test_hasAttributes3 : function()
     582            {
     583                    var element = new CKEDITOR.dom.element( 'span' );
     584                    element.setAttribute( 'class', 'testclass' );
     585                    element.removeAttribute( 'class' );
     586                    assert.isFalse( element.hasAttributes() );
     587            },
     588
     589            /**
     590                 * Test attribute abbreviation
     591                 */
     592            test_hasAttributes4 : function()
     593            {
     594                    var element = CKEDITOR.document.getById( 'attributed1' );
     595                    assert.isTrue( element.hasAttributes() );
     596            },
     597            /**
     598             * Test 'float' style computed value
     599             */
     600            test_getComputedStyle1 : function()
     601            {
     602                    var element = document.createElement( 'span' );
     603                    if ( CKEDITOR.env.ie )
     604                            element.style.cssText = 'float:right';
     605                    else
     606                            element.setAttribute( 'style', 'float:right' );
     607
     608                    element = new CKEDITOR.dom.element( element );
     609                    assert.areSame( 'right', element.getComputedStyle( 'float' ),
     610                        'float style doesn\'t match' );
     611                    element.remove();
     612            },
     613           
     614            /**
     615             * Test box-model computed styles.
     616             */
     617            test_getComputedStyle2 : function()
     618            {
     619                    var element = CKEDITOR.document.getById( 'test-computed' );
     620                    var nativeElement = element.$;
     621
     622                    nativeElement.style.zoom = 1;
     623                    nativeElement.style.border = 'medium solid #000';
     624
     625                    var bw = CKEDITOR.env.ie ? 4 : 3;
     626                    var h = nativeElement.offsetHeight - 20 - 2 * bw;
     627                    assert.areEqual( bw + 'px', element
     628                        .getComputedStyle( 'border-top-width' ),
     629                        'borderTopWidth: medium doesn\'t match' );
     630                    assert.areEqual( h, Math.round( parseFloat( element
     631                            .getComputedStyle( 'height' ) ) ),
     632                            'height: auto (offset minus padding and border) doesn\'t match' );
     633                    nativeElement.style.padding = '1em';
     634                    assert.areEqual( '16px', element.getComputedStyle( 'padding-top' ),
     635                        'padding:1em doesn\'t match' );
     636                    nativeElement.style.margin = 'auto';
     637                    assert.areEqual( '0px', element.getComputedStyle( 'margin-top' ),
     638                        'margin:auto doesn\'t match' );
     639                    assert.areEqual( 493,
     640                        parseInt( element.getComputedStyle( 'width' ) ),
     641                        'percent:width (from CSS) doesn\'t match' );
     642                    assert.areEqual( 'visible',
     643                        element.getComputedStyle( 'visibility' ),
     644                        'visibility doesn\'t match' );
     645                    nativeElement.parentNode.style.visibility = 'hidden';
     646                    assert.areEqual( 'hidden',
     647                        element.getComputedStyle( 'visibility' ),
     648                        'visibility doesn\'t match' );
     649                    nativeElement.parentNode.style.visibility = 'visible';
     650                    assert.areEqual( 2, element.getComputedStyle( 'z-index' ),
     651                        'element.getComputedStyle("zIndex") doesn\'t match' );
     652            },
     653            test_getComputedStyle2 : function()
     654            {
     655                    var element = new CKEDITOR.dom.element( 'span' );
     656                    element.setOpacity( 0.75 );
     657                    assert.areSame( 0.75, element.getComputedStyle( 'opacity' ),
     658                        'opacity style doesn\'t match' );
     659                    element.remove();
     660            },
     661               
     662                test_moveChildren1 : function()
     663                {
     664                        var source = CKEDITOR.document.getById('childrenParent1'),
     665                                target = CKEDITOR.document.getById('childrenTarget1'),
     666                                firstChild = CKEDITOR.document.getById('firstChild1');
     667                               
     668                        source.moveChildren(target);
     669                        assert.areSame(firstChild.$, target.$.childNodes[1]);
     670                },
     671               
     672                test_moveChildren2 : function()
     673                {
     674                        var source = CKEDITOR.document.getById('childrenParent2'),
     675                                target = CKEDITOR.document.getById('childrenTarget2'),
     676                                secondChild = CKEDITOR.document.getById('firstChild2');
     677                               
     678                        source.moveChildren(target, true);
     679                        assert.areSame(secondChild.$, target.$.childNodes[0]);
     680                },
     681 
     682
     683               
     684                test_Markers : function()
     685                {
     686                        var element1 = new CKEDITOR.dom.element( 'span' ),
     687                        element2 = new CKEDITOR.dom.element( 'span' ),
     688                        db = {};
     689                        var markerName = 'fck_test_touched';
     690                       
     691                        CKEDITOR.dom.element.setMarker(db, element1, markerName, true);
     692                        assert.areSame(true, element1.getCustomData(markerName), 'Set marker of value: '+true+' failed.');
     693                        CKEDITOR.dom.element.setMarker(db, element2, markerName, 1);
     694                        assert.areSame(1, element2.getCustomData(markerName), 'Set marker of value: '+1+' failed.');
     695                       
     696                        CKEDITOR.dom.element.clearAllMarkers(db);
     697                        assert.isNull(element1.getCustomData(markerName), 'Bounch clear markers failed.');
     698                        assert.isNull(element2.getCustomData(markerName), 'Bounch clear markers failed.');
     699               
     700                },
     701               
     702                test_breakParent1 : function()
     703            {
     704                    CKEDITOR.document.getById( 'breakParentLeaf1' ).breakParent(
     705                        CKEDITOR.document.getById( 'breakParentRoot1' ) );
     706                    assert.areEqual( CKEDITOR.document.getById( 'breakParentResult1' )
     707                        .getHtml(), trimExpando( CKEDITOR.document.getById(
     708                        'breakParentContainer1' ).getHtml() ) );
     709            },
     710 
     711            test_breakParent2 : function()
     712            {
     713                    CKEDITOR.document.getById( 'breakParentLeaf2' ).breakParent(
     714                        CKEDITOR.document.getById( 'breakParentRoot2' ) );
     715                    assert.areEqual( CKEDITOR.document.getById( 'breakParentResult2' )
     716                        .getHtml(), trimExpando( CKEDITOR.document.getById(
     717                        'breakParentContainer2' ).getHtml() ) );
     718            },
    489719
    490720                name : document.title
    491721        };
     
    493723
    494724        //]]>
    495725        </script>
     726        <style type="text/css" media="screen">
     727                #test-computed {
     728                    width:50%;
     729                    margin:auto;
     730                    padding:10px;
     731                    z-index: 2;
     732                }
     733        </style>
    496734</head>
    497735<body>
    498736        <textarea id="test1" rows="10" cols="80"></textarea>
     
    515753B</div>
    516754        <big>Test</big>
    517755        <small title="Testing">Test</small>
     756        <input id="attributed1" checked />
     757        <div style="display:none"><div id="show2"></div></div>
     758        <div style="visibility:hidden"><div id="show3"></div></div>
     759        <div id="childrenParent1"><span id="firstChild1">text</span></div>
     760        <div id="childrenTarget1"><span>text</span></div>
     761        <div id="childrenParent2"><span id="firstChild2">text</span></div>
     762        <div id="childrenTarget2"><span>text</span></div>
     763        <div id="test-computed">test computed style</div>
     764       
     765        <div id="breakParentContainer1"><b id="breakParentRoot1">This <i>is some<span id="breakParentLeaf1"></span> sample</i> test text</b></div>
     766        <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>
     767       
     768        <div id="breakParentContainer2"><b>This <i id="breakParentRoot2">is some<span id="breakParentLeaf2"></span> sample</i> test text</b></div>
     769        <pre id="breakParentResult2"><b>This <i id="breakParentRoot2">is some</i><span id="breakParentLeaf2"></span><i id="breakParentRoot2"> sample</i> test text</b></pre>
     770       
    518771</body>
    519772</html>
  • _source/tests/core/dom/window.html

     
    4141                {
    4242                        assert.isTrue( loadCalled );
    4343                },
     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            },
    4468
     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               
    45108                name : document.title
    46109        };
    47110})() );
     
    50113        </script>
    51114</head>
    52115<body>
    53         <div id="test1"></div>
     116        <iframe id="innerFrame1" src='windowtestpopup1.html'></iframe>
    54117</body>
    55118</html>
  • _source/tests/core/dom/document.html

     
    8989                        assert.areSame( document.body, doc.getBody().$, '1st call failed' );
    9090                        assert.areSame( document.body, doc.getBody().$, '2nd call failed' );
    9191                },
     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.' );
    9298
     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            },
    93121                name : document.title
    94122        };
    95123})() );
     
    99127</head>
    100128<body>
    101129        <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>
    102132</body>
    103133</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
     13CKEDITOR.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
     13CKEDITOR.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[
     12CKEDITOR.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

     
    4646                        assert.areSame( 'Good'          , target.prop6, 'prop6 doesn\'t match' );
    4747                        assert.areSame( fakeArray       , target.prop7, 'prop7 doesn\'t match' );
    4848                },
    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               
    5078                test_isArray1 : function()
    5179                {
    5280                        assert.isTrue( CKEDITOR.tools.isArray( [] ) );
     
    6694                {
    6795                        assert.isFalse( CKEDITOR.tools.isArray( window.x ) );
    6896                },
    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                },
    70105                test_htmlEncode1 : function()
    71106                {
    72107                        assert.areSame( '&lt;b&gt;Test&lt;/b&gt;', 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[
     10var testCase;
     11
     12CKEDITOR.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
  • _source/tests/plugins/htmlwriter/htmlwriter.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: htmlwriter</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
     10CKEDITOR.plugins.load( 'htmldataprocessor' );
     11
     12        </script>
     13        <script type="text/javascript">
     14        //<![CDATA[
     15
     16CKEDITOR.test.addTestCase( (function()
     17{
     18        // Local references.
     19        var assert = CKEDITOR.test.assert;
     20
     21
     22        return {
     23                /**
     24                 * Test content indentation on  block-level elements after tag open.
     25                 */
     26                test_toDataFormat1 : function()
     27                {
     28                        var element = new CKEDITOR.dom.element.createFromHtml( '<div><p>text</p></div>' );
     29
     30                        assert.areSame( '<p>\n\ttext</p>\n', new CKEDITOR.htmlDataProcessor().toDataFormat( element ),
     31                        'No identation after tag open.' );
     32                },
     33               
     34                /**
     35                 * Test no empty content indentation
     36                 */
     37                test_toDataFormat2 : function()
     38                {
     39                        var element = new CKEDITOR.dom.element.createFromHtml( '<div><p></p></div>' );
     40
     41                        assert.areSame( '<p>\n</p>\n', new CKEDITOR.htmlDataProcessor().toDataFormat( element ),
     42                        'Incorrect identation after tag open when content is empty.' );
     43                },
     44               
     45                /**
     46                 * Test no indentation after tag open for inline elements
     47                 */
     48                test_toDataFormat3 : function()
     49                {
     50                        var element = new CKEDITOR.dom.element.createFromHtml( '<div><b><a>text</a></b>text</div>' );
     51                        assert.areSame( '<b><a>text</a></b>text', new CKEDITOR.htmlDataProcessor().toDataFormat( element ) ,
     52                        'Incorrect identation after tag open when element are inline elements.');
     53                },
     54               
     55                /**
     56                 * Test no content indentation before tag close on inline elements.
     57                 */
     58                test_toDataFormat4 : function()
     59                {
     60                        var element = new CKEDITOR.dom.element.createFromHtml( '<div><p><a>text</a></p></div>' );
     61                        assert.areSame( '<p>\n\t<a>text</a></p>\n', new CKEDITOR.htmlDataProcessor().toDataFormat( element ) ,
     62                        'Incorrect identation before tag close when contents are inline elements.');
     63                },
     64               
     65                /**
     66                 * Test table and table cells format.
     67                 */
     68                test_toDataFormat4 : function()
     69                {
     70                        var element = new CKEDITOR.dom.element.createFromHtml( '<div><table><tr><td></td></tr></table></div>' );
     71                        assert.areSame( CKEDITOR.document.getById('tableFormatResult').getText(), new CKEDITOR.htmlDataProcessor().toDataFormat( element ) ,
     72                        'Incorrect identation on table elements.');
     73                },
     74               
     75                name : document.title
     76        };
     77})() );
     78
     79        //]]>
     80        </script>
     81</head>
     82<body>
     83<textarea id="tableFormatResult"><table>
     84        <tbody>
     85                <tr>
     86                        <td>
     87                        </td>
     88                </tr>
     89        </tbody>
     90</table>
     91</textarea>
     92</body>
     93</html>
     94 No newline at end of file
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy