Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Custom Elements: Create an element when definition is non-null and synchr onous flag set</title> | |
| 3 <script src="../../resources/testharness.js"></script> | |
| 4 <script src="../../resources/testharnessreport.js"></script> | |
| 5 <script src="resources/custom-elements-helpers.js"></script> | |
| 6 <body> | |
| 7 <script> | |
| 8 'use strict'; | |
| 9 | |
| 10 // https://dom.spec.whatwg.org/#dom-document-createelement | |
| 11 // 1. If localName does not match the Name production, then throw an InvalidChar acterError | |
| 12 // 2. If context object is an HTML document, let localName be converted to ASCII lowercase | |
| 13 // 5. If 'is' is non-null and definition can't be found, then throw a NotFoundEr ror | |
| 14 // 6. If 'is' is non-null, then set is attribute to 'is' | |
| 15 | |
| 16 function setup(w) { | |
| 17 class A extends w.HTMLElement { | |
| 18 constructor() { | |
|
dominicc (has gone to gerrit)
2016/11/15 07:39:53
There's no need to write super-only constructors l
| |
| 19 super(); | |
| 20 } | |
| 21 } | |
| 22 w.customElements.define('a-a', A); | |
| 23 | |
| 24 class B extends w.HTMLDivElement { | |
| 25 constructor() { | |
| 26 super(); | |
| 27 } | |
| 28 } | |
| 29 w.customElements.define('b-b', B, {extends: 'div'}); | |
| 30 } | |
| 31 | |
| 32 test_with_window((w) => { | |
| 33 setup(w); | |
|
dominicc (has gone to gerrit)
2016/11/15 07:39:53
Why do you need any custom elements for this test?
| |
| 34 assert_throws_dom_exception(w, 'InvalidCharacterError', () => { | |
| 35 w.document.createElement('.invalid.name.'); | |
| 36 }); | |
| 37 }, '1. If localName does not match the Name production, then throw an InvalidCha racterError'); | |
| 38 | |
| 39 test_with_window((w) => { | |
| 40 class A extends w.HTMLElement { | |
| 41 constructor() { | |
| 42 super(); | |
| 43 } | |
| 44 } | |
| 45 w.customElements.define('a-a', A); | |
| 46 | |
| 47 class B extends w.HTMLDivElement { | |
| 48 constructor() { | |
| 49 super(); | |
| 50 } | |
| 51 } | |
| 52 w.customElements.define('b-b', B, {extends: 'div'}); | |
|
dominicc (has gone to gerrit)
2016/11/15 07:39:53
Why not use setup?
| |
| 53 | |
| 54 assert_equals(w.document.createElement('A-a').constructor, A); | |
| 55 assert_equals(w.document.createElement('div', {is: 'b-B'}).constructor, B); | |
| 56 }, '2. If context object is an HTML document, let localName be converted to ASCI I lowercase'); | |
|
dominicc (has gone to gerrit)
2016/11/15 07:39:53
I don't think "is" is a local name. Consider split
| |
| 57 | |
| 58 test_with_window((w) => { | |
| 59 setup(w); | |
| 60 assert_throws_dom_exception(w, 'NotFoundError', () => { | |
| 61 w.document.createElement('div', {is: 'a-a'}); | |
| 62 }); | |
|
dominicc (has gone to gerrit)
2016/11/15 07:39:53
These are good test cases.
Add a third parameter
| |
| 63 assert_throws_dom_exception(w, 'NotFoundError', () => { | |
| 64 w.document.createElement('button', {is: 'b-b'}); | |
| 65 }); | |
| 66 assert_throws_dom_exception(w, 'NotFoundError', () => { | |
| 67 w.document.createElement('button', {id: 'b-b'}); | |
| 68 }); | |
| 69 assert_throws_dom_exception(w, 'NotFoundError', () => { | |
| 70 w.document.createElement('div', {is: ''}); | |
| 71 }); | |
| 72 assert_throws_dom_exception(w, 'NotFoundError', () => { | |
| 73 w.document.createElement('div', {}); | |
| 74 }); | |
| 75 }, '5. If \'is\' is non-null and definition can not be found, then throw a NotFo undError'); | |
| 76 | |
| 77 test_with_window((w) => { | |
| 78 setup(w); | |
| 79 let a = w.document.createElement('a-a'); | |
| 80 let b = w.document.createElement('div', {is : 'b-b'}); | |
| 81 assert_equals(a.getAttribute('is'), null); | |
| 82 assert_equals(b.getAttribute('is'), 'b-b'); | |
| 83 }, '6. If \'is\' is non-null, then set is-attribute to \'is\''); | |
| 84 | |
| 85 </script> | |
| 86 </body> | |
| OLD | NEW |