-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for ways in which DOMException is unusual #6361
Conversation
I've switched these from testing the current-as-of-now spec to testing whatwg/webidl#378, which is much closer to what's implemented. The results are now:
|
Firefox (nightly)Testing web-platform-tests at revision dd553b3 All results9 tests ran/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.any.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-constants.any.worker.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.worker.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.worker.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.html
/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.worker.html
/WebIDL/ecmascript-binding/es-exceptions/exceptions.html
|
Sauce (safari)Testing web-platform-tests at revision dd553b3 |
Chrome (unstable)Testing web-platform-tests at revision 8031e53 |
Sauce (MicrosoftEdge)Testing web-platform-tests at revision 8031e53 |
w3c-test:mirror |
The toString() part is easy to fix, but the stack property test needs some work in V8, which currently registers it in %Error% instead of %ErrorPrototype% (I'm assuming we do want to move towards the latter given https://tc39.github.io/proposal-error-stacks/) |
Don't you also need to update some of the other tests?
|
Great catches, thanks. Let me update. Also I should probably make these tests .any.js tests. |
@bobholt, is the "No tests run" for 3/4 browsers in this PR a known issue? If not, can you file one with the infra label? |
@rakuco since the spec PR is merged, this is ready for review, when you have time :) |
Sorry, I didn't know you were waiting for me. The change looks fine on my side, and Chromium passes all the new tests (modulo those you'd mentioned before). One of the 3 reviewers need to lgtm the PR though. |
@@ -135,5 +127,3 @@ | |||
assert_equals(ex.code, 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test case ("bar", "UnknownError") a dupe of line 81 ("bar", "foo")?
|
||
const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "message"); | ||
assert_equals(typeof propDesc.get, "function", "property descriptor is a getter"); | ||
assert_equals(propDesc.set, undefined, "property descriptor is not a getter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean "not a setter"?
Ditto for all belows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, it turns out I can actually approve the change, sorry for the brain fart :-) Yuki's question makes sense though, so not doing it just yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits.
Adapt to whatwg/webidl#378 ("Re-align DOMException objects with what is implemented"). We were reimplementing toString() in DOMException because of WebKit r29058 ("Acid3 expects ExeceptionCode constants to be defined on DOMException objects") from almost 10 years ago. A lot has happened since, and we can (and should) just use the toString() implementation from ECMAScript's %ErrorProtoype% (which is explicitly mandated to be in DOMException's inheritance chain by the WebIDL spec). Contrary to what's originally described in bug 556950, we do throw an exception when DOMException.prototype.toString() is called directly: the WebIDL spec now expects it to, and web-platform-tests/wpt#6361 tests this behavior. Additionally, we've changed the way DOMException inherits from %ErrorPrototype%: instead of doing it in V8PerContextData, we now do it in V8DOMException::installV8DOMExceptionTemplate(), as the former had problems with (i)frames detached from the DOM and toString() would just call Object.prototype.toString() instead. The only user-visible part of the change is that "toString" is no longer part of DOMException.prototype's own properties; the error message format is exactly the same in most cases (the exact steps are described in https://tc39.github.io/ecma262/#sec-error.prototype.tostring). Finally, part of http/tests/plugins/cross-frame-object-access.html's output will change from: "Error: Uncaught [object DOMException]" to "Error: Uncaught" This is tricky because it involves PPAPI and its separate process, but basically the plugin in an iframe is trying to access top.location.href, Blink is throwing a SecurityError, but the error message is sent truncated to PPAPI. The message is truncated because V8 is calling its NoSideEffectsErrorToString() when creating the message, and this one does not use the message/name accessors we install, leading to an empty message (it looked slightly better before because we the presence of our own toString() caused Object::NoSideEffectsToString() to choose a different albeit still wrong code path). Blink's handling of this is fine, as the code in V8Initializer takes care of extracting the name and error message from the DOMException V8 object that threw the exception. Bug: 556950, 737497 Change-Id: I9d81edca1de903364bb1aca5950c313885c5964a Reviewed-on: https://chromium-review.googlesource.com/558904 Commit-Queue: Raphael Kubo da Costa (rakuco) <[email protected]> Reviewed-by: Mike West <[email protected]> Reviewed-by: Yuki Shiino <[email protected]> Reviewed-by: Kentaro Hara <[email protected]> Cr-Commit-Position: refs/heads/master@{#485960}
See whatwg/webidl#55.
DO NOT MERGE; this is in fact meant to demonstrate that nobody implements the current spec, which as discussed in that Web IDL issue I kind of messed up. So, likely we will fix the spec, then switch these tests to be -historical.html tests that test the opposite of their current values.