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

Issue 538933002: ScriptState::contextIsEmpty shouldn't return true for a context whose global object is detached (Closed)

Created:
6 years, 3 months ago by haraken
Modified:
6 years, 3 months ago
CC:
abarth-chromium, arv+blink, blink-reviews, blink-reviews-bindings_chromium.org
Project:
blink
Visibility:
Public.

Description

ScriptState::contextIsEmpty shouldn't return true for a context whose global object is detached I cannot reproduce bug 385366 but my best guess is that V8AbstractEventListener::handleEvent calls context->Global() after the global object is detached from the context (because of the frame navigation). Currently ScriptState is used in the following programming pattern: class DOMObject { DOMObject(ScriptState* scriptState) : m_scriptState(scriptState) { } // Record the script state when the DOMObject is created. void methodTriggeredAsynchrnously() { // Blink calls this sometime later. if (m_scriptState->contextIsEmpty()) // If the context is already gone, we do nothing. return; ScriptState::Scope scope(m_scriptState.get()); // Otherwise, enter the context and do the actual work. ...; // Do the actual work. } RefPtr<ScriptState> m_scriptState; }; The problem is that m_scriptState->contextIsEmpty() returns true even if the global object is detached from the context. We should return false in that case. This CL also renames contextIsEmpty to contextIsValid for clarity. BUG=385366 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=181392

Patch Set 1 #

Patch Set 2 : #

Total comments: 2

Patch Set 3 : #

Patch Set 4 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -34 lines) Patch
M Source/bindings/core/v8/ScheduledAction.cpp View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/ScriptController.cpp View 1 2 3 chunks +3 lines, -3 lines 0 comments Download
M Source/bindings/core/v8/ScriptDebugServer.cpp View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/ScriptState.h View 1 2 2 chunks +4 lines, -1 line 0 comments Download
M Source/bindings/core/v8/ScriptState.cpp View 2 chunks +8 lines, -0 lines 0 comments Download
M Source/bindings/core/v8/ScriptValue.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/core/v8/V8AbstractEventListener.cpp View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/V8CustomElementLifecycleCallbacks.cpp View 1 2 3 chunks +3 lines, -3 lines 0 comments Download
M Source/bindings/core/v8/V8EventListenerList.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/core/v8/V8MutationCallback.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/core/v8/V8WorkerGlobalScopeEventListener.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/core/v8/WindowProxy.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/core/v8/custom/V8WindowCustom.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/modules/v8/custom/V8CustomSQLStatementErrorCallback.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/templates/callback_interface.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/tests/results/V8TestCallbackInterface.cpp View 1 2 10 chunks +10 lines, -10 lines 0 comments Download
M Source/core/inspector/InspectorOverlay.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/core/inspector/PageRuntimeAgent.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/web/WebPluginContainerImpl.cpp View 1 2 3 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 13 (4 generated)
haraken
PTAL (A better fix is to clear ScriptState::m_context when we call m_context->DetachGlobal(), but we cannot ...
6 years, 3 months ago (2014-09-04 08:36:23 UTC) #2
jochen (gone - plz use gerrit)
https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h File Source/bindings/core/v8/ScriptState.h (right): https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h#newcode94 Source/bindings/core/v8/ScriptState.h:94: ScopedPersistent<v8::Context> m_context; you can have several pointers to the ...
6 years, 3 months ago (2014-09-04 08:37:39 UTC) #3
haraken
https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h File Source/bindings/core/v8/ScriptState.h (right): https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h#newcode94 Source/bindings/core/v8/ScriptState.h:94: ScopedPersistent<v8::Context> m_context; On 2014/09/04 08:37:39, jochen wrote: > you ...
6 years, 3 months ago (2014-09-04 08:39:23 UTC) #4
jochen (gone - plz use gerrit)
On 2014/09/04 at 08:39:23, haraken wrote: > https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h > File Source/bindings/core/v8/ScriptState.h (right): > > https://codereview.chromium.org/538933002/diff/20001/Source/bindings/core/v8/ScriptState.h#newcode94 ...
6 years, 3 months ago (2014-09-04 09:43:36 UTC) #5
haraken
On 2014/09/04 09:43:36, jochen wrote: > On 2014/09/04 at 08:39:23, haraken wrote: > > > ...
6 years, 3 months ago (2014-09-04 09:44:20 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/haraken@chromium.org/538933002/40001
6 years, 3 months ago (2014-09-04 11:31:05 UTC) #8
commit-bot: I haz the power
Failed to apply patch for Source/bindings/core/v8/ScheduledAction.cpp: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
6 years, 3 months ago (2014-09-04 11:31:16 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/haraken@chromium.org/538933002/60001
6 years, 3 months ago (2014-09-04 11:34:18 UTC) #12
commit-bot: I haz the power
6 years, 3 months ago (2014-09-04 19:26:13 UTC) #13
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as 181392

Powered by Google App Engine
This is Rietveld 408576698