Index: third_party/WebKit/LayoutTests/custom-elements/spec/when-defined-invalid-name.html |
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/when-defined-invalid-name.html b/third_party/WebKit/LayoutTests/custom-elements/spec/when-defined-invalid-name.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..271b55c2a0496418bc1efe67938ac7617fe3bcaa |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/when-defined-invalid-name.html |
@@ -0,0 +1,55 @@ |
+<!DOCTYPE html> |
+<title>Custom Elements: whenDefined with invalid name</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharness-helpers.js"></script> |
kojii
2016/06/29 03:57:41
Please remove this, this file does not exist. I kn
|
+<script src="../../resources/testharnessreport.js"></script> |
+<script src="resources/custom-elements-helpers.js"></script> |
+<body> |
+<script> |
+ |
+'use strict'; |
+ |
+(() => { |
+ // https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name |
+ let invalid_names = [ |
+ '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) |
+ ]; |
+ |
+ invalid_names.forEach((name) => { |
+ promise_test((t) => { |
+ return create_window_in_test(t) |
+ .then((w) => { |
+ console.log(name); |
kojii
2016/06/29 03:57:41
Remove this.
|
+ return promise_rejects_with_dom_exception_syntax_error(w, t, w.customElements.whenDefined(name)); |
+ // return promise_rejects_with_dom_exception_syntax_error(w, t, Promise.reject(new SyntaxError)); |
kojii
2016/06/29 03:57:40
Remove this.
|
+ }); |
+ }, 'whenDefined() called with invalid name ' + name + ' should throw "SyntaxError"DOMEXception'); |
+ }); |
+ |
+ // Since both DOMException syntax error and JavaScript SyntaxError have |
+ // name property set to 'SyntaxError', assert_throws cannot distinguish them. |
+ 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_true(e instanceof global_context.DOMException); |
+ assert_throws('SYNTAX_ERR', function () { throw e; }); |
+ }); |
+ } |
+})(); |
+</script> |
+</body> |