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

Issue 20351002: Add 'error' parameter to 'window.onerror' handlers. (Closed)

Created:
7 years, 5 months ago by Mike West
Modified:
7 years, 4 months ago
Reviewers:
dcarney, adamk
CC:
blink-reviews, Nils Barth (inactive), kojih, jsbell+bindings_chromium.org, eae+blinkwatch, marja+watch_chromium.org, dglazkov+blink, adamk+blink_chromium.org, haraken, Nate Chapin, do-not-use, marja, jochen (gone - plz use gerrit), abarth-chromium
Visibility:
Public.

Description

Add 'error' parameter to 'window.onerror' and 'ErrorEvent'. The HTML5 spec recently added the error object to both the 'window.onerror' callback and the 'ErrorEvent' interface in order to improve developers' ability to debug issues that cause unexpected exceptions in the wild[1]. This patch brings Blink's behavior into line with that update. Currently, we generate an ErrorEvent object after doing sanitization. This patch refactors that code such that we generate an ErrorEvent when V8 calls back into the bindings (V8Initializer::messageHandlerInWorker and V8Initializer::messageHandlerInMainThread). Before we hand that event off to core for sanitization and dispatch, we grab the wrapper for the world in which the exception was thrown, and set the exception object as a hidden value (V8HiddenPropertyName::error()). On the other end, we grab that exception object in the custom 'error' getter of 'V8ErrorEvent', and when triggering the 'onerror' handler via 'V8ErrorHandler::callListenerFunction'. If the value exists, we're still in the same isolated world, so we can safely return the exception without leakage. If the value is empty, we've crossed worlds, and return 'null' instead. BUG=147127 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=155454

Patch Set 1 #

Total comments: 1

Patch Set 2 : Rework. #

Total comments: 2

Patch Set 3 : Rebase. #

Total comments: 5

Patch Set 4 : Rework^2. #

Total comments: 1

Patch Set 5 : fixes. #

Total comments: 16

Patch Set 6 : Feedback. #

Total comments: 2

Patch Set 7 : v8SetReturnValueNull. #

Patch Set 8 : Cleanup unnecessary includes. #

Patch Set 9 : Constructor. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+333 lines, -61 lines) Patch
M LayoutTests/fast/events/constructors/error-event-constructor.html View 1 2 3 4 5 6 7 8 1 chunk +11 lines, -6 lines 0 comments Download
M LayoutTests/fast/events/constructors/error-event-constructor-expected.txt View 1 2 3 4 5 6 7 8 1 chunk +9 lines, -6 lines 0 comments Download
M LayoutTests/fast/events/resources/onerror-test.js View 1 5 chunks +23 lines, -5 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-01-expected.txt View 1 1 chunk +7 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-02-expected.txt View 1 1 chunk +7 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-03-expected.txt View 1 1 chunk +8 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-04-expected.txt View 1 1 chunk +7 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-05-expected.txt View 1 1 chunk +6 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-06-expected.txt View 1 1 chunk +5 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-09-expected.txt View 1 1 chunk +4 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-10-expected.txt View 1 1 chunk +21 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-11-expected.txt View 1 1 chunk +21 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-12-expected.txt View 1 1 chunk +24 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-isolatedworld-01-expected.txt View 1 1 chunk +68 lines, -0 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-isolatedworld-02.html View 1 1 chunk +11 lines, -3 lines 0 comments Download
M LayoutTests/fast/events/window-onerror-isolatedworld-02-expected.txt View 1 1 chunk +16 lines, -10 lines 0 comments Download
M Source/bindings/bindings.gypi View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/scripts/IDLAttributes.txt View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/scripts/deprecated_code_generator_v8.pm View 1 2 3 4 5 6 7 8 2 chunks +6 lines, -2 lines 0 comments Download
M Source/bindings/v8/V8ErrorHandler.cpp View 1 2 3 4 5 6 7 2 chunks +7 lines, -1 line 0 comments Download
M Source/bindings/v8/V8HiddenPropertyName.h View 2 3 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/v8/V8Initializer.cpp View 1 2 3 4 5 6 7 4 chunks +16 lines, -4 lines 0 comments Download
M Source/bindings/v8/WorkerScriptController.cpp View 1 2 3 4 1 chunk +5 lines, -3 lines 0 comments Download
A + Source/bindings/v8/custom/V8ErrorEventCustom.cpp View 1 2 3 4 5 6 1 chunk +21 lines, -4 lines 0 comments Download
M Source/core/dom/ErrorEvent.h View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M Source/core/dom/ErrorEvent.idl View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/ScriptExecutionContext.h View 1 2 3 4 5 6 7 3 chunks +4 lines, -2 lines 0 comments Download
M Source/core/dom/ScriptExecutionContext.cpp View 1 2 3 4 5 6 7 3 chunks +15 lines, -13 lines 0 comments Download
M Source/core/workers/WorkerMessagingProxy.cpp View 1 2 3 1 chunk +3 lines, -2 lines 0 comments Download

Messages

