tor-browser

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

test_custom_element_get.html (1066B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1275838
      5 -->
      6 <head>
      7  <title>Test custom elements get function.</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 </head>
     11 <body>
     12 <iframe id="iframe"></iframe>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1275838">Bug 1275838</a>
     14 <script>
     15 const testWindow = iframe.contentDocument.defaultView;
     16 const customElements = testWindow.customElements;
     17 
     18 ok('customElements' in testWindow, '"window.customElements" exists');
     19 ok('define' in customElements, '"window.customElements.define" exists');
     20 ok('get' in customElements, '"window.customElements.get" exists');
     21 
     22 const name = 'test-get-existing';
     23 class C extends HTMLElement {};
     24 customElements.define(name, C);
     25 is(customElements.get(name), C, 'get() returns the constructor');
     26 is(customElements.get('test-get-not-defined'), undefined,
     27                      'get() returns undefined for not-defined name');
     28 
     29 </script>
     30 </body>
     31 </html>