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> |