Total messages: 24 (0 generated)
Mike West
Hi Dan, Jochen, and Adam. I'd appreciate some feedback on this preliminary pass at adding ...
7 years, 5 months ago (2013-07-25 16:52:23 UTC) #1
Mike West
+marja, since she knows oh so many things about handles. :)
7 years, 5 months ago (2013-07-25 16:53:30 UTC) #2
abarth-chromium
https://codereview.chromium.org/20351002/diff/1/Source/core/dom/ErrorEvent.h File Source/core/dom/ErrorEvent.h (right): https://codereview.chromium.org/20351002/diff/1/Source/core/dom/ErrorEvent.h#newcode72 Source/core/dom/ErrorEvent.h:72: const ScriptValue& error() const { return m_error; } Doesn't ...
7 years, 5 months ago (2013-07-25 18:24:08 UTC) #3
Mike West
On 2013/07/25 18:24:08, abarth wrote: > https://codereview.chromium.org/20351002/diff/1/Source/core/dom/ErrorEvent.h > File Source/core/dom/ErrorEvent.h (right): > > https://codereview.chromium.org/20351002/diff/1/Source/core/dom/ErrorEvent.h#newcode72 > ...
7 years, 4 months ago (2013-07-30 07:03:44 UTC) #4
abarth-chromium
On 2013/07/30 07:03:44, Mike West wrote: > You're right. We should do something here to ...
7 years, 4 months ago (2013-07-30 07:27:56 UTC) #5
Mike West
Hi Jochen, Dan, and Adam, I'd appreciate you taking a few moments to skim the ...
7 years, 4 months ago (2013-07-30 10:14:59 UTC) #6
dcarney
seems reasonable. would be really nice to get rid of a lot of the unnecessary ...
7 years, 4 months ago (2013-07-30 10:48:55 UTC) #7
Mike West
Rebase.
7 years, 4 months ago (2013-07-30 12:10:04 UTC) #8
adamk
I think this code would be simpler if we just relaxed our restrictions on where ...
7 years, 4 months ago (2013-07-30 15:46:40 UTC) #9
Mike West
https://chromiumcodereview.appspot.com/20351002/diff/15001/Source/core/dom/ErrorEvent.idl File Source/core/dom/ErrorEvent.idl (right): https://chromiumcodereview.appspot.com/20351002/diff/15001/Source/core/dom/ErrorEvent.idl#newcode38 Source/core/dom/ErrorEvent.idl:38: [InitializedByEventConstructor, Custom] readonly attribute any error; On 2013/07/30 15:46:41, ...
7 years, 4 months ago (2013-07-30 15:53:36 UTC) #10
adamk
https://chromiumcodereview.appspot.com/20351002/diff/15001/Source/core/dom/ScriptExecutionContext.cpp File Source/core/dom/ScriptExecutionContext.cpp (right): https://chromiumcodereview.appspot.com/20351002/diff/15001/Source/core/dom/ScriptExecutionContext.cpp#newcode254 Source/core/dom/ScriptExecutionContext.cpp:254: RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line, column, error); On ...
7 years, 4 months ago (2013-07-30 16:00:47 UTC) #11
Mike West
I've reworked the patch after talking with Adam and Dan: now the ErrorEvent is created ...
7 years, 4 months ago (2013-07-30 17:47:16 UTC) #12
adamk
Approach looks good, happy to see the ownership of the V8 object disconnected from C++. ...
7 years, 4 months ago (2013-07-30 17:55:41 UTC) #13
dcarney
much cleaner now. I added some nits in case you're done reworking this and ready ...
7 years, 4 months ago (2013-07-30 18:51:58 UTC) #14
Mike West
Thanks Dan and Adam. I do think this is a pretty good approach, and would ...
7 years, 4 months ago (2013-07-30 19:48:12 UTC) #15
adamk
https://codereview.chromium.org/20351002/diff/28001/Source/bindings/v8/V8Initializer.cpp File Source/bindings/v8/V8Initializer.cpp (right): https://codereview.chromium.org/20351002/diff/28001/Source/bindings/v8/V8Initializer.cpp#newcode102 Source/bindings/v8/V8Initializer.cpp:102: if (!wrappedEvent.IsEmpty() && wrappedEvent->IsObject()) wrappedEvent->IsObject() can just be an ...
7 years, 4 months ago (2013-07-31 16:37:30 UTC) #16
Mike West
PTAL. https://codereview.chromium.org/20351002/diff/28001/Source/bindings/v8/V8ErrorHandler.cpp File Source/bindings/v8/V8ErrorHandler.cpp (right): https://codereview.chromium.org/20351002/diff/28001/Source/bindings/v8/V8ErrorHandler.cpp#newcode64 Source/bindings/v8/V8ErrorHandler.cpp:64: error = v8::Local<v8::Value>(v8::Undefined(isolate)); On 2013/07/30 18:51:58, dcarney wrote: ...
7 years, 4 months ago (2013-08-01 07:52:15 UTC) #17
dcarney
lgtm https://codereview.chromium.org/20351002/diff/37001/Source/bindings/v8/custom/V8ErrorEventCustom.cpp File Source/bindings/v8/custom/V8ErrorEventCustom.cpp (right): https://codereview.chromium.org/20351002/diff/37001/Source/bindings/v8/custom/V8ErrorEventCustom.cpp#newcode57 Source/bindings/v8/custom/V8ErrorEventCustom.cpp:57: v8SetReturnValue(info, v8::Null(info.GetIsolate())); v8SetReturnValueNull
7 years, 4 months ago (2013-08-01 08:05:21 UTC) #18
adamk
lgtm, but see below; it's not clear to me what the correct behavior is when ...
7 years, 4 months ago (2013-08-01 15:44:02 UTC) #19
Mike West
On 2013/08/01 15:44:02, adamk wrote: > lgtm, but see below; it's not clear to me ...
7 years, 4 months ago (2013-08-01 19:24:37 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mkwst@chromium.org/20351002/62001
7 years, 4 months ago (2013-08-02 10:19:58 UTC) #21
commit-bot: I haz the power
Retried try job too often on mac_blink_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=mac_blink_rel&number=1049
7 years, 4 months ago (2013-08-02 15:18:04 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mkwst@chromium.org/20351002/62001
7 years, 4 months ago (2013-08-02 19:43:38 UTC) #23
commit-bot: I haz the power
7 years, 4 months ago (2013-08-02 21:51:17 UTC) #24
Message was sent while issue was closed.
Change committed as 155454

Powered by Google App Engine
This is Rietveld 408576698