Ticket #3034: test-element-getDocumentPosition.patch

File test-element-getDocumentPosition.patch, 1.9 KB (added by Garry Yao, 15 years ago)

Unit test case

  • _source/tests/core/dom/element.html

     
    486486                        var element = new CKEDITOR.dom.element( document.getElementsByTagName( 'small' )[0] );
    487487                        assert.isTrue( element.hasAttributes() );
    488488                },
    489 
     489               
     490                test_getDocumentPosition : function()
     491                {
     492                        // Assign the page location of the element.
     493                        YAHOO.util.Dom.setXY('DocPositionTarget', [ 350, 450 ] );
     494                        var pos = CKEDITOR.document.getById( 'DocPositionTarget' ).getDocumentPosition();
     495                        assert.areEqual( 350, pos.x, 'Position coordinates:x relative to document doesn\'t match.' );
     496                        assert.areEqual( 450, pos.y, 'Position coordinates:y relative to document doesn\'t match.' );
     497                },
     498               
    490499                name : document.title
    491500        };
    492501})() );
     
    493502
    494503        //]]>
    495504        </script>
     505        <style type="text/css" media="screen">
     506                #test-computed {
     507                    width:50%;
     508                    margin:auto;
     509                    padding:10px;
     510                    z-index: 2;
     511                }
     512                .scroll
     513                {
     514                        overflow:auto;
     515                }
     516                .block1
     517                {
     518                        width: 100%;
     519                        height: 100px;
     520                        text-align: center;
     521                }
     522                .block2
     523                {
     524                        margin: auto;
     525                        width: 200px;
     526                        height: 200px;
     527                        position : relative;
     528                }
     529                .block3
     530                {
     531                        position: absolute;
     532                        float:right;
     533                        width: 300px;
     534                        height: 300px;
     535                }
     536                .block4
     537                {
     538                        position: absolute;
     539                        left: 50px;
     540                        right: 50px;
     541                        width: 400px;
     542                        height: 400px;
     543                }
     544        </style>
    496545</head>
    497546<body>
    498547        <textarea id="test1" rows="10" cols="80"></textarea>
     
    515564B</div>
    516565        <big>Test</big>
    517566        <small title="Testing">Test</small>
     567       
     568        <div class="block1 scroll"><div class="block2 scroll"><div class="block3 scroll"><div class="block4 scroll"><div id="DocPositionTarget">target</div></div></div></div>
     569       
    518570</body>
    519571</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy