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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp

Issue 2732483004: Reinitialize WindowProxy on navigations. (Closed)
Patch Set: . Created 3 years, 10 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
Index: third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
index 4aab69c8cfee3cb2a9a56fb4352868e2109e73c3..6e0b70d242ebf05ab4b798dcedc15be95b099e49 100644
--- a/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
@@ -133,8 +133,8 @@ void LocalWindowProxy::initialize() {
SecurityOrigin* origin = 0;
if (m_world->isMainWorld()) {
- // ActivityLogger for main world is updated within updateDocument().
- updateDocument();
+ // ActivityLogger for main world is updated within updateDocumentInternal().
+ updateDocumentInternal();
origin = frame()->document()->getSecurityOrigin();
// FIXME: Can this be removed when CSP moves to browser?
ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy();
@@ -316,12 +316,22 @@ void LocalWindowProxy::updateDocument() {
// to update. The update is done when the window proxy gets initialized later.
if (m_lifecycle == Lifecycle::ContextUninitialized)
return;
- // TODO(yukishiino): Is it okay to not update document when the context
- // is detached? It's not trivial to fix this because udpateDocumentProperty
- // requires a not-yet-detached context to instantiate a document wrapper.
- if (m_lifecycle == Lifecycle::ContextDetached)
+
+ // If this WindowProxy was previously initialized, reinitialize it now to
+ // preserve JS object identity. Otherwise, extant references to the
+ // WindowProxy will be broken.
+ if (m_lifecycle == Lifecycle::ContextDetached) {
+ initialize();
+ DCHECK_EQ(Lifecycle::ContextInitialized, m_lifecycle);
+ // Initialization internally updates the document properties, so just
+ // return afterwards.
return;
+ }
+
+ updateDocumentInternal();
+}
+void LocalWindowProxy::updateDocumentInternal() {
updateActivityLogger();
updateDocumentProperty();
updateSecurityOrigin(frame()->document()->getSecurityOrigin());
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.h ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698