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

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

Issue 2100403002: calling whenDefined with invalid name should throw SyntaxError (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removing assert_throws_dom_exception Created 4 years, 5 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/custom-elements/spec/define-element.html » ('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/when_defined.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/when_defined.html b/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/when_defined.html
index 133c512bbfbd7480d2151cdd24975573437469d4..649c33907fb5f689363c74cc6d9a475579aad711 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/when_defined.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/custom-elements-registry/when_defined.html
@@ -2,6 +2,7 @@
<title>Custom Elements: CustomElementsRegistry.whenDefined</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
+<script src="../resources/custom-elements-helpers.js"></script>
<body>
<div id="log"></div>
<script>
@@ -58,6 +59,43 @@
assert_true(afterDefined, 'promise after defined should be resolved.');
assert_true(notDefined, 'promise for not defined name should not be resolved.');
}).catch(reason => { throw reason }));
+
+ // Calling whenDefined() with invalid names should throw "SyntaxError"DOMException
+ // https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name
+ let invalid_names = [
yosin_UTC9 2016/09/21 09:42:31 nit: s/let/const/
+ 'annotation-xml',
+ 'color-profile',
+ 'font-face',
+ 'font-face-src',
+ 'font-face-uri',
+ 'font-face-format',
+ 'font-face-name',
+ 'missing-glyph',
+ 'div', 'p',
+ 'nothtmlbutnohyphen',
+ '-not-initial-a-z', '0not-initial-a-z', 'Not-initial-a-z',
+ 'intermediate-UPPERCASE-letters',
+ 'bad-\u00b6', 'bad-\u00b8', 'bad-\u00bf', 'bad-\u00d7', 'bad-\u00f7',
+ 'bad-\u037e', 'bad-\u037e', 'bad-\u2000', 'bad-\u200e', 'bad-\u203e',
+ 'bad-\u2041', 'bad-\u206f', 'bad-\u2190', 'bad-\u2bff', 'bad-\u2ff0',
+ 'bad-\u3000', 'bad-\ud800', 'bad-\uf8ff', 'bad-\ufdd0', 'bad-\ufdef',
+ 'bad-\ufffe', 'bad-\uffff', 'bad-' + String.fromCodePoint(0xf0000)
yosin_UTC9 2016/09/21 09:42:31 You can write as 'bad-\u{F0000}'.
+ ];
+
+ invalid_names.forEach((name) => {
+ promise_test((t) => {
+ return create_window_in_test(t)
+ .then((w) => {
+ return promise_rejects_with_dom_exception_syntax_error(w, t, w.customElements.whenDefined(name));
yosin_UTC9 2016/09/21 09:42:31 You can write as below: .then(w => promise_rejects
+ });
+ }, 'whenDefined() called with invalid name ' + name + ' should throw "SyntaxError"DOMException');
yosin_UTC9 2016/09/21 09:42:31 You can write as below: `whenDefined() called with
+ });
+
+ function promise_rejects_with_dom_exception_syntax_error(global_context, test, promise, description) {
+ return promise.then(test.unreached_func("Should have rejected: " + description)).catch(function(e) {
+ assert_throws_dom_exception(global_context, 'SYNTAX_ERR', function () { throw e; })
+ });
+ }
})();
</script>
</body>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698