Ticket #3283: test-getPreviousSourceNode-getNextSourceNode.patch

File test-getPreviousSourceNode-getNextSourceNode.patch, 5.5 KB (added by Garry Yao, 15 years ago)
  • _source/tests/core/dom/node_getPreviousSourceNode.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.node</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        doc = CKEDITOR.document;
     18
     19        return {
     20               
     21                /**
     22                 *  Test parent node as previous source node.
     23                 */
     24                test_getPreviousSourceNode : function()
     25                {
     26                        var current = doc.getById( 'br1' ),
     27                                previous = doc.getById('p1');
     28
     29                        assert.isTrue( previous.equals( current.getPreviousSourceNode() ) );
     30                },
     31
     32                /**
     33                 *  Test previous sibling as previous source node.
     34                 */
     35                test_getPreviousSourceNode2 : function()
     36                {
     37                        var current = doc.getById( 'br1' ).getNext(),
     38                                previous = doc.getById('br1');
     39
     40                        assert.isTrue( previous.equals( current.getPreviousSourceNode() ) );
     41                },
     42
     43                /**
     44                 *  Test previous sibling as previous source node with 'startFromSibling = true ' .
     45                 */
     46                test_getPreviousSourceNode_startFromSibling : function()
     47                {
     48                        var current = doc.getById( 'br1' ).getNext(),
     49                                previous = doc.getById('br1');
     50
     51                        assert.isTrue( previous.equals( current.getPreviousSourceNode( true ) ) );
     52                },
     53
     54                /**
     55                 *  Test parent's previous sibling as previous source node with 'startFromSibling = true ' .
     56                 */
     57                test_getPreviousSourceNode_startFromSibling2 : function()
     58                {
     59                        var current = doc.getById( 'br1' ),
     60                                previous = doc.getById('span1').getFirst();
     61
     62                        assert.isTrue( previous.equals( current.getPreviousSourceNode( true ) ) );
     63                },
     64
     65                /**
     66                 *  Test corresponding previous source node with 'nodeType' specified.
     67                 */
     68                test_getPreviousSourceNode_startFromSibling3 : function()
     69                {
     70                        var current = doc.getById( 'br1' ),
     71                                previous = doc.getById('span1').getFirst();
     72
     73                        assert.isTrue( previous.equals( current.getPreviousSourceNode( true, CKEDITOR.NODE_TEXT ) ) );
     74                },
     75
     76                name : document.title
     77        };
     78})() );
     79
     80        //]]>
     81        </script>
     82</head>
     83<body><span id="span1">1</span><p id="p1"><br id="br1" />3</p>
     84</body>
     85</html>
  • _source/tests/core/dom/node_getNextSourceNode.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.node</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        doc = CKEDITOR.document;
     18
     19        return {
     20               
     21                /**
     22                 *  Test first child node as next source node.
     23                 */
     24                test_getNextSourceNode : function()
     25                {
     26                        var current = doc.getById( 'p1' ),
     27                                next = doc.getById('br1');
     28
     29                        assert.isTrue( next.equals( current.getNextSourceNode() ) );
     30                },
     31
     32                /**
     33                 *  Test next sibling as next source node.
     34                 */
     35                test_getNextSourceNode2 : function()
     36                {
     37                        var current = doc.getById( 'br1' ),
     38                                next = doc.getById('span1');
     39
     40                        assert.isTrue( next.equals( current.getNextSourceNode() ) );
     41                },
     42
     43                /**
     44                 *  Test next sibling as next source node with 'startFromSibling = true ' .
     45                 */
     46                test_getNextSourceNode_startFromSibling : function()
     47                {
     48                        var current = doc.getById( 'br1' ),
     49                                next = doc.getById('span1');
     50
     51                        assert.isTrue( next.equals( current.getNextSourceNode( true ) ) );
     52                },
     53
     54                /**
     55                 *  Test child's next sibling as next source node with 'startFromSibling = true ' .
     56                 */
     57                test_getNextSourceNode_startFromSibling2 : function()
     58                {
     59                        var current = doc.getById( 'p1' ),
     60                                next = doc.getById('span1');
     61
     62                        assert.isTrue( next.equals( current.getNextSourceNode( true ) ) );
     63                },
     64
     65                /**
     66                 *  Test corresponding next source node with 'nodeType' specified.
     67                 */
     68                test_getNextSourceNode_startFromSibling3 : function()
     69                {
     70                        var current = doc.getById( 'span1' ),
     71                                next = doc.getById('span2');
     72
     73                        assert.isTrue( next.equals( current.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT ) ) );
     74                },
     75
     76                name : document.title
     77        };
     78})() );
     79
     80        //]]>
     81        </script>
     82</head>
     83<body><div><p id="p1"><br id="br1" /><span id="span1">1</span></p><span id="span2">text</span></div></body>
     84</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy