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

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

Issue 2769803003: v8binding: Initializes WindowProxy iff it's uninitialized. (Closed)
Patch Set: . Created 3 years, 9 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 139ed88755d5dc6b65b9f7e211821b49bc008987..414b4622e1ffd18e991184f6ff13683c0fe0d69f 100644
--- a/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp
@@ -104,8 +104,9 @@ void LocalWindowProxy::disposeContext(GlobalDetachmentBehavior behavior) {
V8GCForContextDispose::instance().notifyContextDisposed(
frame()->isMainFrame());
- DCHECK(m_lifecycle == Lifecycle::ContextInitialized);
- m_lifecycle = Lifecycle::ContextDetached;
+ DCHECK_EQ(m_lifecycle, Lifecycle::ContextInitialized);
+ m_lifecycle = behavior == DetachGlobal ? Lifecycle::GlobalObjectDetached
+ : Lifecycle::ContextDetachedFromFrame;
}
void LocalWindowProxy::initialize() {
@@ -196,9 +197,8 @@ void LocalWindowProxy::createContext() {
m_scriptState = ScriptState::create(context, m_world);
- // TODO(haraken): Currently we cannot enable the following DCHECK because
- // an already detached window proxy can be re-initialized. This is wrong.
- // DCHECK(m_lifecycle == Lifecycle::ContextUninitialized);
+ DCHECK(m_lifecycle == Lifecycle::ContextUninitialized ||
+ m_lifecycle == Lifecycle::GlobalObjectDetached);
m_lifecycle = Lifecycle::ContextInitialized;
DCHECK(m_scriptState->contextIsValid());
}
@@ -318,10 +318,9 @@ void LocalWindowProxy::updateDocument() {
if (m_lifecycle == Lifecycle::ContextUninitialized)
return;
- // 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) {
+ // For a navigated-away window proxy, reinitialize it as a new window with new
+ // context and document.
+ if (m_lifecycle == Lifecycle::GlobalObjectDetached) {
initialize();
DCHECK_EQ(Lifecycle::ContextInitialized, m_lifecycle);
// Initialization internally updates the document properties, so just
@@ -390,18 +389,12 @@ void LocalWindowProxy::namedItemAdded(HTMLDocument* document,
DCHECK(m_world->isMainWorld());
// Context must be initialized before this point.
- DCHECK(m_lifecycle >= Lifecycle::ContextInitialized);
- // TODO(yukishiino): Is it okay to not update named properties
- // after the context gets detached?
- if (m_lifecycle == Lifecycle::ContextDetached)
- return;
+ DCHECK(m_lifecycle == Lifecycle::ContextInitialized ||
+ m_lifecycle == Lifecycle::ContextDetachedFromFrame);
haraken 2017/03/28 11:12:42 I might want to change this to CHECK. Are you pre
Yuki 2017/03/28 12:22:16 Hmm, IIUC, the guideline suggests DCHECK for detec
ScriptState::Scope scope(m_scriptState.get());
v8::Local<v8::Object> documentWrapper =
m_world->domDataStore().get(document, isolate());
- // TODO(yukishiino,peria): We should check if the own property with the same
- // name already exists or not, and if it exists, we shouldn't define a new
- // accessor property (it fails).
documentWrapper->SetAccessor(isolate()->GetCurrentContext(),
v8String(isolate(), name), getter).ToChecked();
}
@@ -411,11 +404,8 @@ void LocalWindowProxy::namedItemRemoved(HTMLDocument* document,
DCHECK(m_world->isMainWorld());
// Context must be initialized before this point.
- DCHECK(m_lifecycle >= Lifecycle::ContextInitialized);
- // TODO(yukishiino): Is it okay to not update named properties
- // after the context gets detached?
- if (m_lifecycle == Lifecycle::ContextDetached)
- return;
+ DCHECK(m_lifecycle == Lifecycle::ContextInitialized ||
+ m_lifecycle == Lifecycle::ContextDetachedFromFrame);
haraken 2017/03/28 11:12:42 Ditto.
Yuki 2017/03/28 12:22:16 Ditto.
if (document->hasNamedItem(name) || document->hasExtraNamedItem(name))
return;
@@ -432,9 +422,8 @@ void LocalWindowProxy::updateSecurityOrigin(SecurityOrigin* origin) {
// 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 security origin when the context
- // is detached?
- if (m_lifecycle == Lifecycle::ContextDetached)
+
+ if (m_lifecycle == Lifecycle::GlobalObjectDetached)
haraken 2017/03/28 11:12:42 Why can't this be: DCHECK(m_lifecycle == Lifecy
Yuki 2017/03/28 12:22:16 It seems that I confused you. In case of GlobalOb
return;
setSecurityToken(origin);

Powered by Google App Engine
This is Rietveld 408576698