Changeset 249762 in webkit
- Timestamp:
- Sep 11, 2019 7:52:18 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249761 r249762 1 2019-09-11 Ali Juma <ajuma@chromium.org> 2 3 Prevent reentrancy FrameLoader::dispatchUnloadEvents() 4 https://bugs.webkit.org/show_bug.cgi?id=200738 5 6 Reviewed by Brady Eidson. 7 8 Reentrancy causes m_pageDismissalEventBeingDispatched to be incorrectly 9 updated, so don't allow reentrancy. 10 11 Since this prevents m_pageDismissalEventBeingDispatched from being reset 12 inside a reentrant call, it can have the unintended effect of causing 13 FrameLoader::stopAllLoaders to early-out when called from 14 FrameLoader::detachFromParent while a frame's unload event handler 15 calls document.open() on a parent frame and causes itself to become 16 detached. Allowing a load to continue in a detached frame will lead to 17 a crash. To prevent this, add a new argument to FrameLoader::stopAllLoaders 18 that FrameLoader::detachFromParent can use to prevent an early-out. 19 20 * loader/FrameLoader.cpp: 21 (WebCore::FrameLoader::stopAllLoaders): 22 (WebCore::FrameLoader::detachFromParent): 23 (WebCore::FrameLoader::dispatchUnloadEvents): 24 (WebCore::FrameLoader::dispatchBeforeUnloadEvent): 25 Ensure that m_pageDismissalEventBeingDispatched is reset to its previous value, even if this is not None. 26 * loader/FrameLoader.h: 27 * loader/FrameLoaderTypes.h: 28 Add a StopLoadingPolicy enum. 29 1 30 2019-09-11 Charlie Turner <cturner@igalia.com> 2 31 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r249452 r249762 1807 1807 } 1808 1808 1809 void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy )1809 void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy, StopLoadingPolicy stopLoadingPolicy) 1810 1810 { 1811 1811 if (m_frame.document() && m_frame.document()->pageCacheState() == Document::InPageCache) 1812 1812 return; 1813 1813 1814 if ( !isStopLoadingAllowed())1814 if (stopLoadingPolicy == StopLoadingPolicy::PreventDuringUnloadEvents && !isStopLoadingAllowed()) 1815 1815 return; 1816 1816 … … 2821 2821 // because detachedChildren() will trigger the unload event handlers of any child frames, and those event 2822 2822 // handlers might start a new subresource load in this frame. 2823 stopAllLoaders( );2823 stopAllLoaders(ShouldClearProvisionalItem, StopLoadingPolicy::AlwaysStopLoading); 2824 2824 } 2825 2825 … … 3272 3272 { 3273 3273 if (!m_frame.document()) 3274 return; 3275 3276 if (m_pageDismissalEventBeingDispatched != PageDismissalType::None) 3274 3277 return; 3275 3278 … … 3352 3355 3353 3356 Ref<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create(); 3354 m_pageDismissalEventBeingDispatched = PageDismissalType::BeforeUnload;3355 3357 3356 3358 { 3359 SetForScope<PageDismissalType> change(m_pageDismissalEventBeingDispatched, PageDismissalType::BeforeUnload); 3357 3360 ForbidPromptsScope forbidPrompts(m_frame.page()); 3358 3361 domWindow->dispatchEvent(beforeUnloadEvent, domWindow->document()); 3359 3362 } 3360 3361 m_pageDismissalEventBeingDispatched = PageDismissalType::None;3362 3363 3363 3364 if (!beforeUnloadEvent->defaultPrevented()) -
trunk/Source/WebCore/loader/FrameLoader.h
r248762 r249762 146 146 // FIXME: These are all functions which stop loads. We have too many. 147 147 void stopAllLoadersAndCheckCompleteness(); 148 WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem );148 WEBCORE_EXPORT void stopAllLoaders(ClearProvisionalItemPolicy = ShouldClearProvisionalItem, StopLoadingPolicy = StopLoadingPolicy::PreventDuringUnloadEvents); 149 149 WEBCORE_EXPORT void stopForUserCancel(bool deferCheckLoadComplete = false); 150 150 void stop(); -
trunk/Source/WebCore/loader/FrameLoaderTypes.h
r246701 r249762 142 142 }; 143 143 144 enum class StopLoadingPolicy { 145 PreventDuringUnloadEvents, 146 AlwaysStopLoading 147 }; 148 144 149 enum class ObjectContentType : uint8_t { 145 150 None,
Note: See TracChangeset
for help on using the changeset viewer.