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

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-05-23T13:42:56 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..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>
« 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