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

Issue 2244203002: Fix "report the exception" in Custom Elements V1 (Closed)

Created:
4 years, 4 months ago by kojii
Modified:
4 years, 4 months ago
CC:
blink-reviews, blink-reviews-bindings_chromium.org, chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix "report the exception" in Custom Elements V1 There are 2 places the spec uses "report the exception"[1]: 1. The document parser invokes constructors synchronously. 2. Upgrade. Currently Blink has 2 different code paths for each, and each has different issues: 1. The synchronous constructor uses SetVerbose(true), which works for thrown exceptions, but ExceptionState::throwIfNeeded() only puts the exception into pending exceptions, which will be cleared when TryCatch scope exits. 2. Upgrade fires error events and calls ExecutionContext::reportException() to avoid it, but it always uses NotSharableCrossOrigin. This works in run-layout-test where the origin has m_unversalAccess, but not in, for instance, file URL. This patch unifies the 2 code paths. [1] https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception BUG=632940 Committed: https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca Cr-Commit-Position: refs/heads/master@{#413421}

Patch Set 1 #

Patch Set 2 : Still WIP #

Patch Set 3 : Still WIP #

Patch Set 4 : Still WIP #

Patch Set 5 : Cleanup and tests #

Total comments: 8

Patch Set 6 : yukishiino review #

Patch Set 7 : Moved reportException to ScriptCustomElementDefinition.cpp #

Total comments: 2

Patch Set 8 : yukishiino review #

Total comments: 7

Patch Set 9 : Move to V8ErrorHandler along with messageHandlerInMainThread from V8Initializer #

Patch Set 10 : Moved to a new class V8MessageHandler #

Patch Set 11 : Renamed to ErrorEventDispatcher #

Total comments: 8

Patch Set 12 : dominicc review on tests at PS5 #

Patch Set 13 : New approach to use TryCatch::ReThrow #

Total comments: 13

Patch Set 14 : More try-and-errors for new approach #

Patch Set 15 : more try and errors #

Patch Set 16 : Add 6 possible approaches #

Patch Set 17 : Add approach 7 #

Patch Set 18 : Took approach 7 and cleanup #

Total comments: 7

Patch Set 19 : haraken/yukishiino reviews #

Unified diffs Side-by-side diffs Delta from patch set Stats (+198 lines, -23 lines) Patch
A third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +156 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ExceptionState.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h View 1 2 13 14 15 16 17 1 chunk +0 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +16 lines, -17 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +22 lines, -0 lines 0 comments Download

Messages

Total messages: 91 (40 generated)
kojii
@yukishiino, PTAL, it looks like you're the expert of V8ThrowException.
4 years, 4 months ago (2016-08-17 06:32:56 UTC) #13
Yuki
I think ExceptionState should be a kind of stack-allocated scope like v8::TryCatch, and we shouldn't ...
4 years, 4 months ago (2016-08-18 05:09:34 UTC) #16
kojii
On 2016/08/18 at 05:09:34, yukishiino wrote: > I think ExceptionState should be a kind of ...
4 years, 4 months ago (2016-08-18 05:30:15 UTC) #17
kojii
+haraken By looking at haraken's CL closer, my code is in trouble, because I need ...
4 years, 4 months ago (2016-08-18 05:33:29 UTC) #19
kojii
Updated the CL to use the strategy above (to add ExceptionState::reportException()). Also added "clearException" at ...
4 years, 4 months ago (2016-08-18 05:59:43 UTC) #22
Yuki
IIUC, what you'd like to do is to dispatch an ErrorEvent instead of throwing an ...
4 years, 4 months ago (2016-08-18 06:10:13 UTC) #23
kojii
On 2016/08/18 at 06:10:13, yukishiino wrote: > IIUC, what you'd like to do is to ...
4 years, 4 months ago (2016-08-18 06:20:36 UTC) #24
kojii
PTAL. Added ExceptionState::getException() and moved reportException to ScriptCustomElementDefinition.
4 years, 4 months ago (2016-08-18 06:49:27 UTC) #27
Yuki
LGTM. https://codereview.chromium.org/2244203002/diff/120001/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h File third_party/WebKit/Source/bindings/core/v8/ExceptionState.h (right): https://codereview.chromium.org/2244203002/diff/120001/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h#newcode108 third_party/WebKit/Source/bindings/core/v8/ExceptionState.h:108: v8::Local<v8::Value> getException() { return m_exception.newLocal(m_isolate); } m_exception may ...
4 years, 4 months ago (2016-08-18 07:57:10 UTC) #29
kojii
Thank you for your review! https://codereview.chromium.org/2244203002/diff/120001/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h File third_party/WebKit/Source/bindings/core/v8/ExceptionState.h (right): https://codereview.chromium.org/2244203002/diff/120001/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h#newcode108 third_party/WebKit/Source/bindings/core/v8/ExceptionState.h:108: v8::Local<v8::Value> getException() { return ...
4 years, 4 months ago (2016-08-18 08:06:52 UTC) #32
haraken
https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode199 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:199: return NotSharableCrossOrigin; Can you create a helper function and ...
4 years, 4 months ago (2016-08-18 09:03:03 UTC) #33
Yuki
https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode202 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:202: static void reportException(ScriptState* scriptState, On 2016/08/18 09:03:03, haraken wrote: ...
4 years, 4 months ago (2016-08-18 09:34:26 UTC) #34
kojii
https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/140001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode235 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:235: if (!message.isEmpty()) { On 2016/08/18 at 09:03:02, haraken wrote: ...
4 years, 4 months ago (2016-08-18 10:15:14 UTC) #37
kojii
That said, I guess I should try harder to share the code to handle unhandled ...
4 years, 4 months ago (2016-08-18 10:54:17 UTC) #38
haraken
On 2016/08/18 10:54:17, kojii wrote: > That said, I guess I should try harder to ...
4 years, 4 months ago (2016-08-18 12:16:38 UTC) #39
kojii
On 2016/08/18 at 12:16:38, haraken wrote: > Maybe we could add the helper functions to ...
4 years, 4 months ago (2016-08-18 13:52:33 UTC) #42
Yuki
I'm sorry for my late response (too late), but I'm afraid that V8ErrorHandler would be ...
4 years, 4 months ago (2016-08-18 14:55:38 UTC) #43
haraken
On 2016/08/18 14:55:38, Yuki wrote: > I'm sorry for my late response (too late), but ...
4 years, 4 months ago (2016-08-18 15:13:58 UTC) #44
haraken
On 2016/08/18 14:55:38, Yuki wrote: > I'm sorry for my late response (too late), but ...
4 years, 4 months ago (2016-08-18 15:17:20 UTC) #45
kojii
Ok...I tried a new static class, V8MessageHandler before I go to V8ErrorHandler. Let me try ...
4 years, 4 months ago (2016-08-18 15:17:24 UTC) #46
Yuki
On 2016/08/18 15:17:20, haraken wrote: > On 2016/08/18 14:55:38, Yuki wrote: > > I'm sorry ...
4 years, 4 months ago (2016-08-18 15:25:11 UTC) #47
kojii
On 2016/08/18 at 15:25:11, yukishiino wrote: > On 2016/08/18 15:17:20, haraken wrote: > > > ...
4 years, 4 months ago (2016-08-18 16:09:13 UTC) #52
dominicc (has gone to gerrit)
https://codereview.chromium.org/2244203002/diff/80001/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html File third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html (right): https://codereview.chromium.org/2244203002/diff/80001/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html#newcode27 third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html:27: <template id="common"> Is this worth it? It's only 4-5 ...
4 years, 4 months ago (2016-08-18 23:16:45 UTC) #55
haraken
https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp File third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp (right): https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp#newcode17 third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp:17: AccessControlStatus ErrorEventDispatcher::accessControlStatusFromScriptOriginOptions( I'd inline this function into dispatchErrorEvent(). I ...
4 years, 4 months ago (2016-08-19 01:51:08 UTC) #56
kojii
https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp File third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp (right): https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp#newcode68 third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp:68: if (!message.isEmpty()) { On 2016/08/19 at 01:51:08, haraken wrote: ...
4 years, 4 months ago (2016-08-19 03:20:39 UTC) #57
kojii
https://codereview.chromium.org/2244203002/diff/80001/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html File third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html (right): https://codereview.chromium.org/2244203002/diff/80001/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html#newcode64 third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html:64: assert_equals(error.name, rethrowErrorName); On 2016/08/18 at 23:16:45, dominicc wrote: > ...
4 years, 4 months ago (2016-08-19 04:57:12 UTC) #58
haraken
https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp File third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp (right): https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp#newcode68 third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp:68: if (!message.isEmpty()) { On 2016/08/19 03:20:39, kojii wrote: > ...
4 years, 4 months ago (2016-08-19 05:28:56 UTC) #59
dominicc (has gone to gerrit)
My $0.02 inline. https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp File third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp (right): https://codereview.chromium.org/2244203002/diff/200001/third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp#newcode68 third_party/WebKit/Source/bindings/core/v8/ErrorEventDispatcher.cpp:68: if (!message.isEmpty()) { On 2016/08/19 at ...
4 years, 4 months ago (2016-08-19 06:41:59 UTC) #60
kojii
The test was updated according to dominicc review on PS5, great if you could have ...
4 years, 4 months ago (2016-08-19 07:04:06 UTC) #61
kojii
haraken@, yukishiino@, PS13 tried TryCatch::ReThrow(), it crashes at: [1:1:0819/162050:5802167048579:FATAL:ScriptWrappable.cpp(27)] Check failed: !wrapper.IsEmpty(). #0 0x7fb2d9dc6c2e base::debug::StackTrace::StackTrace() ...
4 years, 4 months ago (2016-08-19 07:25:58 UTC) #62
Yuki
https://codereview.chromium.org/2244203002/diff/240001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/240001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode200 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:200: tryCatch.ReThrow(); This usage is simply wrong. https://codereview.chromium.org/2244203002/diff/240001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode215 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:215: ExceptionState ...
4 years, 4 months ago (2016-08-19 07:31:33 UTC) #63
Yuki
Sorry, this is my misunderstanding. Please ignore the following comments. On 2016/08/19 07:31:33, Yuki wrote: ...
4 years, 4 months ago (2016-08-19 07:44:07 UTC) #64
dominicc (has gone to gerrit)
lgtm Code looks good. Some points inline, mostly suggestions to make comments clearer. https://codereview.chromium.org/2244203002/diff/240001/third_party/WebKit/LayoutTests/custom-elements/spec/report-the-exception.html File ...
4 years, 4 months ago (2016-08-19 07:51:29 UTC) #65
kojii
PS14 tried: 1. v8call(object->Get()) but it doesn't help. 2. compileAndRunInternalScript() but still doesn't fire. I'll ...
4 years, 4 months ago (2016-08-19 08:51:29 UTC) #66
kojii
Added 6 approaches. * I still can't make 1-4 work. * 5 is workable, need ...
4 years, 4 months ago (2016-08-19 16:13:13 UTC) #67
kojii
I found throwStackOverflowExceptionIfNeeded does similar thing as approach 6, so this might be ok, though ...
4 years, 4 months ago (2016-08-20 14:46:26 UTC) #70
haraken
On 2016/08/20 14:46:26, kojii wrote: > I found throwStackOverflowExceptionIfNeeded does similar thing as approach 6, ...
4 years, 4 months ago (2016-08-22 01:48:22 UTC) #71
kojii
On 2016/08/22 at 01:48:22, haraken wrote: > > The approach 6 and 7 look good ...
4 years, 4 months ago (2016-08-22 01:57:59 UTC) #72
kojii
and FYI, this code checks the ScriptOrigin and sanitize as needed: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ExecutionContext.cpp?sq=package:chromium&dr=C&rcl=1471778369&l=157
4 years, 4 months ago (2016-08-22 02:22:29 UTC) #73
haraken
On 2016/08/22 02:22:29, kojii wrote: > and FYI, this code checks the ScriptOrigin and sanitize ...
4 years, 4 months ago (2016-08-22 02:30:10 UTC) #74
kojii
On 2016/08/22 at 02:30:10, haraken wrote: > > - What happens if the ScriptOrigin is ...
4 years, 4 months ago (2016-08-22 03:18:51 UTC) #76
haraken
On 2016/08/22 03:18:51, kojii wrote: > On 2016/08/22 at 02:30:10, haraken wrote: > > > ...
4 years, 4 months ago (2016-08-22 04:48:17 UTC) #79
kojii
On 2016/08/22 at 04:48:17, haraken wrote: > > > > If the origin is file:, ...
4 years, 4 months ago (2016-08-22 06:23:32 UTC) #80
kojii
PTAL, if you're ok to go with what we believe is right, then follow the ...
4 years, 4 months ago (2016-08-22 06:29:36 UTC) #81
haraken
LGTM https://codereview.chromium.org/2244203002/diff/380001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/380001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode192 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:192: static void dispatchErrorEvent(v8::Isolate* isolate, origin => constructor ? ...
4 years, 4 months ago (2016-08-22 06:36:47 UTC) #82
kojii
Thank you, will apply other comments, but one comment inline below: https://codereview.chromium.org/2244203002/diff/380001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): ...
4 years, 4 months ago (2016-08-22 06:41:33 UTC) #83
Yuki
https://codereview.chromium.org/2244203002/diff/380001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp File third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp (right): https://codereview.chromium.org/2244203002/diff/380001/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp#newcode218 third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp:218: exceptionState.clearException(); On 2016/08/22 06:36:47, haraken wrote: > > Do ...
4 years, 4 months ago (2016-08-22 06:42:08 UTC) #84
haraken
On 2016/08/22 06:41:33, kojii wrote: > Thank you, will apply other comments, but one comment ...
4 years, 4 months ago (2016-08-22 06:43:16 UTC) #85
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2244203002/400001
4 years, 4 months ago (2016-08-22 07:03:48 UTC) #88
commit-bot: I haz the power
Committed patchset #19 (id:400001)
4 years, 4 months ago (2016-08-22 08:34:44 UTC) #89
commit-bot: I haz the power
4 years, 4 months ago (2016-08-22 08:36:12 UTC) #91
Message was sent while issue was closed.
Patchset 19 (id:??) landed as
https://crrev.com/8b406045bb585b6a4bc7808d15df7070ba6e93ca
Cr-Commit-Position: refs/heads/master@{#413421}

Powered by Google App Engine
This is Rietveld 408576698