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

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed)

Created:
7 years, 5 months ago by adamk
Modified:
6 years, 7 months ago
CC:
blink-reviews, Nils Barth (inactive), jsbell+bindings_chromium.org, eae+blinkwatch, abarth-chromium, marja+watch_chromium.org, dglazkov+blink, adamk+blink_chromium.org, Nate Chapin, do-not-use, jww
Visibility:
Public.

Description

Make 'any'-typed attributes of events available in isolated worlds Before r153701, event attributes of type 'any' were freely-shared between isolated worlds. But since that patch, accessing those attributes from other worlds always returns null. This patch re-enables isolated worlds to communicate via custom-constructed events without leaking object identity by using SerializedScriptValue to clone 'any' attributes. When an event is constructed in an isolated world, we eagerly make a clone of its 'any' attributes. This is mostly for expediency: it would otherwise be tricky to find the original data, as it will be hanging off some wrapper in some world, but we wouldn't know which world to look in. But for the main world, since all these events are ScriptWrappable, we lazily clone. This is both for performance reasons and to avoid any side-effects of cloning (such as calling setters) until the event is actually accessed in another world. BUG=260378 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=154535

Patch Set 1 #

Patch Set 2 : Feature complete, needs refactoring #

Patch Set 3 : Properly refactored #

Total comments: 20

Patch Set 4 : Respond to review #

Total comments: 1

