Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html |
| diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html b/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..11e15a18deefbfccbe4c10a5b8eba8583746c700 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html |
| @@ -0,0 +1,41 @@ |
| +<!DOCTYPE html> |
| +<!-- |
| +TODO(yosin): We should upstream to wpt test. |
| +This file is taken from https://github.com/kojiishi/web-platform-tests/blob/53908d773012edf931047674f7afe3975bc1820f/custom-elements/custom-elements-registry/get.html |
| +--> |
| +<title>Custom Elements: CustomElementsRegistry.get</title> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<body> |
| +<div id="log"></div> |
| +<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
|
| +<script> |
| +'use strict'; |
| +(() => { |
| + // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregistry-whendefined |
| + // Use window from iframe to isolate the test. |
| + 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
|
| + const customElements = testWindow.customElements; |
| + 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
|
| + test(() => { |
| + assert_true('customElements' in testWindow, '"window.customElements" exists'); |
| + assert_true('get' in customElements, '"window.customElements.get" exists'); |
| + testable = true; |
| + }, '"window.customElements.get" should exist'); |
| + if (!testable) |
| + return; |
| + // 1. If this CustomElementsRegistry contains an entry with name name, |
| + // then return that entry's constructor. |
| + test(() => { |
| + const name = 'test-get-existing'; |
| + class C extends HTMLElement {}; |
| + customElements.define(name, C); |
| + assert_equals(customElements.get(name), C); |
| + }, 'get() returns the constructor'); |
| + // 2. Otherwise, return undefined. |
| + test(() => { |
| + assert_equals(customElements.get('test-get-not-defined'), undefined); |
| + }, 'get() returns undefined if the name is not defined'); |
| +})(); |
| +</script> |
| +</body> |