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

Unified Diff: Source/bindings/v8/custom/V8PopStateEventCustom.cpp

Issue 19457002: Make 'any'-typed attributes of events available in isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/custom/V8MessageEventCustom.cpp ('k') | Source/core/dom/CustomEvent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/custom/V8PopStateEventCustom.cpp
diff --git a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
index ba93201f6fbc55512f4108480b737ee5fc722a43..91be6fe87c4cb0d16161fc5139a708daa0f755c7 100644
--- a/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
+++ b/Source/bindings/v8/custom/V8PopStateEventCustom.cpp
@@ -58,7 +58,18 @@ void V8PopStateEvent::stateAttrGetterCustom(v8::Local<v8::String> name, const v8
PopStateEvent* event = V8PopStateEvent::toNative(info.Holder());
History* history = event->history();
if (!history || !event->serializedState()) {
- v8SetReturnValue(info, cacheState(info.Holder(), v8::Null(info.GetIsolate())));
+ if (!event->serializedState()) {
+ // If we're in an isolated world and the event was created in the main world,
+ // we need to find the 'state' property on the main world wrapper and clone it.
+ v8::Local<v8::Value> mainWorldState = getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenPropertyName::state());
+ if (!mainWorldState.IsEmpty())
+ event->setSerializedState(SerializedScriptValue::createAndSwallowExceptions(mainWorldState, info.GetIsolate()));
+ }
+ if (event->serializedState())
+ result = event->serializedState()->deserialize();
+ else
+ result = v8::Null(info.GetIsolate());
+ v8SetReturnValue(info, cacheState(info.Holder(), result));
return;
haraken 2014/05/01 14:22:27 This code implements lazy serialization in order t
adamk 2014/05/02 18:33:35 I don't think this analysis is correct. Note that
haraken 2014/05/03 12:35:10 Makes sense, thanks for the clarification! I was o
}
@@ -81,8 +92,9 @@ void V8PopStateEvent::stateAttrGetterCustom(v8::Local<v8::String> name, const v8
}
result = event->serializedState()->deserialize(info.GetIsolate());
v8History->SetHiddenValue(V8HiddenPropertyName::state(), result);
- } else
+ } else {
result = event->serializedState()->deserialize(info.GetIsolate());
+ }
v8SetReturnValue(info, cacheState(info.Holder(), result));
}
« no previous file with comments | « Source/bindings/v8/custom/V8MessageEventCustom.cpp ('k') | Source/core/dom/CustomEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698