Ticket #3240: test_node_getPosition.patch

File test_node_getPosition.patch, 2.0 KB (added by Garry Yao, 15 years ago)

Unit Test Case

  • _source/tests/core/dom/node_getPosition.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<!--[if gte IE 6]>
     10        <script language="javascript" type="text/javascript"
     11                src="../../../../_dev/firebuglite/firebuglite.js"></script>
     12<![endif]-->
     13       
     14        <script type="text/javascript" src="../../test.js"></script>
     15        <script type="text/javascript">
     16        //<![CDATA[
     17CKEDITOR.plugins.load( 'htmldataprocessor' );
     18
     19CKEDITOR.test.addTestCase( (function()
     20{
     21        // Local reference to the "assert" object.
     22        var assert = CKEDITOR.test.assert,
     23        doc = CKEDITOR.document;
     24
     25        // In these tests, we may "reset" the writer rules to avoid it formatting
     26        // the output, making the assertion easier to the done. We don't need to
     27        // test formatting features here, so this is ok.
     28        var getDataProcessor = function()
     29        {
     30                var dataProcessor = new CKEDITOR.htmlDataProcessor();
     31                dataProcessor.writer._.rules = [];
     32                return dataProcessor;
     33        };
     34
     35        return {
     36               
     37                /**
     38                 *  Test preceding position.
     39                 */
     40                test_getPosition_preceding: function()
     41                {
     42                        var source = doc.getById( 'sourcePosition' ),
     43                                target = doc.getBody().getChildren().getItem(1);
     44                                assert.areSame(CKEDITOR.POSITION_PRECEDING,
     45                                        source.getPosition( target ) );
     46                },
     47
     48                name : document.title
     49        };
     50})() );
     51
     52        //]]>
     53        </script>
     54</head>
     55<body><p><span id="sourcePosition">A</span></p>B</body>
     56</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy