WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
207232
Web Inspector: ensure that `didClearWindowObjectInWorld` is dispatched for the main world first
https://bugs.webkit.org/show_bug.cgi?id=207232
Summary
Web Inspector: ensure that `didClearWindowObjectInWorld` is dispatched for th...
Devin Rousso
Reported
2020-02-04 14:58:10 PST
(In reply to Devin Rousso from comment
https://webkit.org/b/206110#c16
)
> View in context: >
https://bugs.webkit.org/attachment.cgi?id=388830&action=review
> > >> Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp:178 > >> + auto injectedScript = injectedScriptManager().injectedScriptFor(globalObject); > > > > I believe there is a subtle issue here - when didClearWindowObjectInWorld is called for the User world before it is called for the Normal world, subsequent call to clear the normal world will erase this injected script from the InjectedScriptManager through m_injectedScriptManager->discardInjectedScripts(). > > > > This can either be patched via the following change to the dispatchDidClearWindowObjectsInAllWorlds (that is somewhat hacky), or via going back to instrumenting only normal worlds and iterating over the remaining worlds within agents explicitly. > > > > void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds() > > { > > Vector<Ref<DOMWrapperWorld>> worlds; > > ScriptController::getAllWorlds(worlds); > > // It is essential that the normal world is cleared first. > > // Various subsystem (InjectedScriptManager) will reset state upon normal > > // world initialization. > > Vector<DOMWrapperWorld*> nonNormalWorlds; > > for (auto& world : worlds) { > > if (world->type() == DOMWrapperWorld::Type::Normal) > > dispatchDidClearWindowObjectInWorld(world); > > else > > nonNormalWorlds.append(&world.get()); > > } > > for (auto* world : nonNormalWorlds) > > dispatchDidClearWindowObjectInWorld(*world); > > } > > Interesting! That is super subtle :P > > I think we'd ideally want to dispatch for the `mainThreadNormalWorld()` > first (as that's really the "signpost" for resetting all the injected > scripts and debugger state), then all other normal worlds, and then all > other worlds. IIUC, there should only ever be one normal world though (and > the current code supports that), so I think we can just do as you suggest. > > @Pavel Feldman, do you want to fix this, or should I?
Attachments
Patch
(2.84 KB, patch)
2020-02-04 15:01 PST
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Devin Rousso
Comment 1
2020-02-04 15:01:21 PST
Created
attachment 389716
[details]
Patch
WebKit Commit Bot
Comment 2
2020-02-05 18:13:52 PST
Comment on
attachment 389716
[details]
Patch Clearing flags on attachment: 389716 Committed
r255885
: <
https://trac.webkit.org/changeset/255885
>
WebKit Commit Bot
Comment 3
2020-02-05 18:13:53 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 4
2020-02-05 18:14:17 PST
<
rdar://problem/59210284
>
Pavel Feldman
Comment 5
2020-02-07 16:40:39 PST
***
Bug 207408
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug