Changeset 244293 in webkit
- Timestamp:
- Apr 15, 2019, 2:49:06 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/Node-cloneNode-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/Node-cloneNode.html (modified) (3 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element.html (modified) (4 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/JSCustomElementInterface.cpp (modified) (1 diff)
-
Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r244216 r244293 1 2019-04-12 Ryosuke Niwa <rniwa@webkit.org> 2 3 Throw TypeError when custom element constructor returns a wrong element or tries to create itself 4 https://bugs.webkit.org/show_bug.cgi?id=196892 5 6 Reviewed by Dean Jackson. 7 8 Update the tests according to https://github.com/web-platform-tests/wpt/pull/16328. 9 10 * web-platform-tests/custom-elements/upgrading/Node-cloneNode-expected.txt: 11 * web-platform-tests/custom-elements/upgrading/Node-cloneNode.html: 12 * web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element-expected.txt: 13 * web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element.html: 14 1 15 2019-04-12 Rob Buis <rbuis@igalia.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/Node-cloneNode-expected.txt
r230330 r244293 6 6 PASS Node.prototype.cloneNode(true) must be able to clone a descendent custom element 7 7 PASS Node.prototype.cloneNode(true) must set parentNode, previousSibling, and nextSibling before upgrading custom elements 8 PASS HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call9 PASS HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call10 PASS Upgrading a custom element must throw InvalidStateError when the custom element's constructor returns another element8 PASS HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call 9 PASS HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call 10 PASS Upgrading a custom element must throw TypeError when the custom element's constructor returns another element 11 11 PASS Inserting an element must not try to upgrade a custom element when it had already failed to upgrade once 12 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/Node-cloneNode.html
r230330 r244293 166 166 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 167 167 instance.cloneNode(false); 168 assert_equals(uncaughtError.name, ' InvalidStateError');169 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'168 assert_equals(uncaughtError.name, 'TypeError'); 169 }, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed' 170 170 + ' due to a custom element constructor constructing itself after super() call'); 171 171 … … 184 184 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 185 185 instance.cloneNode(false); 186 assert_equals(uncaughtError.name, ' InvalidStateError');187 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'186 assert_equals(uncaughtError.name, 'TypeError'); 187 }, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed' 188 188 + ' due to a custom element constructor constructing itself before super() call'); 189 189 … … 204 204 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 205 205 instance.cloneNode(false); 206 assert_equals(uncaughtError.name, ' InvalidStateError');207 }, 'Upgrading a custom element must throw InvalidStateError when the custom element\'s constructor returns another element');206 assert_equals(uncaughtError.name, 'TypeError'); 207 }, 'Upgrading a custom element must throw TypeError when the custom element\'s constructor returns another element'); 208 208 209 209 test(function () { -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element-expected.txt
r207703 r244293 1 1 2 2 PASS Element.prototype.createElement must add an unresolved custom element to the upgrade candidates map 3 PASS HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call 4 PASS HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call 5 PASS Upgrading a custom element must throw an InvalidStateError when the returned element is not SameValue as the upgraded element 3 PASS HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call 4 PASS HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call 5 PASS Upgrading a custom element must throw an TypeError when the returned element is not SameValue as the upgraded element 6 PASS Upgrading a custom element whose constructor returns a Text node must throw 7 PASS Upgrading a custom element whose constructor returns an Element must throw 6 8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element.html
r207703 r244293 16 16 <my-other-element id="instance"></my-other-element> 17 17 <my-other-element id="otherInstance"></my-other-element> 18 <not-an-element></not-an-element> 19 <not-an-html-element></not-an-html-element> 18 20 <script> 19 21 … … 49 51 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 50 52 customElements.define('instantiates-itself-after-super', InstantiatesItselfAfterSuper); 51 assert_equals(uncaughtError.name, ' InvalidStateError');52 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'53 assert_equals(uncaughtError.name, 'TypeError'); 54 }, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed' 53 55 + ' due to a custom element constructor constructing itself after super() call'); 54 56 … … 65 67 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 66 68 customElements.define('instantiates-itself-before-super', InstantiatesItselfBeforeSuper); 67 assert_equals(uncaughtError.name, ' InvalidStateError');68 }, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'69 assert_equals(uncaughtError.name, 'TypeError'); 70 }, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed' 69 71 + ' due to a custom element constructor constructing itself before super() call'); 70 72 … … 86 88 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 87 89 customElements.define('my-other-element', MyOtherElement); 88 assert_equals(uncaughtError.name, ' InvalidStateError');90 assert_equals(uncaughtError.name, 'TypeError'); 89 91 90 92 assert_true(document.createElement('my-other-element') instanceof MyOtherElement, 91 93 'Upgrading of custom elements must happen after the definition was added to the registry.'); 92 94 93 }, 'Upgrading a custom element must throw an InvalidStateError when the returned element is not SameValue as the upgraded element'); 95 }, 'Upgrading a custom element must throw an TypeError when the returned element is not SameValue as the upgraded element'); 96 97 test(() => { 98 class NotAnElement extends HTMLElement { 99 constructor() { 100 return new Text(); 101 } 102 } 103 104 let uncaughtError; 105 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 106 customElements.define("not-an-element", NotAnElement); 107 assert_equals(uncaughtError.name, "TypeError"); 108 }, "Upgrading a custom element whose constructor returns a Text node must throw"); 109 110 test(() => { 111 class NotAnHTMLElement extends HTMLElement { 112 constructor() { 113 return document.createElementNS("", "test"); 114 } 115 } 116 117 let uncaughtError; 118 window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; } 119 customElements.define("not-an-html-element", NotAnHTMLElement); 120 assert_equals(uncaughtError.name, "TypeError"); 121 }, "Upgrading a custom element whose constructor returns an Element must throw"); 94 122 95 123 </script> -
trunk/Source/WebCore/ChangeLog
r244292 r244293 1 2019-04-12 Ryosuke Niwa <rniwa@webkit.org> 2 3 Throw TypeError when custom element constructor returns a wrong element or tries to create itself 4 https://bugs.webkit.org/show_bug.cgi?id=196892 5 6 Reviewed by Dean Jackson. 7 8 Throw TypeError instead of InvalidStateError for consistency. This updates WebKit's custom elements 9 implementation for https://github.com/whatwg/html/pull/4525. 10 11 Tests: imported/w3c/web-platform-tests/custom-elements/upgrading/Node-cloneNode.html 12 imported/w3c/web-platform-tests/custom-elements/upgrading/upgrading-parser-created-element.html 13 14 * bindings/js/JSCustomElementInterface.cpp: 15 (WebCore::JSCustomElementInterface::upgradeElement): 16 * bindings/js/JSHTMLElementCustom.cpp: 17 (WebCore::constructJSHTMLElement): 18 1 19 2019-04-15 Don Olmstead <don.olmstead@sony.com> 2 20 -
trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp
r243163 r244293 215 215 if (!wrappedElement || wrappedElement != &element) { 216 216 element.setIsFailedCustomElement(*this); 217 reportException(state, createDOMException(state, InvalidStateError, "Custom element constructor failed to upgrade anelement"));217 reportException(state, createDOMException(state, TypeError, "Custom element constructor returned a wrong element")); 218 218 return; 219 219 } -
trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp
r234957 r244293 90 90 Element* elementToUpgrade = elementInterface->lastElementInConstructionStack(); 91 91 if (!elementToUpgrade) { 92 throw InvalidStateError(exec, scope, "Cannot instantiate a custom element inside its own constructor during upgrades"_s);92 throwTypeError(&exec, scope, "Cannot instantiate a custom element inside its own constructor during upgrades"_s); 93 93 return JSValue::encode(jsUndefined()); 94 94 }
Note:
See TracChangeset
for help on using the changeset viewer.