Title: [285643] trunk/Tools
- Revision
- 285643
- Author
- [email protected]
- Date
- 2021-11-11 11:07:12 -0800 (Thu, 11 Nov 2021)
Log Message
Infinite recursion under InjectedBundlePage::exitFullScreenForElement()
https://bugs.webkit.org/show_bug.cgi?id=232948
<rdar://80588375>
Reviewed by Eric Carlson.
When WebCore indicates an error in exiting fullscreen, WebKit will respond by attempting to
close any outstanding fullscreen sessions by calling WebFullScreenManager::close(). If this
occurs in the InjectedBundlePage client during a call into WKBundlePageWillExitFullScreen()
or WKBundlePageWillDidFullScreen(), this call will recurse into
InjectedBundlePage::exitFullScreenForElement(), and cause a stack overflow.
Track the current state of fullscreen on a per-InjectedBundlePage basis, and bail out if
the state has been modified due to recursion.
Add a HashMap to map WKBundlePageRef onto InjectedBundlePages. Use that map to find the
particular InjectedBundlePage being requested to enter fullscreen. Add an enumerated
set of Fullscreen states and a private ivar for tracking that state.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::InjectedBundlePage):
(WTR::InjectedBundlePage::~InjectedBundlePage):
(WTR::InjectedBundlePage::enterFullScreenForElement):
(WTR::InjectedBundlePage::exitFullScreenForElement):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (285642 => 285643)
--- trunk/Tools/ChangeLog 2021-11-11 19:06:54 UTC (rev 285642)
+++ trunk/Tools/ChangeLog 2021-11-11 19:07:12 UTC (rev 285643)
@@ -1,3 +1,31 @@
+2021-11-11 Jer Noble <[email protected]>
+
+ Infinite recursion under InjectedBundlePage::exitFullScreenForElement()
+ https://bugs.webkit.org/show_bug.cgi?id=232948
+ <rdar://80588375>
+
+ Reviewed by Eric Carlson.
+
+ When WebCore indicates an error in exiting fullscreen, WebKit will respond by attempting to
+ close any outstanding fullscreen sessions by calling WebFullScreenManager::close(). If this
+ occurs in the InjectedBundlePage client during a call into WKBundlePageWillExitFullScreen()
+ or WKBundlePageWillDidFullScreen(), this call will recurse into
+ InjectedBundlePage::exitFullScreenForElement(), and cause a stack overflow.
+
+ Track the current state of fullscreen on a per-InjectedBundlePage basis, and bail out if
+ the state has been modified due to recursion.
+
+ Add a HashMap to map WKBundlePageRef onto InjectedBundlePages. Use that map to find the
+ particular InjectedBundlePage being requested to enter fullscreen. Add an enumerated
+ set of Fullscreen states and a private ivar for tracking that state.
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+ (WTR::InjectedBundlePage::InjectedBundlePage):
+ (WTR::InjectedBundlePage::~InjectedBundlePage):
+ (WTR::InjectedBundlePage::enterFullScreenForElement):
+ (WTR::InjectedBundlePage::exitFullScreenForElement):
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
+
2021-11-11 Chris Dumez <[email protected]>
Turn off various preferences when in captive portal mode
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (285642 => 285643)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2021-11-11 19:06:54 UTC (rev 285642)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp 2021-11-11 19:07:12 UTC (rev 285643)
@@ -230,10 +230,19 @@
stringBuilder.append("<unknown>");
}
+static HashMap<WKBundlePageRef, InjectedBundlePage*>& bundlePageMap()
+{
+ static NeverDestroyed<HashMap<WKBundlePageRef, InjectedBundlePage*>> map;
+ return map.get();
+}
+
InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
: m_page(page)
, m_world(adoptWK(WKBundleScriptWorldCreateWorld()))
{
+ ASSERT(!bundlePageMap().contains(page));
+ bundlePageMap().set(page, this);
+
WKBundlePageLoaderClientV9 loaderClient = {
{ 9, this },
didStartProvisionalLoadForFrame,
@@ -361,6 +370,8 @@
InjectedBundlePage::~InjectedBundlePage()
{
+ ASSERT(bundlePageMap().contains(m_page));
+ bundlePageMap().remove(m_page);
}
void InjectedBundlePage::stopLoading()
@@ -1643,28 +1654,65 @@
void InjectedBundlePage::enterFullScreenForElement(WKBundlePageRef pageRef, WKBundleNodeHandleRef elementRef)
{
+ ASSERT(bundlePageMap().contains(pageRef));
+ if (auto* injectedBundlePage = bundlePageMap().get(pageRef))
+ injectedBundlePage->enterFullScreenForElement(elementRef);
+}
+
+void InjectedBundlePage::enterFullScreenForElement(WKBundleNodeHandleRef elementRef)
+{
auto& injectedBundle = InjectedBundle::singleton();
if (injectedBundle.testRunner()->shouldDumpFullScreenCallbacks())
injectedBundle.outputText("enterFullScreenForElement()\n");
+ if (m_fullscreenState == EnteringFullscreen)
+ return;
+ m_fullscreenState = EnteringFullscreen;
+
if (!injectedBundle.testRunner()->hasCustomFullScreenBehavior()) {
- WKBundlePageWillEnterFullScreen(pageRef);
- WKBundlePageDidEnterFullScreen(pageRef);
+ WKBundlePageWillEnterFullScreen(m_page);
+ if (m_fullscreenState != EnteringFullscreen)
+ return;
+
+ WKBundlePageDidEnterFullScreen(m_page);
+ if (m_fullscreenState != EnteringFullscreen)
+ return;
+
} else
injectedBundle.testRunner()->callEnterFullscreenForElementCallback();
+
+ m_fullscreenState = InFullscreen;
}
void InjectedBundlePage::exitFullScreenForElement(WKBundlePageRef pageRef, WKBundleNodeHandleRef elementRef)
{
+ ASSERT(bundlePageMap().contains(pageRef));
+ if (auto* injectedBundlePage = bundlePageMap().get(pageRef))
+ injectedBundlePage->exitFullScreenForElement(elementRef);
+}
+
+void InjectedBundlePage::exitFullScreenForElement(WKBundleNodeHandleRef elementRef)
+{
auto& injectedBundle = InjectedBundle::singleton();
if (injectedBundle.testRunner()->shouldDumpFullScreenCallbacks())
injectedBundle.outputText("exitFullScreenForElement()\n");
+ if (m_fullscreenState == ExitingFullscreen)
+ return;
+ m_fullscreenState = ExitingFullscreen;
+
if (!injectedBundle.testRunner()->hasCustomFullScreenBehavior()) {
- WKBundlePageWillExitFullScreen(pageRef);
- WKBundlePageDidExitFullScreen(pageRef);
+ WKBundlePageWillExitFullScreen(m_page);
+ if (m_fullscreenState != ExitingFullscreen)
+ return;
+
+ WKBundlePageDidExitFullScreen(m_page);
+ if (m_fullscreenState != ExitingFullscreen)
+ return;
} else
injectedBundle.testRunner()->callExitFullscreenForElementCallback();
+
+ m_fullscreenState = NotInFullscreen;
}
void InjectedBundlePage::beganEnterFullScreen(WKBundlePageRef, WKRect, WKRect)
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h (285642 => 285643)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h 2021-11-11 19:06:54 UTC (rev 285642)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h 2021-11-11 19:07:12 UTC (rev 285643)
@@ -143,6 +143,9 @@
static void beganEnterFullScreen(WKBundlePageRef, WKRect initialFrame, WKRect finalFrame);
static void beganExitFullScreen(WKBundlePageRef, WKRect initialFrame, WKRect finalFrame);
static void closeFullScreen(WKBundlePageRef);
+
+ void enterFullScreenForElement(WKBundleNodeHandleRef element);
+ void exitFullScreenForElement(WKBundleNodeHandleRef element);
#endif
// Editor client
@@ -181,6 +184,14 @@
WKBundlePageRef m_page;
WKRetainPtr<WKBundleScriptWorldRef> m_world;
bool m_didCommitMainFrameLoad { false };
+
+ enum FullscreenState {
+ NotInFullscreen,
+ EnteringFullscreen,
+ ExitingFullscreen,
+ InFullscreen,
+ };
+ FullscreenState m_fullscreenState { NotInFullscreen };
};
} // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes