(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?
Created attachment 389716 [details] Patch
Comment on attachment 389716 [details] Patch Clearing flags on attachment: 389716 Committed r255885: <https://trac.webkit.org/changeset/255885>
All reviewed patches have been landed. Closing bug.
<rdar://problem/59210284>
*** Bug 207408 has been marked as a duplicate of this bug. ***