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

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

Issue 2735573002: Ensure WindowProxy reinitialization on navigations if needed. (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 f7875a4d3e85f5adaaa45908b83c30028e2cb795..bd7bbda232bda6cb73f2ae0086d0ff80d8245ff4 100644
--- a/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
@@ -101,8 +101,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();
@@ -242,12 +242,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