tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CharacterData-data.html (2136B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>CharacterData.data</title>
      4 <link rel=help href="https://dom.spec.whatwg.org/#dom-characterdata-data">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <div id="log"></div>
      8 <script>
      9 function testNode(create, type) {
     10  test(function() {
     11    var node = create()
     12    assert_equals(node.data, "test")
     13    assert_equals(node.length, 4)
     14  }, type + ".data initial value")
     15 
     16  test(function() {
     17    var node = create()
     18    assert_equals(node.data, "test")
     19 
     20    node.data = null;
     21    assert_equals(node.data, "")
     22    assert_equals(node.length, 0)
     23  }, type + ".data = null")
     24 
     25  test(function() {
     26    var node = create()
     27    assert_equals(node.data, "test")
     28 
     29    node.data = undefined;
     30    assert_equals(node.data, "undefined")
     31    assert_equals(node.length, 9)
     32  }, type + ".data = undefined")
     33 
     34  test(function() {
     35    var node = create()
     36    assert_equals(node.data, "test")
     37 
     38    node.data = 0;
     39    assert_equals(node.data, "0")
     40    assert_equals(node.length, 1)
     41  }, type + ".data = 0")
     42 
     43  test(function() {
     44    var node = create()
     45    assert_equals(node.data, "test")
     46 
     47    node.data = "";
     48    assert_equals(node.data, "")
     49    assert_equals(node.length, 0)
     50  }, type + ".data = ''")
     51 
     52  test(function() {
     53    var node = create()
     54    assert_equals(node.data, "test")
     55 
     56    node.data = "--";
     57    assert_equals(node.data, "--")
     58    assert_equals(node.length, 2)
     59  }, type + ".data = '--'")
     60 
     61  test(function() {
     62    var node = create()
     63    assert_equals(node.data, "test")
     64 
     65    node.data = "資料";
     66    assert_equals(node.data, "資料")
     67    assert_equals(node.length, 2)
     68  }, type + ".data = '資料'")
     69 
     70  test(function() {
     71    var node = create()
     72    assert_equals(node.data, "test")
     73 
     74    node.data = "🌠 test 🌠 TEST";
     75    assert_equals(node.data, "🌠 test 🌠 TEST")
     76    assert_equals(node.length, 15)  // Counting UTF-16 code units
     77  }, type + ".data = '🌠 test 🌠 TEST'")
     78 }
     79 
     80 testNode(function() { return document.createTextNode("test") }, "Text")
     81 testNode(function() { return document.createComment("test") }, "Comment")
     82 </script>