Changeset 207520 in webkit
- Timestamp:
- Oct 18, 2016 10:03:11 PM (8 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 8 added
- 2 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207519 r207520 1 2016-10-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 Import the latest custom elements tests from W3C 4 https://bugs.webkit.org/show_bug.cgi?id=163640 5 6 Reviewed by Chris Dumez. 7 8 Removed the test re-imported via web-platform-tests in r206838. 9 10 * fast/custom-elements/lifecycle-callback-timing-expected.txt: Removed. 11 * fast/custom-elements/lifecycle-callback-timing.html: Removed. 12 1 13 2016-10-18 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r207514 r207520 1 2016-10-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 Import the latest custom elements tests from W3C 4 https://bugs.webkit.org/show_bug.cgi?id=163640 5 6 Reviewed by Chris Dumez. 7 8 Import more custom elements tests from web-platform-tests as of fbe5ac0fd8eecac67d1562032eeba5bd7ec2b735. 9 Most of these tests are written and fixed by me. 10 11 * web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt: 12 * web-platform-tests/custom-elements/htmlconstructor/newtarget.html: 13 * web-platform-tests/custom-elements/reactions/DOMStringMap-expected.txt: Added. 14 * web-platform-tests/custom-elements/reactions/DOMStringMap.html: Added. 15 * web-platform-tests/custom-elements/reactions/Document-expected.txt: 16 * web-platform-tests/custom-elements/reactions/Document.html: 17 * web-platform-tests/custom-elements/reactions/Element-expected.txt: 18 * web-platform-tests/custom-elements/reactions/Element.html: 19 * web-platform-tests/custom-elements/reactions/ElementContentEditable-expected.txt: Added. 20 * web-platform-tests/custom-elements/reactions/ElementContentEditable.html: Added. 21 * web-platform-tests/custom-elements/reactions/HTMLElement-expected.txt: Added. 22 * web-platform-tests/custom-elements/reactions/HTMLElement.html: Added. 23 * web-platform-tests/custom-elements/reactions/NamedNodeMap-expected.txt: 24 * web-platform-tests/custom-elements/reactions/NamedNodeMap.html: 25 * web-platform-tests/custom-elements/reactions/Range-expected.txt: 26 * web-platform-tests/custom-elements/reactions/Range.html: 27 * web-platform-tests/custom-elements/reactions/Selection-expected.txt: Added. 28 * web-platform-tests/custom-elements/reactions/Selection.html: Added. 29 * web-platform-tests/custom-elements/reactions/resources/reactions.js: 30 * web-platform-tests/custom-elements/reactions/w3c-import.log: 31 * web-platform-tests/custom-elements/resources/custom-elements-helpers.js: 32 1 33 2016-10-18 Chris Dumez <cdumez@apple.com> 2 34 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt
r206838 r207520 1 1 2 FAIL Use NewTarget's prototype, not the one stored at definition time promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.bo..." 3 FAIL Rethrow any exceptions thrown while getting the prototype assert_throws: function "() => { 4 return Reflect.construct(w.HTMLElement, [],..." threw object "TypeError: new.target does not define a custom element" ("TypeError") expected object "[object Object]" ("prototype throws") 5 FAIL If prototype is not object, derives the fallback from NewTarget's realm (autonomous custom elements) promise_test: Unhandled rejection with value: object "TypeError: new.target does not define a custom element" 6 FAIL If prototype is not object, derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..." 2 PASS Use NewTarget's prototype, not the one stored at definition time 3 PASS Rethrow any exceptions thrown while getting the prototype 4 FAIL If prototype is not object (null), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]" 5 FAIL If prototype is not object (undefined), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]" 6 FAIL If prototype is not object (5), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]" 7 FAIL If prototype is not object (string), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]" 8 FAIL If prototype is not object (null), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..." 9 FAIL If prototype is not object (undefined), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..." 10 FAIL If prototype is not object (5), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..." 11 FAIL If prototype is not object (string), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..." 7 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget.html
r206999 r207520 6 6 <script src="/resources/testharnessreport.js"></script> 7 7 <script src="../resources/custom-elements-helpers.js"></script> 8 8 <body> 9 9 <script> 10 10 "use strict"; 11 11 12 12 test_with_window(w => { 13 let afterDefinition = false;13 let beforeDefinition = true; 14 14 const proto1 = { "proto": "number one" }; 15 15 const proto2 = { "proto": "number two" }; 16 16 17 const TestElement = (function () { 18 assert_throws({ name: "prototype throws" }, () => { 19 const o = Reflect.construct(w.HTMLElement, [], new.target); 17 function TestElement() { 18 const o = Reflect.construct(w.HTMLElement, [], new.target); 19 assert_equals(Object.getPrototypeOf(o), proto2, 20 "Must use the value returned from new.target.prototype"); 21 assert_not_equals(Object.getPrototypeOf(o), proto1, 22 "Must not use the prototype stored at definition time"); 23 } 20 24 21 assert_equals(Object.getPrototypeOf(o), proto2, 22 "Must use the value returned from new.target.prototype"); 23 assert_not_equals(Object.getPrototypeOf(o), proto1, 24 "Must not use the prototype stored at definition time"); 25 }); 26 }).bind({}); 27 28 Object.defineProperty(TestElement, "prototype", { 29 get() { 30 return beforeDefinition ? proto1 : proto2; 31 } 25 const ElementWithDynamicPrototype = new Proxy(TestElement, { 26 get: function (target, name) { 27 if (name == "prototype") 28 return beforeDefinition ? proto1 : proto2; 29 return target[name]; 30 } 32 31 }); 33 32 34 w.customElements.define("test-element", TestElement);33 w.customElements.define("test-element", ElementWithDynamicPrototype); 35 34 36 beforeDefinition = true; 37 new TestElement(); 38 35 beforeDefinition = false; 36 new ElementWithDynamicPrototype(); 39 37 }, "Use NewTarget's prototype, not the one stored at definition time"); 40 38 … … 43 41 let throws = false; 44 42 45 const TestElement = (function () { 43 function TestElement() { 44 throws = true; 46 45 assert_throws({ name: "prototype throws" }, () => { 47 returnReflect.construct(w.HTMLElement, [], new.target);46 Reflect.construct(w.HTMLElement, [], new.target); 48 47 }); 49 } ).bind({});48 } 50 49 51 Object.defineProperty(TestElement, "prototype", {52 get () {53 if (throws ) {50 const ElementWithDynamicPrototype = new Proxy(TestElement, { 51 get: function (target, name) { 52 if (throws && name == "prototype") 54 53 throw { name: "prototype throws" }; 55 } 56 return {}; 54 return target[name]; 57 55 } 58 56 }); 59 57 60 w.customElements.define("test-element", TestElement);58 w.customElements.define("test-element", ElementWithDynamicPrototype); 61 59 62 throws = true; 63 new TestElement(); 60 new ElementWithDynamicPrototype(); 64 61 65 62 }, "Rethrow any exceptions thrown while getting the prototype"); 66 63 67 test_with_window(w =>{68 for (const notAnObject of [null, undefined, 5, "string"]){64 [null, undefined, 5, "string"].forEach(function (notAnObject) { 65 test_with_window(w => { 69 66 // We have to return an object during define(), but not during super() 70 67 let returnNotAnObject = false; 71 68 72 const TestElement = (function() {69 function TestElement() { 73 70 const o = Reflect.construct(w.HTMLElement, [], new.target); 74 71 75 assert_equals(Object.getPrototypeOf(o), window.HTMLElement, 72 assert_equals(Object.getPrototypeOf(new.target), window.Function.prototype); 73 assert_equals(Object.getPrototypeOf(o), window.HTMLElement.prototype, 76 74 "Must use the HTMLElement from the realm of NewTarget"); 77 assert_not_equals(Object.getPrototypeOf(o), w.HTMLElement ,75 assert_not_equals(Object.getPrototypeOf(o), w.HTMLElement.prototype, 78 76 "Must not use the HTMLElement from the realm of the active function object (w.HTMLElement)"); 79 77 80 78 return o; 81 } ).bind({});79 } 82 80 83 Object.defineProperty(TestElement, "prototype", { 84 get() { 85 return returnNotAnObject ? notAnObject : {}; 81 const ElementWithDynamicPrototype = new Proxy(TestElement, { 82 get: function (target, name) { 83 if (name == "prototype") 84 return returnNotAnObject ? notAnObject : {}; 85 return target[name]; 86 86 } 87 87 }); 88 88 89 w.customElements.define("test-element", TestElement);89 w.customElements.define("test-element", ElementWithDynamicPrototype); 90 90 91 91 returnNotAnObject = true; 92 new TestElement();93 } 94 } , "If prototype is not object, derives the fallback from NewTarget's realm (autonomous custom elements)");92 new ElementWithDynamicPrototype(); 93 }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (autonomous custom elements)"); 94 }); 95 95 96 test_with_window(w =>{97 for (const notAnObject of [null, undefined, 5, "string"]){96 [null, undefined, 5, "string"].forEach(function (notAnObject) { 97 test_with_window(w => { 98 98 // We have to return an object during define(), but not during super() 99 99 let returnNotAnObject = false; 100 100 101 const TestElement = (function() {101 function TestElement() { 102 102 const o = Reflect.construct(w.HTMLParagraphElement, [], new.target); 103 103 … … 108 108 109 109 return o; 110 } ).bind({});110 } 111 111 112 Object.defineProperty(TestElement, "prototype", { 113 get() { 114 return returnNotAnObject ? notAnObject : {}; 112 const ElementWithDynamicPrototype = new Proxy(TestElement, { 113 get: function (target, name) { 114 if (name == "prototype") 115 return returnNotAnObject ? notAnObject : {}; 116 return target[name]; 115 117 } 116 118 }); 117 119 118 w.customElements.define("test-element", TestElement, { extends: "p" });120 w.customElements.define("test-element", ElementWithDynamicPrototype, { extends: "p" }); 119 121 120 122 returnNotAnObject = true; 121 new TestElement(); 122 } 123 }, "If prototype is not object, derives the fallback from NewTarget's realm (customized built-in elements)"); 123 new ElementWithDynamicPrototype(); 124 }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (customized built-in elements)"); 125 }); 126 124 127 </script> 128 </body> -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document-expected.txt
r207170 r207520 2 2 FAIL importNode on Document must construct a new custom element when importing a custom element assert_array_equals: lengths differ, expected 1 got 0 3 3 PASS adoptNode on Document must enqueue an adopted reaction when importing a custom element 4 FAIL execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element assert_array_equals: lengths differ, expected 1 got 0 4 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document.html
r206999 r207520 2 2 <html> 3 3 <head> 4 <title>Custom Elements: CEReactions on ParentNodeinterface</title>4 <title>Custom Elements: CEReactions on Document interface</title> 5 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 6 6 <meta name="assert" content="importNode and adoptNode of Document interface must have CEReactions"> 7 7 <meta name="help" content="https://dom.spec.whatwg.org/#document"> 8 <meta name="help" content="https://html.spec.whatwg.org/#document"> 8 9 <script src="/resources/testharness.js"></script> 9 10 <script src="/resources/testharnessreport.js"></script> … … 43 44 }, 'adoptNode on Document must enqueue an adopted reaction when importing a custom element'); 44 45 46 test(function () { 47 var element = define_new_custom_element(); 48 var instance = document.createElement(element.name); 49 50 var container = document.createElement('div'); 51 container.contentEditable = true; 52 container.appendChild(instance); 53 document.body.appendChild(container); 54 55 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']); 56 57 container.focus(); 58 document.execCommand('delete', false, null); 59 60 assert_array_equals(element.takeLog().types(), ['disconnected']); 61 }, 'execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element'); 62 45 63 </script> 46 64 </body> -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element-expected.txt
r207170 r207520 14 14 PASS setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute 15 15 PASS setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute 16 PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist17 16 PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute 18 17 PASS removeAttribute on Element must enqueue an attributeChanged reaction when removing an existing attribute 19 18 PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute 20 PASS removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist21 19 PASS removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute 22 20 PASS removeAttributeNS on Element must enqueue an attributeChanged reaction when removing an existing attribute … … 30 28 PASS setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute 31 29 PASS setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute 32 PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist33 30 PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute 34 31 PASS removeAttributeNode on Element must enqueue an attributeChanged reaction when removing an existing attribute 35 32 PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute 36 PASS undefined must enqueue a connected reaction 37 PASS undefined must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document 33 PASS insertAdjacentElement on Element must enqueue a connected reaction 34 PASS insertAdjacentElement on Element must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document 35 FAIL innerHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1 36 FAIL innerHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1 37 FAIL innerHTML on Element must enqueue a disconnected reaction assert_array_equals: lengths differ, expected 1 got 0 38 FAIL outerHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1 39 FAIL outerHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1 40 FAIL outerHTML on Element must enqueue a disconnected reaction assert_array_equals: lengths differ, expected 1 got 0 41 FAIL insertAdjacentHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1 42 FAIL insertAdjacentHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1 38 43 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element.html
r206999 r207520 2 2 <html> 3 3 <head> 4 <title>Custom Elements: CEReactions on Nodeinterface</title>4 <title>Custom Elements: CEReactions on Element interface</title> 5 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 6 <meta name="assert" content="id, className, slot, setAttribute, setAttributeNS, removeAttribute, removeAttributeNS, setAttributeNode, setAttributeNodeNS, removeAttributeNode, and insertAdjacentElementof Element interface must have CEReactions">6 <meta name="assert" content="id, className, slot, setAttribute, setAttributeNS, removeAttribute, removeAttributeNS, setAttributeNode, setAttributeNodeNS, removeAttributeNode, insertAdjacentElement, innerHTML, outerHTML, and insertAdjacentHTML of Element interface must have CEReactions"> 7 7 <meta name="help" content="https://dom.spec.whatwg.org/#element"> 8 <meta name="help" content="https://w3c.github.io/DOM-Parsing/"> 8 9 <script src="/resources/testharness.js"></script> 9 10 <script src="/resources/testharnessreport.js"></script> … … 55 56 testNodeConnector(function (newContainer, element) { 56 57 newContainer.insertAdjacentElement('afterBegin', element); 57 }); 58 }, 'insertAdjacentElement on Element'); 59 60 testInsertingMarkup(function (newContainer, markup) { 61 newContainer.innerHTML = markup; 62 }, 'innerHTML on Element'); 63 64 testNodeDisconnector(function (customElement) { 65 customElement.parentNode.innerHTML = ''; 66 }, 'innerHTML on Element'); 67 68 testInsertingMarkup(function (newContainer, markup) { 69 newContainer.firstChild.outerHTML = markup; 70 }, 'outerHTML on Element'); 71 72 testNodeDisconnector(function (customElement) { 73 customElement.outerHTML = ''; 74 }, 'outerHTML on Element'); 75 76 testInsertingMarkup(function (newContainer, markup) { 77 newContainer.insertAdjacentHTML('afterBegin', markup); 78 }, 'insertAdjacentHTML on Element'); 58 79 59 80 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap-expected.txt
r207170 r207520 8 8 PASS setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing attribute 9 9 PASS setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing unobserved attribute 10 FAIL removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an attribute that does not exist The object can not be found here.11 10 PASS removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute 12 11 PASS removeNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute 13 12 PASS removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an existing unobserved attribute 14 FAIL removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an attribute that does not exist The object can not be found here.15 13 PASS removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute 16 14 PASS removeNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap.html
r206999 r207520 29 29 testAttributeRemover(function (element, name) { 30 30 element.attributes.removeNamedItem(name); 31 }, 'removeNamedItem on NamedNodeMap' );31 }, 'removeNamedItem on NamedNodeMap', {onlyExistingAttribute: true}); 32 32 33 33 testAttributeRemover(function (element, name) { 34 34 element.attributes.removeNamedItemNS(null, name); 35 }, 'removeNamedItemNS on NamedNodeMap' );35 }, 'removeNamedItemNS on NamedNodeMap', {onlyExistingAttribute: true}); 36 36 37 37 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range-expected.txt
r207170 r207520 7 7 PASS insertNode on Range must enqueue a connected reaction 8 8 PASS insertNode on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document 9 PASS insertNode on Range must enqueue a connected reaction 10 PASS insertNode on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document 9 PASS surroundContents on Range must enqueue a connected reaction 10 PASS surroundContents on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document 11 FAIL createContextualFragment on Range must construct a custom element assert_equals: expected (function) function "class CustomElement extends HTMLElement { 12 constru..." but got (object) object "[object Object]" 11 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range.html
r206999 r207520 43 43 range.selectNodeContents(container); 44 44 range.surroundContents(customElement); 45 }, 'insertNode on Range'); 45 }, 'surroundContents on Range'); 46 47 testParsingMarkup(function (document, markup) { 48 var range = document.createRange(); 49 return range.createContextualFragment(markup); 50 }, 'createContextualFragment on Range'); 46 51 47 52 </script> -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/resources/reactions.js
r206999 r207520 40 40 container.appendChild(instance); 41 41 assert_array_equals(element.takeLog().types(), ['connected']); 42 testFunction(instance );42 testFunction(instance, window); 43 43 assert_array_equals(element.takeLog().types(), ['disconnected']); 44 44 }, name + ' must enqueue a disconnected reaction'); 45 45 46 46 container.parentNode.removeChild(container); 47 } 48 49 function testInsertingMarkup(testFunction, name) { 50 let container = document.createElement('div'); 51 container.appendChild(document.createElement('div')); 52 document.body.appendChild(container); 53 54 test(function () { 55 var element = define_new_custom_element(); 56 testFunction(container, `<${element.name}></${element.name}>`); 57 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']); 58 }, name + ' must enqueue a connected reaction for a newly constructed custom element'); 59 60 test(function () { 61 var element = define_new_custom_element(['title']); 62 testFunction(container, `<${element.name} id="hello" title="hi"></${element.name}>`); 63 var logEntries = element.takeLog(); 64 assert_array_equals(logEntries.types(), ['constructed', 'attributeChanged', 'connected']); 65 assert_attribute_log_entry(logEntries[1], {name: 'title', oldValue: null, newValue: 'hi', namespace: null}); 66 }, name + ' must enqueue a attributeChanged reaction for a newly constructed custom element'); 67 68 container.parentNode.removeChild(container); 69 } 70 71 function testParsingMarkup(testFunction, name) { 72 test(function () { 73 var element = define_new_custom_element(['id']); 74 assert_array_equals(element.takeLog().types(), []); 75 var instance = testFunction(document, `<${element.name} id="hello" class="foo"></${element.name}>`); 76 assert_equals(Object.getPrototypeOf(instance.querySelector(element.name)), element.class); 77 var logEntries = element.takeLog(); 78 assert_array_equals(logEntries.types(), ['constructed', 'attributeChanged']); 79 assert_attribute_log_entry(logEntries[1], {name: 'id', oldValue: null, newValue: 'hello', namespace: null}); 80 }, name + ' must construct a custom element'); 47 81 } 48 82 … … 93 127 } 94 128 129 function testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, contentValue1, validValue2, contentValue2, name) { 130 test(function () { 131 var element = define_new_custom_element([contentAttributeName]); 132 var instance = document.createElement(element.name); 133 assert_array_equals(element.takeLog().types(), ['constructed']); 134 instance[jsAttributeName] = validValue1; 135 var logEntries = element.takeLog(); 136 assert_array_equals(logEntries.types(), ['attributeChanged']); 137 138 assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: contentValue1, namespace: null}); 139 }, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute'); 140 141 test(function () { 142 var element = define_new_custom_element([contentAttributeName]); 143 var instance = document.createElement(element.name); 144 instance[jsAttributeName] = validValue1; 145 assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']); 146 instance[jsAttributeName] = validValue2; 147 var logEntries = element.takeLog(); 148 assert_array_equals(logEntries.types(), ['attributeChanged']); 149 assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: contentValue1, newValue: contentValue2, namespace: null}); 150 }, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute'); 151 } 152 95 153 function testReflectAttribute(jsAttributeName, contentAttributeName, validValue1, validValue2, name) { 96 test(function () { 97 var element = define_new_custom_element([contentAttributeName]); 98 var instance = document.createElement(element.name); 99 assert_array_equals(element.takeLog().types(), ['constructed']); 100 instance[jsAttributeName] = validValue1; 101 var logEntries = element.takeLog(); 102 assert_array_equals(logEntries.types(), ['attributeChanged']); 103 assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: validValue1, namespace: null}); 104 }, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute'); 105 106 test(function () { 107 var element = define_new_custom_element([contentAttributeName]); 108 var instance = document.createElement(element.name); 109 instance[jsAttributeName] = validValue1; 110 assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']); 111 instance[jsAttributeName] = validValue2; 112 var logEntries = element.takeLog(); 113 assert_array_equals(logEntries.types(), ['attributeChanged']); 114 assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: validValue1, newValue: validValue2, namespace: null}); 115 }, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute'); 154 testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, validValue1, validValue2, validValue2, name); 155 } 156 157 function testReflectBooleanAttribute(jsAttributeName, contentAttributeName, name) { 158 testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, true, '', false, null, name); 116 159 } 117 160 … … 178 221 } 179 222 180 function testAttributeRemover(testFunction, name) { 181 test(function () { 182 var element = define_new_custom_element(['title']); 183 var instance = document.createElement(element.name); 184 assert_array_equals(element.takeLog().types(), ['constructed']); 185 testFunction(instance, 'title'); 186 assert_array_equals(element.takeLog().types(), []); 187 }, name + ' must not enqueue an attributeChanged reaction when removing an attribute that does not exist'); 223 function testAttributeRemover(testFunction, name, options) { 224 if (options && !options.onlyExistingAttribute) { 225 test(function () { 226 var element = define_new_custom_element(['title']); 227 var instance = document.createElement(element.name); 228 assert_array_equals(element.takeLog().types(), ['constructed']); 229 testFunction(instance, 'title'); 230 assert_array_equals(element.takeLog().types(), []); 231 }, name + ' must not enqueue an attributeChanged reaction when removing an attribute that does not exist'); 232 } 188 233 189 234 test(function () { -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/w3c-import.log
r206838 r207520 18 18 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Attr.html 19 19 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ChildNode.html 20 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/DOMStringMap.html 20 21 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/DOMTokenList.html 21 22 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document.html 22 23 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element.html 24 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ElementContentEditable.html 25 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLElement.html 23 26 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap.html 24 27 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Node.html 25 28 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ParentNode.html 26 29 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range.html 30 /LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Selection.html -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/resources/custom-elements-helpers.js
r206999 r207520 66 66 return { 67 67 name: name, 68 class: CustomElement, 68 69 takeLog: function () { 69 70 let currentLog = log; log = [];
Note: See TracChangeset
for help on using the changeset viewer.