| 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..da310db308dea24ae654b3e9e898b6f2384b5911
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html
|
| @@ -0,0 +1,44 @@
|
| +<!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>
|
| +<script>
|
| +'use strict';
|
| +(() => {
|
| + // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregistry-whendefined
|
| + // Use window from iframe to isolate the test.
|
| + function setup() {
|
| + const iframe = document.createElement('iframe');
|
| + document.body.appendChild(iframe);
|
| + const testWindow = iframe.contentWindow;
|
| + const customElements = testWindow.customElements;
|
| + if (!customElements)
|
| + return Promise.reject('This test requires window.customElements');
|
| + if (!('get' in customElements))
|
| + return Promise.reject('This test requires window.customElements.get');
|
| + return Promise.resolve(customElements);
|
| + }
|
| +
|
| + promise_test(() => setup()
|
| + .then(customElements => {
|
| + // 1. If this CustomElementsRegistry contains an entry with name name,
|
| + // then return that entry's constructor.
|
| + const name = 'test-get-existing';
|
| + class C extends HTMLElement {};
|
| + customElements.define(name, C);
|
| + assert_equals(customElements.get(name), C, 'get() returns the constructor')
|
| + return Promise.resolve(customElements);
|
| + }).then(customElements => {
|
| + // 2. Otherwise, return undefined.
|
| + assert_equals(customElements.get('test-get-not-defined'), undefined,
|
| + 'get() returns undefined for not-defined name');
|
| + }).catch(reason => { throw reason }));
|
| +})();
|
| +</script>
|
| +</body>
|
|
|