Patch Set 5 : Patch for landing #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+281 lines, -56 lines) Patch
A LayoutTests/fast/events/event-isolated-world-clone.html View 1 2 3 1 chunk +40 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/event-isolated-world-clone-expected.txt View 1 2 3 1 chunk +15 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/init-custom-event-isolated-world.html View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/init-custom-event-isolated-world-expected.txt View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/init-message-event-isolated-world.html View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A LayoutTests/fast/events/init-message-event-isolated-world-expected.txt View 1 2 3 1 chunk +7 lines, -0 lines 0 comments Download
M Source/bindings/scripts/deprecated_code_generator_v8.pm View 1 2 3 4 3 chunks +44 lines, -17 lines 0 comments Download
M Source/bindings/v8/ScriptValue.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/bindings/v8/ScriptWrappable.h View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M Source/bindings/v8/SerializedScriptValue.h View 1 2 3 3 chunks +9 lines, -4 lines 0 comments Download
M Source/bindings/v8/SerializedScriptValue.cpp View 1 2 3 4 chunks +13 lines, -14 lines 0 comments Download
M Source/bindings/v8/V8Binding.h View 1 2 2 chunks +3 lines, -0 lines 0 comments Download
M Source/bindings/v8/V8Binding.cpp View 1 2 3 4 1 chunk +8 lines, -2 lines 0 comments Download
M Source/bindings/v8/custom/V8CustomEventCustom.cpp View 1 2 3 4 3 chunks +17 lines, -5 lines 0 comments Download
M Source/bindings/v8/custom/V8MessageEventCustom.cpp View 1 2 3 4 2 chunks +19 lines, -3 lines 0 comments Download
M Source/bindings/v8/custom/V8PopStateEventCustom.cpp View 1 2 3 4 2 chunks +14 lines, -2 lines 3 comments Download
M Source/core/dom/CustomEvent.h View 1 2 3 2 chunks +8 lines, -2 lines 0 comments Download
M Source/core/dom/CustomEvent.cpp View 1 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/MessageEvent.h View 1 2 3 1 chunk +7 lines, -1 line 0 comments Download
M Source/core/dom/PopStateEvent.h View 1 2 3 2 chunks +7 lines, -2 lines 0 comments Download
M Source/core/dom/PopStateEvent.cpp View 1 1 chunk +0 lines, -1 line 0 comments Download
M Source/web/WebSerializedScriptValue.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 15 (0 generated)
adamk
Reviewers: abarth for the isolated world-related stuff marja for the change to ScriptWrappable
7 years, 5 months ago (2013-07-17 22:54:57 UTC) #1
abarth-chromium
LGTM, but we should probably have Marja take a look. https://codereview.chromium.org/19457002/diff/6001/LayoutTests/fast/events/init-custom-event-isolated-world.html File LayoutTests/fast/events/init-custom-event-isolated-world.html (right): https://codereview.chromium.org/19457002/diff/6001/LayoutTests/fast/events/init-custom-event-isolated-world.html#newcode6 ...
7 years, 5 months ago (2013-07-17 23:06:44 UTC) #2
adamk
https://codereview.chromium.org/19457002/diff/6001/LayoutTests/fast/events/init-custom-event-isolated-world.html File LayoutTests/fast/events/init-custom-event-isolated-world.html (right): https://codereview.chromium.org/19457002/diff/6001/LayoutTests/fast/events/init-custom-event-isolated-world.html#newcode6 LayoutTests/fast/events/init-custom-event-isolated-world.html:6: console.log("Tests that properties of custom events are cloned when ...
7 years, 5 months ago (2013-07-17 23:45:10 UTC) #3
haraken
https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/Dictionary.cpp File Source/bindings/v8/Dictionary.cpp (right): https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/Dictionary.cpp#newcode187 Source/bindings/v8/Dictionary.cpp:187: value = SerializedScriptValue::createSwallowExceptions(v8Value, m_isolate); Would you elaborate on why ...
7 years, 5 months ago (2013-07-18 00:00:29 UTC) #4
adamk
https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/Dictionary.cpp File Source/bindings/v8/Dictionary.cpp (right): https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/Dictionary.cpp#newcode187 Source/bindings/v8/Dictionary.cpp:187: value = SerializedScriptValue::createSwallowExceptions(v8Value, m_isolate); On 2013/07/18 00:00:29, haraken wrote: ...
7 years, 5 months ago (2013-07-18 01:09:14 UTC) #5
haraken
https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/custom/V8CustomEventCustom.cpp File Source/bindings/v8/custom/V8CustomEventCustom.cpp (right): https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/custom/V8CustomEventCustom.cpp#newcode69 Source/bindings/v8/custom/V8CustomEventCustom.cpp:69: event->setSerializedDetail(SerializedScriptValue::createSwallowExceptions(mainWorldDetail, info.GetIsolate())); I thought it might be possible in ...
7 years, 5 months ago (2013-07-18 01:28:00 UTC) #6
marja
I don't understand this CL well enough to review its correctness. However, I trust abarth@'s ...
7 years, 5 months ago (2013-07-18 09:24:51 UTC) #7
haraken
> https://codereview.chromium.org/19457002/diff/16001/Source/bindings/v8/V8Binding.cpp#newcode543 > Source/bindings/v8/V8Binding.cpp:543: return > DOMWrapperWorld::isolatedWorld(v8::Context::GetCurrent()); > What's the difference between GetCurrent() and GetEntered()? ...
7 years, 5 months ago (2013-07-18 09:38:31 UTC) #8
marja
On 2013/07/18 09:38:31, haraken wrote: > > > https://codereview.chromium.org/19457002/diff/16001/Source/bindings/v8/V8Binding.cpp#newcode543 > > Source/bindings/v8/V8Binding.cpp:543: return > > ...
7 years, 5 months ago (2013-07-18 09:43:37 UTC) #9
adamk
https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/custom/V8CustomEventCustom.cpp File Source/bindings/v8/custom/V8CustomEventCustom.cpp (right): https://codereview.chromium.org/19457002/diff/6001/Source/bindings/v8/custom/V8CustomEventCustom.cpp#newcode73 Source/bindings/v8/custom/V8CustomEventCustom.cpp:73: result = event->serializedScriptValue()->deserialize(); On 2013/07/18 01:28:01, haraken wrote: > ...
7 years, 5 months ago (2013-07-18 16:48:31 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/adamk@chromium.org/19457002/29001
7 years, 5 months ago (2013-07-18 20:34:41 UTC) #11
commit-bot: I haz the power
Change committed as 154535
7 years, 5 months ago (2013-07-18 22:36:09 UTC) #12
haraken
(Dragging up an old thread...) adamk@: Let me ask a clarifying question about this CL. ...
6 years, 7 months ago (2014-05-01 14:22:27 UTC) #13
adamk
https://codereview.chromium.org/19457002/diff/29001/Source/bindings/v8/custom/V8PopStateEventCustom.cpp File Source/bindings/v8/custom/V8PopStateEventCustom.cpp (right): https://codereview.chromium.org/19457002/diff/29001/Source/bindings/v8/custom/V8PopStateEventCustom.cpp#newcode73 Source/bindings/v8/custom/V8PopStateEventCustom.cpp:73: return; On 2014/05/01 14:22:27, haraken wrote: > > This ...
6 years, 7 months ago (2014-05-02 18:33:34 UTC) #14
haraken
6 years, 7 months ago (2014-05-03 12:35:09 UTC) #15
Message was sent while issue was closed.
https://codereview.chromium.org/19457002/diff/29001/Source/bindings/v8/custom...
File Source/bindings/v8/custom/V8PopStateEventCustom.cpp (right):

https://codereview.chromium.org/19457002/diff/29001/Source/bindings/v8/custom...
Source/bindings/v8/custom/V8PopStateEventCustom.cpp:73: return;
On 2014/05/02 18:33:35, adamk wrote:
> On 2014/05/01 14:22:27, haraken wrote:
> > 
> > This code implements lazy serialization in order to optimize a case where
the
> > main world accesses |state|. However, I don't quite understand how it's
> > optimized.
> > 
> > For example, imagine the following flow:
> > 
> > (1) the main world sets |state|.
> > (2) the main world gets |state|.
> > (3) an isolated world gets |state|.
> > 
> > Currently, the serialization of |state| happens at (2), not (3). Is this
> > expected? I thought that the lazy serialization is intended to delay the
> > serialization until any isolated world gets |state| (i.e., (3)).
> 
> I don't think this analysis is correct. Note that in the constructor, we store
> the main world state as a HiddenValue on the main world wrapper (see
> PopStateEventV8Internal::constructor). And then at the top of this function we
> retrieve the HiddenValue. So no serialization is done if we're still in the
main
> world.

Makes sense, thanks for the clarification! I was overlooking the code at line 51
- 56.

Powered by Google App Engine
This is Rietveld 408576698