OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <!-- | |
3 TODO(yosin): We should upstream to wpt test. | |
4 This file is taken from https://github.com/kojiishi/web-platform-tests/blob/5390 8d773012edf931047674f7afe3975bc1820f/custom-elements/custom-elements-registry/ge t.html | |
5 --> | |
6 <title>Custom Elements: CustomElementsRegistry.get</title> | |
7 <script src="../../../resources/testharness.js"></script> | |
8 <script src="../../../resources/testharnessreport.js"></script> | |
9 <body> | |
10 <div id="log"></div> | |
11 <iframe id="iframe"></iframe> | |
dominicc (has gone to gerrit)
2016/05/25 01:31:23
I think it is better to dynamically create these;
yosin_UTC9
2016/05/30 06:17:55
Done
| |
12 <script> | |
13 'use strict'; | |
14 (() => { | |
15 // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsreg istry-whendefined | |
16 // Use window from iframe to isolate the test. | |
17 const testWindow = iframe.contentDocument.defaultView; | |
dominicc (has gone to gerrit)
2016/05/25 01:31:23
iframe.contentWindow
yosin_UTC9
2016/05/30 06:17:55
Done
| |
18 const customElements = testWindow.customElements; | |
19 let testable = false; | |
dominicc (has gone to gerrit)
2016/05/25 01:31:23
I wonder what it would look like if testable was a
yosin_UTC9
2016/05/30 06:17:55
Done
| |
20 test(() => { | |
21 assert_true('customElements' in testWindow, '"window.customElements" exists' ); | |
22 assert_true('get' in customElements, '"window.customElements.get" exists'); | |
23 testable = true; | |
24 }, '"window.customElements.get" should exist'); | |
25 if (!testable) | |
26 return; | |
27 // 1. If this CustomElementsRegistry contains an entry with name name, | |
28 // then return that entry's constructor. | |
29 test(() => { | |
30 const name = 'test-get-existing'; | |
31 class C extends HTMLElement {}; | |
32 customElements.define(name, C); | |
33 assert_equals(customElements.get(name), C); | |
34 }, 'get() returns the constructor'); | |
35 // 2. Otherwise, return undefined. | |
36 test(() => { | |
37 assert_equals(customElements.get('test-get-not-defined'), undefined); | |
38 }, 'get() returns undefined if the name is not defined'); | |
39 })(); | |
40 </script> | |
41 </body> | |
OLD | NEW |