Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/get.html

Issue 1994093002: Introduce CustomElementRegistry#get() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-01T15:09:57 Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698