tor-browser

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

Document-createElementNS.html (2011B)


      1 <!DOCTYPE html>
      2 <title>Custom Elements: document.createElementNS should support custom elements</title>
      3 <link rel="help" content="https://dom.spec.whatwg.org/#concept-create-element">
      4 <link rel="help" content="https://dom.spec.whatwg.org/#internal-createelementns-steps">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <body>
      8 <script>
      9 test(() => {
     10  class MyElement extends HTMLElement {};
     11 
     12  customElements.define('my-autonomous', MyElement);
     13  let element = document.createElementNS('http://www.w3.org/1999/xhtml', 'p:my-autonomous');
     14  assert_true(element instanceof MyElement);
     15  assert_equals(element.prefix, 'p');
     16 }, 'autonomous: document.createElementNS should create custom elements with prefixes.');
     17 
     18 test(() => {
     19  class MyElement2 extends HTMLElement {};
     20 
     21  customElements.define('my-autonomous2', MyElement2);
     22  let element = document.createElementNS('urn:example', 'my-autonomous2');
     23  assert_false(element instanceof MyElement2);
     24 }, 'autonomous: document.createElementNS should check namespaces.');
     25 
     26 test(() => {
     27  const xhtmlNS = 'http://www.w3.org/1999/xhtml';
     28  assert_false(document.createElementNS(xhtmlNS, 'x-foo') instanceof HTMLUnknownElement);
     29  assert_false(document.createElementNS(xhtmlNS, 'x-foo', {}) instanceof HTMLUnknownElement);
     30  assert_false((new Document()).createElementNS(xhtmlNS, 'x-foo') instanceof HTMLUnknownElement);
     31  assert_false((new Document()).createElementNS(xhtmlNS, 'x-foo', {}) instanceof HTMLUnknownElement);
     32 }, 'autonomous: document.createElementNS should not create HTMLUnknownElement for a valid custom element name');
     33 
     34 test(() => {
     35  class MyElement3 extends HTMLElement {};
     36  customElements.define('my-autonomous3', MyElement3);
     37 
     38  const instance = document.createElementNS('http://www.w3.org/1999/xhtml', 'my-autonomous3', undefined);
     39  assert_true(instance instanceof MyElement3);
     40 }, 'autonomous: document.createElementNS with undefined options value should be upgraded.');
     41 
     42 </script>
     43 </body>