Skip to content

Commit 6c58f93

Browse files
authored
browser(webkit): simplify isolated world handling (#766)
1 parent 2b231c9 commit 6c58f93

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1125
1+
1126

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,7 +3539,7 @@ index 5bc523a07233d6efab4ee18d19a6b8f105274664..d640783477744da05c5baed94dc0c168
35393539
DocumentWriter& writer() const { return m_writer; }
35403540

35413541
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
3542-
index a1285851f259d82a63a86de58c53de3e3b02d914..b2493d7629504bd11594fb7107a2b8b8acfe3e1c 100644
3542+
index a1285851f259d82a63a86de58c53de3e3b02d914..9b090e501f3212e8522ee77e8aa7fdae521793c1 100644
35433543
--- a/Source/WebCore/loader/FrameLoader.cpp
35443544
+++ b/Source/WebCore/loader/FrameLoader.cpp
35453545
@@ -1180,6 +1180,7 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat
@@ -3577,37 +3577,35 @@ index a1285851f259d82a63a86de58c53de3e3b02d914..b2493d7629504bd11594fb7107a2b8b8
35773577
}
35783578

35793579
void FrameLoader::continueFragmentScrollAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue)
3580-
@@ -3946,24 +3953,30 @@ String FrameLoader::referrer() const
3580+
@@ -3946,24 +3953,29 @@ String FrameLoader::referrer() const
35813581

35823582
void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
35833583
{
35843584
- if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript))
35853585
- return;
3586-
-
3586+
+ // It is essential that the normal world is cleared first.
3587+
+ // Various subsystem (InjectedScriptManager) will reset state upon normal
3588+
+ // world initialization.
3589+
+ DOMWrapperWorld& mainWorld = mainThreadNormalWorld();
3590+
+ dispatchDidClearWindowObjectInWorld(mainWorld);
3591+
35873592
Vector<Ref<DOMWrapperWorld>> worlds;
35883593
ScriptController::getAllWorlds(worlds);
35893594
- for (auto& world : worlds)
35903595
- dispatchDidClearWindowObjectInWorld(world);
3591-
+ // It is essential that the normal world is cleared first.
3592-
+ // Various subsystem (InjectedScriptManager) will reset state upon normal
3593-
+ // world initialization.
3594-
+ Vector<DOMWrapperWorld*> nonNormalWorlds;
35953596
+ for (auto& world : worlds) {
3596-
+ if (world->type() == DOMWrapperWorld::Type::Normal)
3597+
+ if (world.ptr() != &mainWorld)
35973598
+ dispatchDidClearWindowObjectInWorld(world);
3598-
+ else
3599-
+ nonNormalWorlds.append(&world.get());
36003599
+ }
3601-
+ for (auto* world : nonNormalWorlds)
3602-
+ dispatchDidClearWindowObjectInWorld(*world);
36033600
}
36043601

36053602
void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
36063603
{
36073604
- if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame.windowProxy().existingJSWindowProxy(world))
36083605
- return;
3609-
+ if (m_frame.script().canExecuteScripts(NotAboutToExecuteScript) && m_frame.windowProxy().existingJSWindowProxy(world)) {
3610-
+ m_client.dispatchDidClearWindowObjectInWorld(world);
3606+
+ if (m_frame.windowProxy().existingJSWindowProxy(world)) {
3607+
+ if (m_frame.script().canExecuteScripts(NotAboutToExecuteScript))
3608+
+ m_client.dispatchDidClearWindowObjectInWorld(world);
36113609

36123610
- m_client.dispatchDidClearWindowObjectInWorld(world);
36133611
-

0 commit comments

Comments
 (0)