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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html

Issue 2321363002: Custom Elements: layout tests for custom built-in elements definition (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/spec/define-element-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Custom Elements: defineElement</title> 2 <title>Custom Elements: defineElement</title>
3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus tomelementsregistry"> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus tomelementsregistry">
4 <meta name="author" title="Dominic Cooney" href="mailto:dominicc@chromium.org"> 4 <meta name="author" title="Dominic Cooney" href="mailto:dominicc@chromium.org">
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="resources/custom-elements-helpers.js"></script> 7 <script src="resources/custom-elements-helpers.js"></script>
8 <body> 8 <body>
9 <script> 9 <script>
10 // TODO(dominicc): Merge these tests with 10 // TODO(dominicc): Merge these tests with
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 w1.customElements.define('first-name', X); 95 w1.customElements.define('first-name', X);
96 w2.customElements.define('second-name', X); 96 w2.customElements.define('second-name', X);
97 assert_equals( 97 assert_equals(
98 new X().localName, 'second-name', 98 new X().localName, 'second-name',
99 'the current global object should determine which definition is ' + 99 'the current global object should determine which definition is ' +
100 'operative; because X extends w2.HTMLElement, w2 is operative'); 100 'operative; because X extends w2.HTMLElement, w2 is operative');
101 }); 101 });
102 }, 'HTMLElement constructor looks up definitions in the current global-' + 102 }, 'HTMLElement constructor looks up definitions in the current global-' +
103 'reused constructor'); 103 'reused constructor');
104 104
105 // TODO: What error should be thrown if extends option not specified or null?
dominicc (has gone to gerrit) 2016/09/12 05:12:54 Part of it is element definition [1] step 6. If th
106
107 test_with_window((w) => {
108 class A extends w.HTMLButtonElement {}
109 let invalid_values = [
kojii 2016/09/12 04:52:23 Let's make the variable name more explicit; in thi
110 'a-a',
111 'z0-y0',
112 'emotion-\u1f60d',
113 'math-\u03b1',
114 'a.b-c'
115 ];
116 invalid_values.forEach((val) => {
117 assert_throws_dom_exception(w, 'NotSupportedError', () => {
118 w.customElements.define('a-a', A, { extends: val });
119 }, 'extends value must not be valid customized element name')
dominicc (has gone to gerrit) 2016/09/12 05:12:54 It might be good to include the actual value in th
120 });
121 }, 'Invalid extends value');
dominicc (has gone to gerrit) 2016/09/12 05:12:54 This and the next test may show up in output like
122
123 test_with_window((w) => {
124 class A extends w.HTMLButtonElement {}
125 let invalid_values = [
kojii 2016/09/12 04:52:23 ditto; such as "element_names_for_HTMLUnknownEleme
126 'bgsound',
127 'blink',
128 'isindex',
129 'multicol',
130 'nextid',
131 'spacer',
132 42
133 ]
134 invalid_values.forEach((val) => {
135 assert_throws_dom_exception(w, 'NotSupportedError', () => {
136 w.customElements.define('a-a', A, { extends: val });
137 }, 'extends value cannot be HTMLUnknownElement');
dominicc (has gone to gerrit) 2016/09/12 05:12:55 Make this more precise; the value isn't HTMLUnknow
138 });
139 }, 'Invalid extends value');
140
141 test_with_window((w) => {
142 class A extends w.HTMLButtonElement {}
143 w.customElements.define('defined-name', A, { extends: 'button'});
dominicc (has gone to gerrit) 2016/09/12 05:12:54 Be consistent with spacing; you put a space before
144 assert_equals(new A().localName, 'button', 'extends value should == local ' +
kojii 2016/09/12 04:52:23 Let's make human text; such as "localName should b
dominicc (has gone to gerrit) 2016/09/12 05:12:54 Use English, so not == but just 'be' or something
145 'name');
146 assert_not_equals(new A().localName, 'defined-name', 'extends value ' +
kojii 2016/09/12 04:52:23 ditto.
147 'should != defined-name');
148 }, 'Localname should be extends value not defined-name');
dominicc (has gone to gerrit) 2016/09/12 05:12:54 Write 'Local name ...' with a space. localName is
149
105 promise_test((t) => { 150 promise_test((t) => {
106 return Promise.all([create_window_in_test(t), create_window_in_test(t)]) 151 return Promise.all([create_window_in_test(t), create_window_in_test(t)])
107 .then(([w1, w2]) => { 152 .then(([w1, w2]) => {
108 class X extends w2.HTMLElement { }; 153 class X extends w2.HTMLElement { };
109 w1.customElements.define('x-x', X); 154 w1.customElements.define('x-x', X);
110 assert_throws( 155 assert_throws(
111 TypeError.prototype, () => new X(), 156 TypeError.prototype, () => new X(),
112 'the current global object (w2) should not find the definition in w1'); 157 'the current global object (w2) should not find the definition in w1');
113 }); 158 });
114 }, 'HTMLElement constructor looks up definitions in the current global'); 159 }, 'HTMLElement constructor looks up definitions in the current global');
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // step 2 448 // step 2
404 test_with_window((w) => { 449 test_with_window((w) => {
405 let invalid_name = 'annotation-xml'; 450 let invalid_name = 'annotation-xml';
406 assert_throws_dom_exception(w, 'SYNTAX_ERR', () => { 451 assert_throws_dom_exception(w, 'SYNTAX_ERR', () => {
407 w.customElements.define(invalid_name, class extends HTMLElement {}); 452 w.customElements.define(invalid_name, class extends HTMLElement {});
408 }, 'defining author-defined custom element constructor should pass this ' + 453 }, 'defining author-defined custom element constructor should pass this ' +
409 'step without throwing TypeError'); 454 'step without throwing TypeError');
410 }, 'Invalid constructor'); 455 }, 'Invalid constructor');
411 </script> 456 </script>
412 </body> 457 </body>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/spec/define-element-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698