tor-browser

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

CustomElementRegistry-multi-register.html (1229B)


      1 <!DOCTYPE html>
      2 <meta name="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
      3 <meta name="assert" content="The same constructor can be registered to multiple registries">
      4 <link rel="help" href="https://wicg.github.io/webcomponents/proposals/Scoped-Custom-Element-Registries">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8 class MyCustom extends HTMLElement {};
      9 
     10 test(() => {
     11  let registry1 = new CustomElementRegistry();
     12  let registry2 = new CustomElementRegistry();
     13  window.customElements.define('my-custom', MyCustom);
     14  registry1.define('my-custom', MyCustom);
     15  registry2.define('my-custom', MyCustom);
     16 
     17  assert_equals(window.customElements.get('my-custom'), MyCustom);
     18  assert_equals(registry1.get('my-custom'), MyCustom);
     19  assert_equals(registry2.get('my-custom'), MyCustom);
     20 }, 'Same constructor can be registered to different registries');
     21 
     22 test(() => {
     23  let registry = new CustomElementRegistry();
     24  registry.define('custom-a', MyCustom);
     25  assert_throws_dom('NotSupportedError', () => registry.define('custom-b', MyCustom));
     26 }, 'Non-global registries still reject duplicate registrations of the same constructor');
     27 </script>