tor-browser

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

Document-createAttribute.html (1914B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Document.createAttribute</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script src=attributes.js></script>
      7 <script src=productions.js></script>
      8 <div id=log>
      9 <script>
     10 var xml_document;
     11 setup(function() {
     12  xml_document = document.implementation.createDocument(null, null, null);
     13 });
     14 
     15 invalid_names.forEach(function(name) {
     16  test(function() {
     17    assert_throws_dom("INVALID_CHARACTER_ERR", function() {
     18      document.createAttribute(name, "test");
     19    });
     20  }, "HTML document.createAttribute(" + format_value(name) + ") should throw");
     21 
     22  test(function() {
     23    assert_throws_dom("INVALID_CHARACTER_ERR", function() {
     24      xml_document.createAttribute(name, "test");
     25    });
     26  }, "XML document.createAttribute(" + format_value(name) + ") should throw");
     27 });
     28 
     29 valid_names.forEach(name => {
     30  test(() => {
     31    let attr = document.createAttribute(name);
     32    attr_is(attr, "", name.toLowerCase(), null, null, name.toLowerCase());
     33  }, `HTML document.createAttribute(${format_value(name)})`);
     34 
     35  test(() => {
     36    let attr = xml_document.createAttribute(name);
     37    attr_is(attr, "", name, null, null, name);
     38  }, `XML document.createAttribute(${format_value(name)})`);
     39 });
     40 
     41 var tests = ["title", "TITLE", null, undefined];
     42 tests.forEach(function(name) {
     43  test(function() {
     44    var attribute = document.createAttribute(name);
     45    attr_is(attribute, "", String(name).toLowerCase(), null, null, String(name).toLowerCase());
     46    assert_equals(attribute.ownerElement, null);
     47  }, "HTML document.createAttribute(" + format_value(name) + ")");
     48 
     49  test(function() {
     50    var attribute = xml_document.createAttribute(name);
     51    attr_is(attribute, "", String(name), null, null, String(name));
     52    assert_equals(attribute.ownerElement, null);
     53  }, "XML document.createAttribute(" + format_value(name) + ")");
     54 });
     55 </script>