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)); |
} |