tor-browser

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

append-on-Document.html (2021B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>DocumentType.append</title>
      4 <link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-append">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8 
      9 function test_append_on_Document() {
     10 
     11    var node = document.implementation.createDocument(null, null);
     12    test(function() {
     13        var parent = node.cloneNode();
     14        parent.append();
     15        assert_array_equals(parent.childNodes, []);
     16    }, 'Document.append() without any argument, on a Document having no child.');
     17 
     18    test(function() {
     19        var parent = node.cloneNode();
     20        var x = document.createElement('x');
     21        parent.append(x);
     22        assert_array_equals(parent.childNodes, [x]);
     23    }, 'Document.append() with only one element as an argument, on a Document having no child.');
     24 
     25    test(function() {
     26        var parent = node.cloneNode();
     27        var x = document.createElement('x');
     28        var y = document.createElement('y');
     29        parent.appendChild(x);
     30        assert_throws_dom('HierarchyRequestError', function() { parent.append(y); });
     31        assert_array_equals(parent.childNodes, [x]);
     32    }, 'Document.append() with only one element as an argument, on a Document having one child.');
     33 
     34    test(function() {
     35        var parent = node.cloneNode();
     36        assert_throws_dom('HierarchyRequestError', function() { parent.append('text'); });
     37        assert_array_equals(parent.childNodes, []);
     38    }, 'Document.append() with text as an argument, on a Document having no child.');
     39 
     40    test(function() {
     41        var parent = node.cloneNode();
     42        var x = document.createElement('x');
     43        var y = document.createElement('y');
     44        assert_throws_dom('HierarchyRequestError', function() { parent.append(x, y); });
     45        assert_array_equals(parent.childNodes, []);
     46    }, 'Document.append() with two elements as the argument, on a Document having no child.');
     47 
     48 }
     49 
     50 test_append_on_Document();
     51 
     52 </script>
     53 </html>