Ticket #2935: 2935.patch

File 2935.patch, 17.7 KB (added by Garry Yao, 15 years ago)
  • _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
     13CKEDITOR.test.addTestCase( (function()
     14{
     15        // Local reference to the "assert" object.
     16        var assert = CKEDITOR.test.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/element.html

     
    4646                        var element = new CKEDITOR.dom.element( document.getElementById( 'test1' ) );
    4747                        assert.isNull( element.getNameAtt() );
    4848                },
     49                /**
     50                 *  Test dynamic created all elements which support 'name' attribute.
     51                 */
     52                test_getNameAtt2 : function()
     53                {
     54                        var supportNameTags = [ 'a', 'applet', 'button', 'embed', 'form',
     55                            'frame', 'iframe', 'input', 'meta', 'object', 'param', 'select' ], element;
     56       
     57                        var i, l = supportNameTags.length;
     58                        for ( i = 0 ; i < l ; i++ )
     59                        {
     60                                element = new CKEDITOR.dom.element( supportNameTags[ i ] );
     61                                element.setAttribute( 'name', 'test' );
     62                                assert.areEqual( 'test', element.getNameAtt(),
     63                                    'name attribute doesn\'t match on ' + supportNameTags[ i ] );
     64                        }
     65                },
    4966
    5067                test_getName : function()
    5168                {
     
    7592
    7693                        assert.areEqual( '', nativeElement.style.display );
    7794                },
     95                /**
     96                 * Test display inheritance
     97                 */
     98                test_show2 : function()
     99                {
     100                        var element = CKEDITOR.document.getById( 'show2' );
     101                        element.show();
     102                        assert.areEqual( 'block', element.getComputedStyle( 'display' ),
     103                            '"display" doesn\'t match' );
     104                },
     105               
     106                /**
     107                 * Test visibility inheritance
     108                 */
     109                test_show3 : function()
     110                {
     111                        var element = CKEDITOR.document.getById( 'show2' );
     112                        element.show();
     113                        assert.areEqual( 'visible', element.getComputedStyle( 'visibility' ),
     114                            '"visibility" doesn\'t match' );
     115                },
    78116
    79117                test_createFromHtml : function()
    80118                {
     
    233271                        assert.areEqual( 'absolute', document.getElementById( 'setStyle' ).style.position );
    234272                        assert.areEqual( 'right', document.getElementById( 'setStyle' ).style.cssFloat );
    235273                },
     274                /**
     275                 * Test boundary opacity style values.
     276                 */
     277                test_setOpacity : function()
     278                {
     279                        var opacityValues = [ 1, 0.5, 0 ];
     280       
     281                        var i, l = opacityValues.length;
     282                        for ( i = 0 ; i < l ; i++ )
     283                        {
     284                                var element = new CKEDITOR.dom.element( 'span' );
     285                                element.setOpacity( opacityValues[ i ] );
     286                                assert.areEqual( opacityValues[ i ], element
     287                                    .getComputedStyle( 'opacity' ), "Opacity style value of "
     288                                    + opacityValues[ i ] + " doesn\'t match." );
     289                        }
     290                },
    236291
    237292                test_setText1 : function()
    238293                {
     
    400455                        var element = new CKEDITOR.dom.element( document.getElementById( 'tabIndexScriptDef' ) );
    401456                        assert.areEqual( null, element.getAttribute( 'tabindex' ) );
    402457                },
     458               
     459                test_getAttribute_Style : function()
     460            {
     461                    var element = new CKEDITOR.dom.element( 'span' );
     462                    if ( CKEDITOR.env.ie )
     463                            element.$.style.cssText = 'float:right';
     464                    else
     465                            element.$.setAttribute( 'style', 'float:right' );
     466
     467                    assert.areSame( 'float: right;', element.getAttribute( 'style' ) );
     468            },
    403469
    404470                test_getTabIndex1 : function()
    405471                {
     
    486552                        var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] );
    487553                        assert.isTrue( element.hasAttributes() );
    488554                },
     555                /**
     556                 * Test dynamic attribute existence
     557                 */
     558            test_hasAttributes3 : function()
     559            {
     560                    var element = new CKEDITOR.dom.element( 'span' );
     561                    element.setAttribute( 'class', 'testclass' );
     562                    element.removeAttribute( 'class' );
     563                    assert.isFalse( element.hasAttributes() );
     564            },
     565
     566            /**
     567                 * Test attribute abbreviation
     568                 */
     569            test_hasAttributes4 : function()
     570            {
     571                    var element = CKEDITOR.document.getById( 'attributed1' );
     572                    assert.isTrue( element.hasAttributes() );
     573            },
     574            /**
     575             * Test 'float' style computed value
     576             */
     577            test_getComputedStyle1 : function()
     578            {
     579                    var element = document.createElement( 'span' );
     580                    if ( CKEDITOR.env.ie )
     581                            element.style.cssText = 'float:right';
     582                    else
     583                            element.setAttribute( 'style', 'float:right' );
     584
     585                    element = new CKEDITOR.dom.element( element );
     586                    assert.areSame( 'right', element.getComputedStyle( 'float' ),
     587                        'float style doesn\'t match' );
     588                    element.remove();
     589            },
     590           
     591            /**
     592             * Test box-model computed styles.
     593             */
     594            test_getComputedStyle2 : function()
     595            {
     596                    var element = CKEDITOR.document.getById( 'test-computed' );
     597                    var nativeElement = element.$;
     598
     599                    nativeElement.style.zoom = 1;
     600                    nativeElement.style.border = 'medium solid #000';
     601
     602                    var bw = CKEDITOR.env.ie ? 4 : 3;
     603                    var h = nativeElement.offsetHeight - 20 - 2 * bw;
     604                    assert.areEqual( bw + 'px', element
     605                        .getComputedStyle( 'border-top-width' ),
     606                        'borderTopWidth: medium doesn\'t match' );
     607                    assert.areEqual( h, Math.round( parseFloat( element
     608                            .getComputedStyle( 'height' ) ) ),
     609                            'height: auto (offset minus padding and border) doesn\'t match' );
     610                    nativeElement.style.padding = '1em';
     611                    assert.areEqual( '16px', element.getComputedStyle( 'padding-top' ),
     612                        'padding:1em doesn\'t match' );
     613                    nativeElement.style.margin = 'auto';
     614                    assert.areEqual( '0px', element.getComputedStyle( 'margin-top' ),
     615                        'margin:auto doesn\'t match' );
     616                    assert.areEqual( 493,
     617                        parseInt( element.getComputedStyle( 'width' ) ),
     618                        'percent:width (from CSS) doesn\'t match' );
     619                    assert.areEqual( 'visible',
     620                        element.getComputedStyle( 'visibility' ),
     621                        'visibility doesn\'t match' );
     622                    nativeElement.parentNode.style.visibility = 'hidden';
     623                    assert.areEqual( 'hidden',
     624                        element.getComputedStyle( 'visibility' ),
     625                        'visibility doesn\'t match' );
     626                    nativeElement.parentNode.style.visibility = 'visible';
     627                    assert.areEqual( 2, element.getComputedStyle( 'z-index' ),
     628                        'element.getComputedStyle("zIndex") doesn\'t match' );
     629            },
     630            test_getComputedStyle2 : function()
     631            {
     632                    var element = new CKEDITOR.dom.element( 'span' );
     633                    element.setOpacity( 0.75 );
     634                    assert.areSame( 0.75, element.getComputedStyle( 'opacity' ),
     635                        'opacity style doesn\'t match' );
     636                    element.remove();
     637            },
     638               
     639                test_moveChildren1 : function()
     640                {
     641                        var source = CKEDITOR.document.getById('childrenParent1'),
     642                                target = CKEDITOR.document.getById('childrenTarget1'),
     643                                firstChild = CKEDITOR.document.getById('firstChild1');
     644                               
     645                        source.moveChildren(target);
     646                        assert.areSame(firstChild.$, target.$.childNodes[1]);
     647                },
     648               
     649                test_moveChildren2 : function()
     650                {
     651                        var source = CKEDITOR.document.getById('childrenParent2'),
     652                                target = CKEDITOR.document.getById('childrenTarget2'),
     653                                secondChild = CKEDITOR.document.getById('firstChild2');
     654                               
     655                        source.moveChildren(target, true);
     656                        assert.areSame(secondChild.$, target.$.childNodes[0]);
     657                },
     658 
     659
     660               
     661                test_Markers : function()
     662                {
     663                        var element1 = new CKEDITOR.dom.element( 'span' ),
     664                        element2 = new CKEDITOR.dom.element( 'span' ),
     665                        db = {};
     666                        var markerName = 'fck_test_touched';
     667                       
     668                        CKEDITOR.dom.element.setMarker(db, element1, markerName, true);
     669                        assert.areSame(true, element1.getCustomData(markerName), 'Set marker of value: '+true+' failed.');
     670                        CKEDITOR.dom.element.setMarker(db, element2, markerName, 1);
     671                        assert.areSame(1, element2.getCustomData(markerName), 'Set marker of value: '+1+' failed.');
     672                       
     673                        CKEDITOR.dom.element.clearAllMarkers(db);
     674                        assert.isNull(element1.getCustomData(markerName), 'Bounch clear markers failed.');
     675                        assert.isNull(element2.getCustomData(markerName), 'Bounch clear markers failed.');
     676               
     677                },
    489678
    490679                name : document.title
    491680        };
     
    493682
    494683        //]]>
    495684        </script>
     685        <style type="text/css" media="screen">
     686                #test-computed {
     687                    width:50%;
     688                    margin:auto;
     689                    padding:10px;
     690                    z-index: 2;
     691                }
     692        </style>
    496693</head>
    497694<body>
    498695        <textarea id="test1" rows="10" cols="80"></textarea>
     
    515712B</div>
    516713        <big>Test</big>
    517714        <small title="Testing">Test</small>
     715        <input id="attributed1" checked />
     716        <div style="display:none"><div id="show2"></div></div>
     717        <div style="visibility:hidden"><div id="show3"></div></div>
     718        <div id="childrenParent1"><span id="firstChild1">text</span></div>
     719        <div id="childrenTarget1"><span>text</span></div>
     720        <div id="childrenParent2"><span id="firstChild2">text</span></div>
     721        <div id="childrenTarget2"><span>text</span></div>
     722        <div id="test-computed">test computed style</div>
    518723</body>
    519724</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/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 = CKEDITOR.test.assert;
     17        var action = YAHOO.util.UserAction;
     18
     19        return {
     20               
     21                /**
     22                 * Test dom native listener invoked correct times.
     23                 */
     24                test_AddEventListener1 : function()
     25            {
     26                    var element = CKEDITOR.document.getById( 'nativeEvent' ), callbackCount = 0;
     27                    element.on( 'click', function()
     28                    {
     29                            callbackCount++;
     30                    } );
     31                    element.on( 'click', function()
     32                    {
     33                            callbackCount++;
     34                    } );
     35                    action.click( element.$ );
     36                    // waits and then run assertion
     37                    this.wait( function()
     38                    {
     39                            assert.areEqual( 2, callbackCount,
     40                                'Event handler should be invoked ' + 2 + ' times.' );
     41                    }, 500 );
     42            },
     43           
     44            /**
     45             *  Test prevent and stop dom native event.
     46             */
     47            test_AddEventListener2 : function()
     48            {
     49                    var element = CKEDITOR.document.getById( 'nativeEvent' ), innerElement = CKEDITOR.document
     50                        .getById( 'nativeEventInner' ), preventFailed = false, stopFailed = false;
     51                    // Test stop propagation
     52                    element.on( 'click', function()
     53                    {
     54                            stopFailed = true;
     55                    } );
     56                    innerElement.on( 'click', function( evt )
     57                    {
     58                            evt.data.preventDefault( true );
     59                    } );
     60                    // Test prevent others
     61                    innerElement.on( 'click', function()
     62                    {
     63                            preventFailed = true;
     64                    } );
     65
     66                    action.click( innerElement.$ );
     67                    // waits and then run assertion
     68                    this.wait( function()
     69                    {
     70                            assert.isFalse( preventFailed, 'Prevent event failed.' );
     71                            assert.isFalse( stopFailed, 'Stop event failed.' );
     72                    }, 500 );
     73            },
     74                name : document.title
     75        };
     76})() );
     77
     78        //]]>
     79        </script>
     80</head>
     81<body>
     82        <div id='nativeEvent'><span id='nativeEventInner'></span></div>
     83</body>
     84</html>
     85 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>' ) );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy