<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277356] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277356">277356</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-05-11 22:53:13 -0700 (Tue, 11 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add SPI to suspend / resume a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=225333
<rdar://77462543>

Reviewed by Geoff Garen.

Source/WebCore:

Add new function to BackForwardCache to suspend a page and return a CachedPage
instead of requiring a HistoryItem and storing the CachedPage on that history
item. This is useful when we want to suspend the page in-place and do not want
to require a history item (or a navigation).

* Headers.cmake:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::trySuspendPage):
(WebCore::BackForwardCache::addIfCacheable):
(WebCore::BackForwardCache::suspendPage):
* history/BackForwardCache.h:
* history/CachedPage.h:

Source/WebKit:

Add SPI to suspend / resume a WKWebView. This suspends the page as if it was in
the back/forward cache but the suspension happens in-place, no need to navigate.
The suspended page is also not part of the Back/Forward cache so its cap on the
number of suspended pages does not apply here.

Most of WKWebView's API / SPI will throw an exception when called on a suspended
view (The WKPageRefAPI will RELEASE_ASSERT()). Some of the basic API will stay
functional (URL, isLoading, title, ...). It is also safe to deallocate / close
a suspended WKWebView.

* UIProcess/API/C/WKPage.cpp:
(crashIfPageIsSuspended):
(WKPageLoadURL):
(WKPageLoadURLWithShouldOpenExternalURLsPolicy):
(WKPageLoadURLWithUserData):
(WKPageLoadURLRequest):
(WKPageLoadURLRequestWithUserData):
(WKPageLoadFile):
(WKPageLoadFileWithUserData):
(WKPageLoadData):
(WKPageLoadDataWithUserData):
(WKPageLoadHTMLString):
(WKPageLoadHTMLStringWithUserData):
(WKPageLoadAlternateHTMLString):
(WKPageLoadAlternateHTMLStringWithUserData):
(WKPageLoadPlainTextString):
(WKPageLoadPlainTextStringWithUserData):
(WKPageLoadWebArchiveData):
(WKPageLoadWebArchiveDataWithUserData):
(WKPageStopLoading):
(WKPageReload):
(WKPageReloadWithoutContentBlockers):
(WKPageReloadFromOrigin):
(WKPageReloadExpiredOnly):
(WKPageTryClose):
(WKPageClose):
(WKPageGoForward):
(WKPageGoBack):
(WKPageGoToBackForwardListItem):
(WKPageTryRestoreScrollPosition):
(WKPageUpdateWebsitePolicies):
(WKPageSetApplicationNameForUserAgent):
(WKPageSetCustomUserAgent):
(WKPageSetCustomTextEncodingName):
(WKPageTerminate):
(WKPageRestoreFromSessionState):
(WKPageRestoreFromSessionStateWithoutNavigation):
(WKPageSetCustomBackingScaleFactor):
(WKPageSetTextZoomFactor):
(WKPageSetPageZoomFactor):
(WKPageSetPageAndTextZoomFactors):
(WKPageSetScaleFactor):
(WKPageSetUseFixedLayout):
(WKPageSetFixedLayoutSize):
(WKPageListenForLayoutMilestones):
(WKPageSetSuppressScrollbarAnimations):
(WKPageSetRubberBandsAtLeft):
(WKPageSetRubberBandsAtRight):
(WKPageSetRubberBandsAtTop):
(WKPageSetRubberBandsAtBottom):
(WKPageSetEnableVerticalRubberBanding):
(WKPageSetEnableHorizontalRubberBanding):
(WKPageSetBackgroundExtendsBeyondPage):
(WKPageSetPaginationMode):
(WKPageSetPaginationBehavesLikeColumns):
(WKPageSetPageLength):
(WKPageSetGapBetweenPages):
(WKPageSetPaginationLineGridEnabled):
(WKPageSetMaintainsInactiveSelection):
(WKPageCenterSelectionInVisibleArea):
(WKPageFindStringMatches):
(WKPageGetImageForFindMatch):
(WKPageSelectFindMatch):
(WKPageFindString):
(WKPageHideFindUI):
(WKPageCountStringMatches):
(WKPageSetPageContextMenuClient):
(WKPageSetPageFindClient):
(WKPageSetPageFindMatchesClient):
(WKPageSetPageInjectedBundleClient):
(WKPageSetPageFormClient):
(WKPageSetPageLoaderClient):
(WKPageSetPagePolicyClient):
(WKPageSetPageUIClient):
(WKPageSetPageNavigationClient):
(WKPageSetPageStateClient):
(WKPageRunJavaScriptInMainFrame):
(WKPageRunJavaScriptInMainFrame_b):
(WKPageRenderTreeExternalRepresentation):
(WKPageGetSourceForFrame):
(WKPageGetContentsAsString):
(WKPageGetBytecodeProfile):
(WKPageGetSamplingProfilerOutput):
(WKPageGetSelectionAsWebArchiveData):
(WKPageGetContentsAsMHTMLData):
(WKPageForceRepaint):
(WKPageValidateCommand):
(WKPageExecuteCommand):
(WKPageComputePagesForPrinting):
(WKPageDrawPagesToPDF):
(WKPageBeginPrinting):
(WKPageEndPrinting):
(WKPageSetControlledByAutomation):
(WKPageSetAllowsRemoteInspection):
(WKPageSetMediaVolume):
(WKPageSetMuted):
(WKPageSetMediaCaptureEnabled):
(WKPageDidAllowPointerLock):
(WKPageClearUserMediaState):
(WKPageDidDenyPointerLock):
(WKPageSetMayStartMediaWhenInWindow):
(WKPageSelectContextMenuItem):
(WKPageSetScrollPinningBehavior):
(WKPageSetAddsVisitedLinks):
(WKPageClearWheelEventTestMonitor):
(WKPageCallAfterNextPresentationUpdate):
(WKPageSetIgnoresViewportScaleLimits):
(WKPageGetApplicationManifest_b):
(WKPageDumpPrivateClickMeasurement):
(WKPageClearPrivateClickMeasurement):
(WKPageSetPrivateClickMeasurementOverrideTimerForTesting):
(WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTesting):
(WKPageSimulateResourceLoadStatisticsSessionRestart):
(WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting):
(WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting):
(WKPageSetPrivateClickMeasurementAttributionReportURLsForTesting):
(WKPageMarkPrivateClickMeasurementsAsExpiredForTesting):
(WKPageSetPCMFraudPreventionValuesForTesting):
(WKPageSetMockCameraOrientation):
(WKPageLoadedSubresourceDomains):
(WKPageClearLoadedSubresourceDomains):
(WKPageSetMediaCaptureReportingDelayForTesting):
(WKPageDispatchActivityStateUpdateForTesting):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView loadRequest:]):
(-[WKWebView loadFileURL:allowingReadAccessToURL:]):
(-[WKWebView loadHTMLString:baseURL:]):
(-[WKWebView loadData:MIMEType:characterEncodingName:baseURL:]):
(-[WKWebView startDownloadUsingRequest:completionHandler:]):
(-[WKWebView resumeDownloadFromResumeData:completionHandler:]):
(-[WKWebView goToBackForwardListItem:]):
(-[WKWebView goBack]):
(-[WKWebView goForward]):
(-[WKWebView reload]):
(-[WKWebView reloadFromOrigin]):
(-[WKWebView stopLoading]):
(-[WKWebView evaluateJavaScript:completionHandler:]):
(-[WKWebView evaluateJavaScript:inFrame:inContentWorld:completionHandler:]):
(-[WKWebView callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]):
(-[WKWebView closeAllMediaPresentationsWithCompletionHandler:]):
(-[WKWebView pauseAllMediaPlaybackWithCompletionHandler:]):
(-[WKWebView setAllMediaPlaybackSuspended:completionHandler:]):
(-[WKWebView requestMediaPlaybackStateWithCompletionHandler:]):
(-[WKWebView setMicrophoneCaptureState:completionHandler:]):
(-[WKWebView setCameraCaptureState:completionHandler:]):
(-[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]):
(-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
(-[WKWebView setAllowsBackForwardNavigationGestures:]):
(-[WKWebView setCustomUserAgent:]):
(-[WKWebView setAllowsLinkPreview:]):
(-[WKWebView setPageZoom:]):
(-[WKWebView findString:withConfiguration:completionHandler:]):
(-[WKWebView setMediaType:]):
(-[WKWebView setInteractionState:]):
(-[WKWebView setAllowsMagnification:]):
(-[WKWebView setMagnification:centeredAtPoint:]):
(-[WKWebView setMagnification:]):
(-[WKWebView printOperationWithPrintInfo:]):
(-[WKWebView createPDFWithConfiguration:completionHandler:]):
(-[WKWebView createWebArchiveDataWithCompletionHandler:]):
(-[WKWebView loadSimulatedRequest:response:responseData:]):
(-[WKWebView loadSimulatedRequest:withResponse:responseData:]):
(-[WKWebView loadSimulatedRequest:responseHTMLString:]):
(-[WKWebView loadSimulatedRequest:withResponseHTMLString:]):
(-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
(-[WKWebView _toggleStrikeThrough:]):
(-[WKWebView _increaseListLevel:]):
(-[WKWebView _decreaseListLevel:]):
(-[WKWebView _changeListType:]):
(-[WKWebView _setViewportSizeForCSSViewportUnits:]):
(-[WKWebView _didEnableBrowserExtensions:]):
(-[WKWebView _didDisableBrowserExtensions:]):
(-[WKWebView _setEditable:]):
(-[WKWebView _executeEditCommand:argument:completion:]):
(-[WKWebView _startTextManipulationsWithConfiguration:completion:]):
(-[WKWebView _completeTextManipulation:completion:]):
(-[WKWebView _completeTextManipulationForItems:completion:]):
(-[WKWebView _takeFindStringFromSelection:]):
(-[WKWebView _updateMediaPlaybackControlsManager]):
(-[WKWebView _togglePictureInPicture]):
(-[WKWebView _closeAllMediaPresentations]):
(-[WKWebView _stopMediaCapture]):
(-[WKWebView _stopAllMediaPlayback]):
(-[WKWebView _suspendAllMediaPlayback]):
(-[WKWebView _resumeAllMediaPlayback]):
(-[WKWebView _restoreAppHighlights:]):
(-[WKWebView _restoreAndScrollToAppHighlight:]):
(-[WKWebView _addAppHighlight]):
(-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]):
(-[WKWebView _loadData:MIMEType:characterEncodingName:baseURL:userData:]):
(-[WKWebView _loadRequest:shouldOpenExternalURLs:]):
(-[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]):
(-[WKWebView _grantAccessToAssetServices]):
(-[WKWebView _revokeAccessToAssetServices]):
(-[WKWebView _switchFromStaticFontRegistryToUserFontRegistry]):
(-[WKWebView _appBoundNavigationDataForDomain:completionHandler:]):
(-[WKWebView _suspendPage:]):
(-[WKWebView _resumePage:]):
(-[WKWebView _setApplicationNameForUserAgent:]):
(-[WKWebView _killWebContentProcess]):
(-[WKWebView _reloadWithoutContentBlockers]):
(-[WKWebView _reloadExpiredOnly]):
(-[WKWebView _killWebContentProcessAndResetState]):
(-[WKWebView _takePDFSnapshotWithConfiguration:completionHandler:]):
(-[WKWebView _getPDFFirstPageSizeInFrame:completionHandler:]):
(-[WKWebView _restoreFromSessionStateData:]):
(-[WKWebView _restoreSessionState:andNavigate:]):
(-[WKWebView _close]):
(-[WKWebView _tryClose]):
(-[WKWebView _insertAttachmentWithFilename:contentType:data:options:completion:]):
(-[WKWebView _insertAttachmentWithFileWrapper:contentType:options:completion:]):
(-[WKWebView _insertAttachmentWithFileWrapper:contentType:completion:]):
(-[WKWebView _attachmentForIdentifier:]):
(-[WKWebView _simulateDeviceOrientationChangeWithAlpha:beta:gamma:]):
(-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]):
(-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:details:completionHandler:]):
(-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:detailsWithLinks:completionHandler:]):
(-[WKWebView _isJITEnabled:]):
(-[WKWebView _evaluateJavaScriptWithoutUserGesture:completionHandler:]):
(-[WKWebView _callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]):
(-[WKWebView _evaluateJavaScript:inFrame:inContentWorld:completionHandler:]):
(-[WKWebView _evaluateJavaScript:withSourceURL:inFrame:inContentWorld:completionHandler:]):
(-[WKWebView _updateWebpagePreferences:]):
(-[WKWebView _notifyUserScripts]):
(-[WKWebView _deferrableUserScriptsNeedNotification]):
(-[WKWebView _setAllowsRemoteInspection:]):
(-[WKWebView _setRemoteInspectionNameOverride:]):
(-[WKWebView _setAddsVisitedLinks:]):
(-[WKWebView _getMainResourceDataWithCompletionHandler:]):
(-[WKWebView _getWebArchiveDataWithCompletionHandler:]):
(-[WKWebView _getContentsAsStringWithCompletionHandler:]):
(-[WKWebView _getContentsOfAllFramesAsStringWithCompletionHandler:]):
(-[WKWebView _getContentsAsAttributedStringWithCompletionHandler:]):
(-[WKWebView _getApplicationManifestWithCompletionHandler:]):
(-[WKWebView _setPaginationMode:]):
(-[WKWebView _setPaginationBehavesLikeColumns:]):
(-[WKWebView _setPageLength:]):
(-[WKWebView _setGapBetweenPages:]):
(-[WKWebView _setPaginationLineGridEnabled:]):
(-[WKWebView _setTextZoomFactor:]):
(-[WKWebView _setPageZoomFactor:]):
(-[WKWebView _countStringMatches:options:maxCount:]):
(-[WKWebView _findString:options:maxCount:]):
(-[WKWebView _hideFindUI]):
(-[WKWebView _saveBackForwardSnapshotForItem:]):
(-[WKWebView _clearServiceWorkerEntitlementOverride:]):
(-[WKWebView _preconnectToServer:]):
(-[WKWebView _setCanUseCredentialStorage:]):
(-[WKWebView _setLayoutMode:]):
(-[WKWebView _setFixedLayoutSize:]):
(-[WKWebView _setBackgroundExtendsBeyondPage:]):
(-[WKWebView _setViewScale:]):
(-[WKWebView _setCORSDisablingPatterns:]):
(-[WKWebView _getProcessDisplayNameWithCompletionHandler:]):
(-[WKWebView _setMinimumEffectiveDeviceWidth:]):
(-[WKWebView _grantAccessToPreferenceService]):
(-[WKWebView _setScrollPerformanceDataCollectionEnabled:]):
(-[WKWebView _setAllowsMediaDocumentInlinePlayback:]):
(-[WKWebView _setMediaCaptureEnabled:]):
(-[WKWebView _setPageMuted:]):
(-[WKWebView _removeDataDetectedLinks:]):
(-[WKWebView _doAfterNextPresentationUpdate:]):
(-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForPainting:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleTouchEvent):
(WebKit::WebPageProxy::resumeActiveDOMObjectsAndAnimations):
(WebKit::WebPageProxy::suspendActiveDOMObjectsAndAnimations):
(WebKit::WebPageProxy::suspend):
(WebKit::WebPageProxy::resume):
(WebKit::WebPageProxy::requestMediaPlaybackState):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
* UIProcess/WebPageProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::suspend):
(WebKit::WebPage::resume):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Add API test coverage.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreHeaderscmake">trunk/Source/WebCore/Headers.cmake</a></li>
<li><a href="#trunkSourceWebCorehistoryBackForwardCachecpp">trunk/Source/WebCore/history/BackForwardCache.cpp</a></li>
<li><a href="#trunkSourceWebCorehistoryBackForwardCacheh">trunk/Source/WebCore/history/BackForwardCache.h</a></li>
<li><a href="#trunkSourceWebCorehistoryCachedPageh">trunk/Source/WebCore/history/CachedPage.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKPagecpp">trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaProcessSuspensionmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoapostMessageregularlyhtml">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebCore/ChangeLog      2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2021-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Add SPI to suspend / resume a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=225333
+        <rdar://77462543>
+
+        Reviewed by Geoff Garen.
+
+        Add new function to BackForwardCache to suspend a page and return a CachedPage
+        instead of requiring a HistoryItem and storing the CachedPage on that history
+        item. This is useful when we want to suspend the page in-place and do not want
+        to require a history item (or a navigation).
+
+        * Headers.cmake:
+        * history/BackForwardCache.cpp:
+        (WebCore::BackForwardCache::trySuspendPage):
+        (WebCore::BackForwardCache::addIfCacheable):
+        (WebCore::BackForwardCache::suspendPage):
+        * history/BackForwardCache.h:
+        * history/CachedPage.h:
+
</ins><span class="cx"> 2021-05-11  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove the String::toInt family of functions
</span></span></pre></div>
<a id="trunkSourceWebCoreHeaderscmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Headers.cmake (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Headers.cmake       2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebCore/Headers.cmake  2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -608,6 +608,7 @@
</span><span class="cx">     history/BackForwardItemIdentifier.h
</span><span class="cx">     history/CachedFrame.h
</span><span class="cx">     history/CachedFramePlatformData.h
</span><ins>+    history/CachedPage.h
</ins><span class="cx">     history/HistoryItem.h
</span><span class="cx"> 
</span><span class="cx">     html/Autocapitalize.h
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryBackForwardCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/BackForwardCache.cpp (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/BackForwardCache.cpp        2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebCore/history/BackForwardCache.cpp   2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -426,51 +426,62 @@
</span><span class="cx">         firePageHideEventRecursively(*child);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool BackForwardCache::addIfCacheable(HistoryItem& item, Page* page)
</del><ins>+std::unique_ptr<CachedPage> BackForwardCache::trySuspendPage(Page& page, ForceSuspension forceSuspension)
</ins><span class="cx"> {
</span><del>-    if (item.isInBackForwardCache())
-        return false;
</del><ins>+    page.mainFrame().loader().stopForBackForwardCache();
</ins><span class="cx"> 
</span><del>-    if (!page)
-        return false;
</del><ins>+    if (forceSuspension == ForceSuspension::No && !canCache(page))
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    page->mainFrame().loader().stopForBackForwardCache();
</del><ins>+    ASSERT_WITH_MESSAGE(!page.isUtilityPage(), "Utility pages such as SVGImage pages should never go into BackForwardCache");
</ins><span class="cx"> 
</span><del>-    if (!canCache(*page))
-        return false;
</del><ins>+    setBackForwardCacheState(page, Document::AboutToEnterBackForwardCache);
</ins><span class="cx"> 
</span><del>-    ASSERT_WITH_MESSAGE(!page->isUtilityPage(), "Utility pages such as SVGImage pages should never go into BackForwardCache");
-
-    setBackForwardCacheState(*page, Document::AboutToEnterBackForwardCache);
-
</del><span class="cx">     // Focus the main frame, defocusing a focused subframe (if we have one). We do this here,
</span><span class="cx">     // before the page enters the back/forward cache, while we still can dispatch DOM blur/focus events.
</span><del>-    if (page->focusController().focusedFrame())
-        page->focusController().setFocusedFrame(&page->mainFrame());
</del><ins>+    if (page.focusController().focusedFrame())
+        page.focusController().setFocusedFrame(&page.mainFrame());
</ins><span class="cx"> 
</span><span class="cx">     // Fire the pagehide event in all frames.
</span><del>-    firePageHideEventRecursively(page->mainFrame());
</del><ins>+    firePageHideEventRecursively(page.mainFrame());
</ins><span class="cx"> 
</span><del>-    destroyRenderTree(page->mainFrame());
</del><ins>+    destroyRenderTree(page.mainFrame());
</ins><span class="cx"> 
</span><span class="cx">     // Stop all loads again before checking if we can still cache the page after firing the pagehide
</span><span class="cx">     // event, since the page may have started ping loads in its pagehide event handler.
</span><del>-    page->mainFrame().loader().stopForBackForwardCache();
</del><ins>+    page.mainFrame().loader().stopForBackForwardCache();
</ins><span class="cx"> 
</span><span class="cx">     // Check that the page is still page-cacheable after firing the pagehide event. The JS event handlers
</span><span class="cx">     // could have altered the page in a way that could prevent caching.
</span><del>-    if (!canCache(*page)) {
-        setBackForwardCacheState(*page, Document::NotInBackForwardCache);
-        return false;
</del><ins>+    if (forceSuspension == ForceSuspension::No && !canCache(page)) {
+        setBackForwardCacheState(page, Document::NotInBackForwardCache);
+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    setBackForwardCacheState(*page, Document::InBackForwardCache);
</del><ins>+    setBackForwardCacheState(page, Document::InBackForwardCache);
</ins><span class="cx"> 
</span><ins>+    // Make sure we don't fire any JS events in this scope.
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
+    return makeUnique<CachedPage>(page);
+}
+
+bool BackForwardCache::addIfCacheable(HistoryItem& item, Page* page)
+{
+    if (item.isInBackForwardCache())
+        return false;
+
+    if (!page)
+        return false;
+
+    auto cachedPage = trySuspendPage(*page, ForceSuspension::No);
+    if (!cachedPage)
+        return false;
+
</ins><span class="cx">     {
</span><span class="cx">         // Make sure we don't fire any JS events in this scope.
</span><span class="cx">         ScriptDisallowedScope::InMainThread scriptDisallowedScope;
</span><span class="cx"> 
</span><del>-        item.setCachedPage(makeUnique<CachedPage>(*page));
</del><ins>+        item.setCachedPage(WTFMove(cachedPage));
</ins><span class="cx">         item.m_pruningReason = PruningReason::None;
</span><span class="cx">         m_items.add(&item);
</span><span class="cx">     }
</span><span class="lines">@@ -481,6 +492,13 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr<CachedPage> BackForwardCache::suspendPage(Page& page)
+{
+    RELEASE_LOG(BackForwardCache, "BackForwardCache::suspendPage()");
+
+    return trySuspendPage(page, ForceSuspension::Yes);
+}
+
</ins><span class="cx"> std::unique_ptr<CachedPage> BackForwardCache::take(HistoryItem& item, Page* page)
</span><span class="cx"> {
</span><span class="cx">     if (!item.m_cachedPage) {
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryBackForwardCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/BackForwardCache.h (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/BackForwardCache.h  2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebCore/history/BackForwardCache.h     2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx">     WEBCORE_EXPORT void setMaxSize(unsigned); // number of pages to cache.
</span><span class="cx">     unsigned maxSize() const { return m_maxSize; }
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT std::unique_ptr<CachedPage> suspendPage(Page&);
</ins><span class="cx">     WEBCORE_EXPORT bool addIfCacheable(HistoryItem&, Page*); // Prunes if maxSize() is exceeded.
</span><span class="cx">     WEBCORE_EXPORT void remove(HistoryItem&);
</span><span class="cx">     CachedPage* get(HistoryItem&, Page*);
</span><span class="lines">@@ -74,6 +75,8 @@
</span><span class="cx"> 
</span><span class="cx">     static bool canCachePageContainingThisFrame(Frame&);
</span><span class="cx"> 
</span><ins>+    enum class ForceSuspension : bool { No, Yes };
+    std::unique_ptr<CachedPage> trySuspendPage(Page&, ForceSuspension);
</ins><span class="cx">     void prune(PruningReason);
</span><span class="cx">     void dump() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryCachedPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/CachedPage.h (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/CachedPage.h        2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebCore/history/CachedPage.h   2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -38,9 +38,9 @@
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     explicit CachedPage(Page&);
</span><del>-    ~CachedPage();
</del><ins>+    WEBCORE_EXPORT ~CachedPage();
</ins><span class="cx"> 
</span><del>-    void restore(Page&);
</del><ins>+    WEBCORE_EXPORT void restore(Page&);
</ins><span class="cx">     void clear();
</span><span class="cx"> 
</span><span class="cx">     Page& page() const { return m_page; }
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/ChangeLog       2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -1,3 +1,300 @@
</span><ins>+2021-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Add SPI to suspend / resume a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=225333
+        <rdar://77462543>
+
+        Reviewed by Geoff Garen.
+
+        Add SPI to suspend / resume a WKWebView. This suspends the page as if it was in
+        the back/forward cache but the suspension happens in-place, no need to navigate.
+        The suspended page is also not part of the Back/Forward cache so its cap on the
+        number of suspended pages does not apply here.
+
+        Most of WKWebView's API / SPI will throw an exception when called on a suspended
+        view (The WKPageRefAPI will RELEASE_ASSERT()). Some of the basic API will stay
+        functional (URL, isLoading, title, ...). It is also safe to deallocate / close
+        a suspended WKWebView.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (crashIfPageIsSuspended):
+        (WKPageLoadURL):
+        (WKPageLoadURLWithShouldOpenExternalURLsPolicy):
+        (WKPageLoadURLWithUserData):
+        (WKPageLoadURLRequest):
+        (WKPageLoadURLRequestWithUserData):
+        (WKPageLoadFile):
+        (WKPageLoadFileWithUserData):
+        (WKPageLoadData):
+        (WKPageLoadDataWithUserData):
+        (WKPageLoadHTMLString):
+        (WKPageLoadHTMLStringWithUserData):
+        (WKPageLoadAlternateHTMLString):
+        (WKPageLoadAlternateHTMLStringWithUserData):
+        (WKPageLoadPlainTextString):
+        (WKPageLoadPlainTextStringWithUserData):
+        (WKPageLoadWebArchiveData):
+        (WKPageLoadWebArchiveDataWithUserData):
+        (WKPageStopLoading):
+        (WKPageReload):
+        (WKPageReloadWithoutContentBlockers):
+        (WKPageReloadFromOrigin):
+        (WKPageReloadExpiredOnly):
+        (WKPageTryClose):
+        (WKPageClose):
+        (WKPageGoForward):
+        (WKPageGoBack):
+        (WKPageGoToBackForwardListItem):
+        (WKPageTryRestoreScrollPosition):
+        (WKPageUpdateWebsitePolicies):
+        (WKPageSetApplicationNameForUserAgent):
+        (WKPageSetCustomUserAgent):
+        (WKPageSetCustomTextEncodingName):
+        (WKPageTerminate):
+        (WKPageRestoreFromSessionState):
+        (WKPageRestoreFromSessionStateWithoutNavigation):
+        (WKPageSetCustomBackingScaleFactor):
+        (WKPageSetTextZoomFactor):
+        (WKPageSetPageZoomFactor):
+        (WKPageSetPageAndTextZoomFactors):
+        (WKPageSetScaleFactor):
+        (WKPageSetUseFixedLayout):
+        (WKPageSetFixedLayoutSize):
+        (WKPageListenForLayoutMilestones):
+        (WKPageSetSuppressScrollbarAnimations):
+        (WKPageSetRubberBandsAtLeft):
+        (WKPageSetRubberBandsAtRight):
+        (WKPageSetRubberBandsAtTop):
+        (WKPageSetRubberBandsAtBottom):
+        (WKPageSetEnableVerticalRubberBanding):
+        (WKPageSetEnableHorizontalRubberBanding):
+        (WKPageSetBackgroundExtendsBeyondPage):
+        (WKPageSetPaginationMode):
+        (WKPageSetPaginationBehavesLikeColumns):
+        (WKPageSetPageLength):
+        (WKPageSetGapBetweenPages):
+        (WKPageSetPaginationLineGridEnabled):
+        (WKPageSetMaintainsInactiveSelection):
+        (WKPageCenterSelectionInVisibleArea):
+        (WKPageFindStringMatches):
+        (WKPageGetImageForFindMatch):
+        (WKPageSelectFindMatch):
+        (WKPageFindString):
+        (WKPageHideFindUI):
+        (WKPageCountStringMatches):
+        (WKPageSetPageContextMenuClient):
+        (WKPageSetPageFindClient):
+        (WKPageSetPageFindMatchesClient):
+        (WKPageSetPageInjectedBundleClient):
+        (WKPageSetPageFormClient):
+        (WKPageSetPageLoaderClient):
+        (WKPageSetPagePolicyClient):
+        (WKPageSetPageUIClient):
+        (WKPageSetPageNavigationClient):
+        (WKPageSetPageStateClient):
+        (WKPageRunJavaScriptInMainFrame):
+        (WKPageRunJavaScriptInMainFrame_b):
+        (WKPageRenderTreeExternalRepresentation):
+        (WKPageGetSourceForFrame):
+        (WKPageGetContentsAsString):
+        (WKPageGetBytecodeProfile):
+        (WKPageGetSamplingProfilerOutput):
+        (WKPageGetSelectionAsWebArchiveData):
+        (WKPageGetContentsAsMHTMLData):
+        (WKPageForceRepaint):
+        (WKPageValidateCommand):
+        (WKPageExecuteCommand):
+        (WKPageComputePagesForPrinting):
+        (WKPageDrawPagesToPDF):
+        (WKPageBeginPrinting):
+        (WKPageEndPrinting):
+        (WKPageSetControlledByAutomation):
+        (WKPageSetAllowsRemoteInspection):
+        (WKPageSetMediaVolume):
+        (WKPageSetMuted):
+        (WKPageSetMediaCaptureEnabled):
+        (WKPageDidAllowPointerLock):
+        (WKPageClearUserMediaState):
+        (WKPageDidDenyPointerLock):
+        (WKPageSetMayStartMediaWhenInWindow):
+        (WKPageSelectContextMenuItem):
+        (WKPageSetScrollPinningBehavior):
+        (WKPageSetAddsVisitedLinks):
+        (WKPageClearWheelEventTestMonitor):
+        (WKPageCallAfterNextPresentationUpdate):
+        (WKPageSetIgnoresViewportScaleLimits):
+        (WKPageGetApplicationManifest_b):
+        (WKPageDumpPrivateClickMeasurement):
+        (WKPageClearPrivateClickMeasurement):
+        (WKPageSetPrivateClickMeasurementOverrideTimerForTesting):
+        (WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTesting):
+        (WKPageSimulateResourceLoadStatisticsSessionRestart):
+        (WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting):
+        (WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting):
+        (WKPageSetPrivateClickMeasurementAttributionReportURLsForTesting):
+        (WKPageMarkPrivateClickMeasurementsAsExpiredForTesting):
+        (WKPageSetPCMFraudPreventionValuesForTesting):
+        (WKPageSetMockCameraOrientation):
+        (WKPageLoadedSubresourceDomains):
+        (WKPageClearLoadedSubresourceDomains):
+        (WKPageSetMediaCaptureReportingDelayForTesting):
+        (WKPageDispatchActivityStateUpdateForTesting):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView loadRequest:]):
+        (-[WKWebView loadFileURL:allowingReadAccessToURL:]):
+        (-[WKWebView loadHTMLString:baseURL:]):
+        (-[WKWebView loadData:MIMEType:characterEncodingName:baseURL:]):
+        (-[WKWebView startDownloadUsingRequest:completionHandler:]):
+        (-[WKWebView resumeDownloadFromResumeData:completionHandler:]):
+        (-[WKWebView goToBackForwardListItem:]):
+        (-[WKWebView goBack]):
+        (-[WKWebView goForward]):
+        (-[WKWebView reload]):
+        (-[WKWebView reloadFromOrigin]):
+        (-[WKWebView stopLoading]):
+        (-[WKWebView evaluateJavaScript:completionHandler:]):
+        (-[WKWebView evaluateJavaScript:inFrame:inContentWorld:completionHandler:]):
+        (-[WKWebView callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]):
+        (-[WKWebView closeAllMediaPresentationsWithCompletionHandler:]):
+        (-[WKWebView pauseAllMediaPlaybackWithCompletionHandler:]):
+        (-[WKWebView setAllMediaPlaybackSuspended:completionHandler:]):
+        (-[WKWebView requestMediaPlaybackStateWithCompletionHandler:]):
+        (-[WKWebView setMicrophoneCaptureState:completionHandler:]):
+        (-[WKWebView setCameraCaptureState:completionHandler:]):
+        (-[WKWebView _evaluateJavaScript:asAsyncFunction:withSourceURL:withArguments:forceUserGesture:inFrame:inWorld:completionHandler:]):
+        (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+        (-[WKWebView setAllowsBackForwardNavigationGestures:]):
+        (-[WKWebView setCustomUserAgent:]):
+        (-[WKWebView setAllowsLinkPreview:]):
+        (-[WKWebView setPageZoom:]):
+        (-[WKWebView findString:withConfiguration:completionHandler:]):
+        (-[WKWebView setMediaType:]):
+        (-[WKWebView setInteractionState:]):
+        (-[WKWebView setAllowsMagnification:]):
+        (-[WKWebView setMagnification:centeredAtPoint:]):
+        (-[WKWebView setMagnification:]):
+        (-[WKWebView printOperationWithPrintInfo:]):
+        (-[WKWebView createPDFWithConfiguration:completionHandler:]):
+        (-[WKWebView createWebArchiveDataWithCompletionHandler:]):
+        (-[WKWebView loadSimulatedRequest:response:responseData:]):
+        (-[WKWebView loadSimulatedRequest:withResponse:responseData:]):
+        (-[WKWebView loadSimulatedRequest:responseHTMLString:]):
+        (-[WKWebView loadSimulatedRequest:withResponseHTMLString:]):
+        (-[WKWebView loadFileRequest:allowingReadAccessToURL:]):
+        (-[WKWebView _toggleStrikeThrough:]):
+        (-[WKWebView _increaseListLevel:]):
+        (-[WKWebView _decreaseListLevel:]):
+        (-[WKWebView _changeListType:]):
+        (-[WKWebView _setViewportSizeForCSSViewportUnits:]):
+        (-[WKWebView _didEnableBrowserExtensions:]):
+        (-[WKWebView _didDisableBrowserExtensions:]):
+        (-[WKWebView _setEditable:]):
+        (-[WKWebView _executeEditCommand:argument:completion:]):
+        (-[WKWebView _startTextManipulationsWithConfiguration:completion:]):
+        (-[WKWebView _completeTextManipulation:completion:]):
+        (-[WKWebView _completeTextManipulationForItems:completion:]):
+        (-[WKWebView _takeFindStringFromSelection:]):
+        (-[WKWebView _updateMediaPlaybackControlsManager]):
+        (-[WKWebView _togglePictureInPicture]):
+        (-[WKWebView _closeAllMediaPresentations]):
+        (-[WKWebView _stopMediaCapture]):
+        (-[WKWebView _stopAllMediaPlayback]):
+        (-[WKWebView _suspendAllMediaPlayback]):
+        (-[WKWebView _resumeAllMediaPlayback]):
+        (-[WKWebView _restoreAppHighlights:]):
+        (-[WKWebView _restoreAndScrollToAppHighlight:]):
+        (-[WKWebView _addAppHighlight]):
+        (-[WKWebView _loadAlternateHTMLString:baseURL:forUnreachableURL:]):
+        (-[WKWebView _loadData:MIMEType:characterEncodingName:baseURL:userData:]):
+        (-[WKWebView _loadRequest:shouldOpenExternalURLs:]):
+        (-[WKWebView _loadRequest:shouldOpenExternalURLsPolicy:]):
+        (-[WKWebView _grantAccessToAssetServices]):
+        (-[WKWebView _revokeAccessToAssetServices]):
+        (-[WKWebView _switchFromStaticFontRegistryToUserFontRegistry]):
+        (-[WKWebView _appBoundNavigationDataForDomain:completionHandler:]):
+        (-[WKWebView _suspendPage:]):
+        (-[WKWebView _resumePage:]):
+        (-[WKWebView _setApplicationNameForUserAgent:]):
+        (-[WKWebView _killWebContentProcess]):
+        (-[WKWebView _reloadWithoutContentBlockers]):
+        (-[WKWebView _reloadExpiredOnly]):
+        (-[WKWebView _killWebContentProcessAndResetState]):
+        (-[WKWebView _takePDFSnapshotWithConfiguration:completionHandler:]):
+        (-[WKWebView _getPDFFirstPageSizeInFrame:completionHandler:]):
+        (-[WKWebView _restoreFromSessionStateData:]):
+        (-[WKWebView _restoreSessionState:andNavigate:]):
+        (-[WKWebView _close]):
+        (-[WKWebView _tryClose]):
+        (-[WKWebView _insertAttachmentWithFilename:contentType:data:options:completion:]):
+        (-[WKWebView _insertAttachmentWithFileWrapper:contentType:options:completion:]):
+        (-[WKWebView _insertAttachmentWithFileWrapper:contentType:completion:]):
+        (-[WKWebView _attachmentForIdentifier:]):
+        (-[WKWebView _simulateDeviceOrientationChangeWithAlpha:beta:gamma:]):
+        (-[WKWebView _showSafeBrowsingWarningWithTitle:warning:details:completionHandler:]):
+        (-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:details:completionHandler:]):
+        (-[WKWebView _showSafeBrowsingWarningWithURL:title:warning:detailsWithLinks:completionHandler:]):
+        (-[WKWebView _isJITEnabled:]):
+        (-[WKWebView _evaluateJavaScriptWithoutUserGesture:completionHandler:]):
+        (-[WKWebView _callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:]):
+        (-[WKWebView _evaluateJavaScript:inFrame:inContentWorld:completionHandler:]):
+        (-[WKWebView _evaluateJavaScript:withSourceURL:inFrame:inContentWorld:completionHandler:]):
+        (-[WKWebView _updateWebpagePreferences:]):
+        (-[WKWebView _notifyUserScripts]):
+        (-[WKWebView _deferrableUserScriptsNeedNotification]):
+        (-[WKWebView _setAllowsRemoteInspection:]):
+        (-[WKWebView _setRemoteInspectionNameOverride:]):
+        (-[WKWebView _setAddsVisitedLinks:]):
+        (-[WKWebView _getMainResourceDataWithCompletionHandler:]):
+        (-[WKWebView _getWebArchiveDataWithCompletionHandler:]):
+        (-[WKWebView _getContentsAsStringWithCompletionHandler:]):
+        (-[WKWebView _getContentsOfAllFramesAsStringWithCompletionHandler:]):
+        (-[WKWebView _getContentsAsAttributedStringWithCompletionHandler:]):
+        (-[WKWebView _getApplicationManifestWithCompletionHandler:]):
+        (-[WKWebView _setPaginationMode:]):
+        (-[WKWebView _setPaginationBehavesLikeColumns:]):
+        (-[WKWebView _setPageLength:]):
+        (-[WKWebView _setGapBetweenPages:]):
+        (-[WKWebView _setPaginationLineGridEnabled:]):
+        (-[WKWebView _setTextZoomFactor:]):
+        (-[WKWebView _setPageZoomFactor:]):
+        (-[WKWebView _countStringMatches:options:maxCount:]):
+        (-[WKWebView _findString:options:maxCount:]):
+        (-[WKWebView _hideFindUI]):
+        (-[WKWebView _saveBackForwardSnapshotForItem:]):
+        (-[WKWebView _clearServiceWorkerEntitlementOverride:]):
+        (-[WKWebView _preconnectToServer:]):
+        (-[WKWebView _setCanUseCredentialStorage:]):
+        (-[WKWebView _setLayoutMode:]):
+        (-[WKWebView _setFixedLayoutSize:]):
+        (-[WKWebView _setBackgroundExtendsBeyondPage:]):
+        (-[WKWebView _setViewScale:]):
+        (-[WKWebView _setCORSDisablingPatterns:]):
+        (-[WKWebView _getProcessDisplayNameWithCompletionHandler:]):
+        (-[WKWebView _setMinimumEffectiveDeviceWidth:]):
+        (-[WKWebView _grantAccessToPreferenceService]):
+        (-[WKWebView _setScrollPerformanceDataCollectionEnabled:]):
+        (-[WKWebView _setAllowsMediaDocumentInlinePlayback:]):
+        (-[WKWebView _setMediaCaptureEnabled:]):
+        (-[WKWebView _setPageMuted:]):
+        (-[WKWebView _removeDataDetectedLinks:]):
+        (-[WKWebView _doAfterNextPresentationUpdate:]):
+        (-[WKWebView _doAfterNextPresentationUpdateWithoutWaitingForPainting:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::handleTouchEvent):
+        (WebKit::WebPageProxy::resumeActiveDOMObjectsAndAnimations):
+        (WebKit::WebPageProxy::suspendActiveDOMObjectsAndAnimations):
+        (WebKit::WebPageProxy::suspend):
+        (WebKit::WebPageProxy::resume):
+        (WebKit::WebPageProxy::requestMediaPlaybackState):
+        (WebKit::WebPageProxy::resetStateAfterProcessExited):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::suspend):
+        (WebKit::WebPage::resume):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
</ins><span class="cx"> 2021-05-11  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove the String::toInt family of functions
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp   2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp      2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -143,6 +143,15 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><ins>+NO_RETURN_DUE_TO_CRASH NEVER_INLINE static void crashBecausePageIsSuspended()
+{
+    WTFLogAlways("Error: Attempt to call WKPageRef API/SPI on a suspended page, this is a client bug.");
+    CRASH();
+}
+
+#define CRASH_IF_SUSPENDED if (UNLIKELY(pageRef && toImpl(pageRef)->isSuspended())) \
+    crashBecausePageIsSuspended()
+
</ins><span class="cx"> WKTypeID WKPageGetTypeID()
</span><span class="cx"> {
</span><span class="cx">     return toAPI(WebPageProxy::APIType);
</span><span class="lines">@@ -165,11 +174,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef pageRef, WKURLRef URLRef, bool shouldOpenExternalURLs)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy = shouldOpenExternalURLs ? WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow : WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
</span><span class="cx">     toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)), shouldOpenExternalURLsPolicy);
</span><span class="cx"> }
</span><span class="lines">@@ -176,11 +187,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadURLWithUserData(WKPageRef pageRef, WKURLRef URLRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)), WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow, toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     auto resourceRequest = toImpl(urlRequestRef)->resourceRequest();
</span><span class="cx">     toImpl(pageRef)->loadRequest(WTFMove(resourceRequest));
</span><span class="cx"> }
</span><span class="lines">@@ -187,6 +200,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadURLRequestWithUserData(WKPageRef pageRef, WKURLRequestRef urlRequestRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     auto resourceRequest = toImpl(urlRequestRef)->resourceRequest();
</span><span class="cx">     toImpl(pageRef)->loadRequest(WTFMove(resourceRequest), WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow, toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="lines">@@ -193,21 +207,25 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadFile(WKPageRef pageRef, WKURLRef fileURL, WKURLRef resourceDirectoryURL)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadFile(toWTFString(fileURL), toWTFString(resourceDirectoryURL));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadFileWithUserData(WKPageRef pageRef, WKURLRef fileURL, WKURLRef resourceDirectoryURL, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadFile(toWTFString(fileURL), toWTFString(resourceDirectoryURL), toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadData(WKPageRef pageRef, WKDataRef dataRef, WKStringRef MIMETypeRef, WKStringRef encodingRef, WKURLRef baseURLRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadData(toImpl(dataRef)->dataReference(), toWTFString(MIMETypeRef), toWTFString(encodingRef), toWTFString(baseURLRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadDataWithUserData(WKPageRef pageRef, WKDataRef dataRef, WKStringRef MIMETypeRef, WKStringRef encodingRef, WKURLRef baseURLRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadData(toImpl(dataRef)->dataReference(), toWTFString(MIMETypeRef), toWTFString(encodingRef), toWTFString(baseURLRef), toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -233,21 +251,25 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WKPageLoadHTMLStringWithUserData(pageRef, htmlStringRef, baseURLRef, nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadHTMLStringWithUserData(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     loadString(pageRef, htmlStringRef, "text/html"_s, toWTFString(baseURLRef), userDataRef);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadAlternateHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WKPageLoadAlternateHTMLStringWithUserData(pageRef, htmlStringRef, baseURLRef, unreachableURLRef, nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadAlternateHTMLStringWithUserData(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     String string = toWTFString(htmlStringRef);
</span><span class="cx">     toImpl(pageRef)->loadAlternateHTML(dataFrom(string), encodingOf(string), URL(URL(), toWTFString(baseURLRef)), URL(URL(), toWTFString(unreachableURLRef)), toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="lines">@@ -254,31 +276,37 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadPlainTextString(WKPageRef pageRef, WKStringRef plainTextStringRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WKPageLoadPlainTextStringWithUserData(pageRef, plainTextStringRef, nullptr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadPlainTextStringWithUserData(WKPageRef pageRef, WKStringRef plainTextStringRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     loadString(pageRef, plainTextStringRef, "text/plain"_s, aboutBlankURL().string(), userDataRef);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadWebArchiveData(WKPageRef pageRef, WKDataRef webArchiveDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadWebArchiveData(toImpl(webArchiveDataRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageLoadWebArchiveDataWithUserData(WKPageRef pageRef, WKDataRef webArchiveDataRef, WKTypeRef userDataRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->loadWebArchiveData(toImpl(webArchiveDataRef), toImpl(userDataRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageStopLoading(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->stopLoading();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageReload(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     OptionSet<WebCore::ReloadOption> reloadOptions;
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     if (linkedOnOrAfter(WebCore::SDKVersion::FirstWithExpiredOnlyReloadBehavior))
</span><span class="lines">@@ -290,21 +318,25 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageReloadWithoutContentBlockers(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->reload(WebCore::ReloadOption::DisableContentBlockers);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageReloadFromOrigin(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->reload(WebCore::ReloadOption::FromOrigin);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageReloadExpiredOnly(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->reload(WebCore::ReloadOption::ExpiredOnly);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageTryClose(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     return toImpl(pageRef)->tryClose();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -320,6 +352,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageGoForward(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->goForward();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -330,6 +363,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageGoBack(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     auto& page = *toImpl(pageRef);
</span><span class="cx">     if (page.pageClient().hasSafeBrowsingWarning()) {
</span><span class="cx">         WKPageReload(pageRef);
</span><span class="lines">@@ -345,11 +379,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageGoToBackForwardListItem(WKPageRef pageRef, WKBackForwardListItemRef itemRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->goToBackForwardItem(*toImpl(itemRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageTryRestoreScrollPosition(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->tryRestoreScrollPosition();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -365,6 +401,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageUpdateWebsitePolicies(WKPageRef pageRef, WKWebsitePoliciesRef websitePoliciesRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->websiteDataStore(), "Setting WebsitePolicies.websiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
</span><span class="cx">     RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->userContentController(), "Setting WebsitePolicies.userContentController is only supported during WKFramePolicyListenerUseWithPolicies().");
</span><span class="cx">     auto data = toImpl(websitePoliciesRef)->data();
</span><span class="lines">@@ -423,6 +460,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetApplicationNameForUserAgent(WKPageRef pageRef, WKStringRef applicationNameRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setApplicationNameForUserAgent(toWTFString(applicationNameRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -433,6 +471,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetCustomUserAgent(WKPageRef pageRef, WKStringRef userAgentRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setCustomUserAgent(toWTFString(userAgentRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -453,11 +492,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetCustomTextEncodingName(WKPageRef pageRef, WKStringRef encodingNameRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setCustomTextEncodingName(toWTFString(encodingNameRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageTerminate(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     Ref<WebProcessProxy> protectedProcessProxy(toImpl(pageRef)->process());
</span><span class="cx">     protectedProcessProxy->requestTermination(ProcessTerminationReason::RequestedByClient);
</span><span class="cx"> }
</span><span class="lines">@@ -518,11 +559,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageRestoreFromSessionState(WKPageRef pageRef, WKTypeRef sessionStateRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     restoreFromSessionState(pageRef, sessionStateRef, true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef pageRef, WKTypeRef sessionStateRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     restoreFromSessionState(pageRef, sessionStateRef, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -538,6 +581,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetCustomBackingScaleFactor(WKPageRef pageRef, double customScaleFactor)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setCustomDeviceScaleFactor(customScaleFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -548,6 +592,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetTextZoomFactor(WKPageRef pageRef, double zoomFactor)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setTextZoomFactor(zoomFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -558,16 +603,19 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageZoomFactor(WKPageRef pageRef, double zoomFactor)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setPageZoomFactor(zoomFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, double textZoomFactor)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetScaleFactor(WKPageRef pageRef, double scale, WKPoint origin)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->scalePage(scale, toIntPoint(origin));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -578,11 +626,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetUseFixedLayout(WKPageRef pageRef, bool fixed)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setUseFixedLayout(fixed);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetFixedLayoutSize(WKPageRef pageRef, WKSize size)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setFixedLayoutSize(toIntSize(size));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -598,6 +648,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageListenForLayoutMilestones(WKPageRef pageRef, WKLayoutMilestones milestones)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->listenForLayoutMilestones(toLayoutMilestones(milestones));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -613,6 +664,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetSuppressScrollbarAnimations(WKPageRef pageRef, bool suppressAnimations)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setSuppressScrollbarAnimations(suppressAnimations);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -648,6 +700,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetRubberBandsAtLeft(WKPageRef pageRef, bool rubberBandsAtLeft)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setRubberBandsAtLeft(rubberBandsAtLeft);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -658,6 +711,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetRubberBandsAtRight(WKPageRef pageRef, bool rubberBandsAtRight)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setRubberBandsAtRight(rubberBandsAtRight);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -668,6 +722,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetRubberBandsAtTop(WKPageRef pageRef, bool rubberBandsAtTop)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setRubberBandsAtTop(rubberBandsAtTop);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -678,6 +733,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetRubberBandsAtBottom(WKPageRef pageRef, bool rubberBandsAtBottom)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setRubberBandsAtBottom(rubberBandsAtBottom);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -688,6 +744,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetEnableVerticalRubberBanding(WKPageRef pageRef, bool enableVerticalRubberBanding)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setEnableVerticalRubberBanding(enableVerticalRubberBanding);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -698,11 +755,13 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetEnableHorizontalRubberBanding(WKPageRef pageRef, bool enableHorizontalRubberBanding)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setEnableHorizontalRubberBanding(enableHorizontalRubberBanding);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetBackgroundExtendsBeyondPage(WKPageRef pageRef, bool backgroundExtendsBeyondPage)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setBackgroundExtendsBeyondPage(backgroundExtendsBeyondPage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -713,6 +772,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPaginationMode(WKPageRef pageRef, WKPaginationMode paginationMode)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WebCore::Pagination::Mode mode;
</span><span class="cx">     switch (paginationMode) {
</span><span class="cx">     case kWKPaginationModeUnpaginated:
</span><span class="lines">@@ -757,6 +817,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPaginationBehavesLikeColumns(WKPageRef pageRef, bool behavesLikeColumns)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setPaginationBehavesLikeColumns(behavesLikeColumns);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -767,6 +828,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageLength(WKPageRef pageRef, double pageLength)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setPageLength(pageLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -777,6 +839,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetGapBetweenPages(WKPageRef pageRef, double gap)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setGapBetweenPages(gap);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -787,6 +850,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPaginationLineGridEnabled(WKPageRef pageRef, bool lineGridEnabled)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setPaginationLineGridEnabled(lineGridEnabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -817,46 +881,55 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetMaintainsInactiveSelection(WKPageRef pageRef, bool newValue)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     return toImpl(pageRef)->setMaintainsInactiveSelection(newValue);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageCenterSelectionInVisibleArea(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     return toImpl(pageRef)->centerSelectionInVisibleArea();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageFindStringMatches(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->findStringMatches(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetImageForFindMatch(WKPageRef pageRef, int32_t matchIndex)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getImageForFindMatch(matchIndex);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSelectFindMatch(WKPageRef pageRef, int32_t matchIndex)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->selectFindMatch(matchIndex);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageHideFindUI(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->hideFindUI();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageCountStringMatches(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->countStringMatches(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageContextMenuClient(WKPageRef pageRef, const WKPageContextMenuClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><span class="cx">     class ContextMenuClient final : public API::Client<WKPageContextMenuClientBase>, public API::ContextMenuClient {
</span><span class="cx">     public:
</span><span class="lines">@@ -973,6 +1046,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageFindClient(WKPageRef pageRef, const WKPageFindClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class FindClient : public API::Client<WKPageFindClientBase>, public API::FindClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit FindClient(const WKPageFindClientBase* client)
</span><span class="lines">@@ -1011,6 +1085,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageFindMatchesClient(WKPageRef pageRef, const WKPageFindMatchesClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class FindMatchesClient : public API::Client<WKPageFindMatchesClientBase>, public API::FindMatchesClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit FindMatchesClient(const WKPageFindMatchesClientBase* client)
</span><span class="lines">@@ -1054,16 +1129,19 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageInjectedBundleClient(WKPageRef pageRef, const WKPageInjectedBundleClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setInjectedBundleClient(wkClient);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setFormClient(makeUnique<WebFormClient>(wkClient));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageLoaderClient(WKPageRef pageRef, const WKPageLoaderClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class LoaderClient : public API::Client<WKPageLoaderClientBase>, public API::LoaderClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit LoaderClient(const WKPageLoaderClientBase* client)
</span><span class="lines">@@ -1234,6 +1312,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPagePolicyClient(WKPageRef pageRef, const WKPagePolicyClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class PolicyClient : public API::Client<WKPagePolicyClientBase>, public API::PolicyClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit PolicyClient(const WKPagePolicyClientBase* client)
</span><span class="lines">@@ -1493,6 +1572,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class UIClient : public API::Client<WKPageUIClientBase>, public API::UIClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit UIClient(const WKPageUIClientBase* client)
</span><span class="lines">@@ -2138,6 +2218,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetPageNavigationClient(WKPageRef pageRef, const WKPageNavigationClientBase* wkClient)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     class NavigationClient : public API::Client<WKPageNavigationClientBase>, public API::NavigationClient {
</span><span class="cx">     public:
</span><span class="cx">         explicit NavigationClient(const WKPageNavigationClientBase* client)
</span><span class="lines">@@ -2503,16 +2584,18 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-void WKPageSetPageStateClient(WKPageRef page, WKPageStateClientBase* client)
</del><ins>+void WKPageSetPageStateClient(WKPageRef pageRef, WKPageStateClientBase* client)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     if (client)
</span><del>-        toImpl(page)->setPageLoadStateObserver(makeUnique<StateClient>(client));
</del><ins>+        toImpl(pageRef)->setPageLoadStateObserver(makeUnique<StateClient>(client));
</ins><span class="cx">     else
</span><del>-        toImpl(page)->setPageLoadStateObserver(nullptr);
</del><ins>+        toImpl(pageRef)->setPageLoadStateObserver(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->runJavaScriptInMainFrame({ toImpl(scriptRef)->string(), URL { }, false, WTF::nullopt, true }, [context, callback] (auto&& result) {
</span><span class="cx">         if (result.has_value())
</span><span class="cx">             callback(toAPI(result.value().get()), nullptr, context);
</span><span class="lines">@@ -2531,6 +2614,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageRunJavaScriptInMainFrame_b(WKPageRef pageRef, WKStringRef scriptRef, WKPageRunJavaScriptBlock block)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WKPageRunJavaScriptInMainFrame(pageRef, scriptRef, Block_copy(block), callRunJavaScriptBlockAndRelease);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -2544,31 +2628,37 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getRenderTreeExternalRepresentation(toStringCallback(context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), toStringCallback(context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getContentsAsString(ContentAsStringIncludesChildFrames::No, toStringCallback(context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecodeProfileFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getBytecodeProfile(toStringCallback(context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetSamplingProfilerOutput(WKPageRef pageRef, void* context, WKPageGetSamplingProfilerOutputFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getSamplingProfilerOutput(toStringCallback(context, callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->getSelectionAsWebArchiveData([context, callback] (API::Data* data) {
</span><span class="cx">         callback(toAPI(data), nullptr, context);
</span><span class="cx">     });
</span><span class="lines">@@ -2576,6 +2666,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageGetContentsAsMHTMLData(WKPageRef pageRef, void* context, WKPageGetContentsAsMHTMLDataFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(MHTML)
</span><span class="cx">     toImpl(pageRef)->getContentsAsMHTMLData([context, callback] (API::Data* data) {
</span><span class="cx">         callback(toAPI(data), nullptr, context);
</span><span class="lines">@@ -2589,6 +2680,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->forceRepaint([context, callback]() {
</span><span class="cx">         callback(nullptr, context);
</span><span class="cx">     });
</span><span class="lines">@@ -2626,6 +2718,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     auto commandName = toImpl(command)->string();
</span><span class="cx">     toImpl(pageRef)->validateCommand(commandName, [context, callback, commandName](bool isEnabled, int32_t state) {
</span><span class="cx">         callback(toAPI(API::String::create(commandName).ptr()), isEnabled, state, nullptr, context);
</span><span class="lines">@@ -2634,6 +2727,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageExecuteCommand(WKPageRef pageRef, WKStringRef command)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->executeEditCommand(toImpl(command)->string());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2646,9 +2740,10 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
</del><ins>+void WKPageComputePagesForPrinting(WKPageRef pageRef, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), [context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, const WebCore::FloatBoxExtent& computedPageMargin) {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), [context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, const WebCore::FloatBoxExtent& computedPageMargin) {
</ins><span class="cx">         Vector<WKRect> wkRects(rects.size());
</span><span class="cx">         for (size_t i = 0; i < rects.size(); ++i)
</span><span class="cx">             wkRects[i] = toAPI(rects[i]);
</span><span class="lines">@@ -2657,22 +2752,25 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><del>-void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
</del><ins>+void WKPageDrawPagesToPDF(WKPageRef pageRef, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, [context, callback] (API::Data* data) {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, [context, callback] (API::Data* data) {
</ins><span class="cx">         callback(toAPI(data), nullptr, context);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo)
</del><ins>+void WKPageBeginPrinting(WKPageRef pageRef, WKFrameRef frame, WKPrintInfo printInfo)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo));
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageEndPrinting(WKPageRef page)
</del><ins>+void WKPageEndPrinting(WKPageRef pageRef)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->endPrinting();
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->endPrinting();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageGetIsControlledByAutomation(WKPageRef page)
</span><span class="lines">@@ -2680,9 +2778,10 @@
</span><span class="cx">     return toImpl(page)->isControlledByAutomation();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetControlledByAutomation(WKPageRef page, bool controlled)
</del><ins>+void WKPageSetControlledByAutomation(WKPageRef pageRef, bool controlled)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setControlledByAutomation(controlled);
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setControlledByAutomation(controlled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageGetAllowsRemoteInspection(WKPageRef page)
</span><span class="lines">@@ -2695,23 +2794,26 @@
</span><span class="cx"> #endif    
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetAllowsRemoteInspection(WKPageRef page, bool allow)
</del><ins>+void WKPageSetAllowsRemoteInspection(WKPageRef pageRef, bool allow)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><del>-    toImpl(page)->setAllowsRemoteInspection(allow);
</del><ins>+    toImpl(pageRef)->setAllowsRemoteInspection(allow);
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx">     UNUSED_PARAM(allow);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetMediaVolume(WKPageRef page, float volume)
</del><ins>+void WKPageSetMediaVolume(WKPageRef pageRef, float volume)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setMediaVolume(volume);    
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setMediaVolume(volume);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetMuted(WKPageRef page, WKMediaMutedState mutedState)
</del><ins>+void WKPageSetMuted(WKPageRef pageRef, WKMediaMutedState mutedState)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     WebCore::MediaProducer::MutedStateFlags coreState;
</span><span class="cx"> 
</span><span class="cx">     if (mutedState & kWKMediaAudioMuted)
</span><span class="lines">@@ -2721,12 +2823,13 @@
</span><span class="cx">     if (mutedState & kWKMediaScreenCaptureMuted)
</span><span class="cx">         coreState.add(WebCore::MediaProducer::MutedState::ScreenCaptureIsMuted);
</span><span class="cx"> 
</span><del>-    toImpl(page)->setMuted(coreState);
</del><ins>+    toImpl(pageRef)->setMuted(coreState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled)
</del><ins>+void WKPageSetMediaCaptureEnabled(WKPageRef pageRef, bool enabled)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setMediaCaptureEnabled(enabled);
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setMediaCaptureEnabled(enabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageGetMediaCaptureEnabled(WKPageRef page)
</span><span class="lines">@@ -2734,30 +2837,33 @@
</span><span class="cx">     return toImpl(page)->mediaCaptureEnabled();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageDidAllowPointerLock(WKPageRef page)
</del><ins>+void WKPageDidAllowPointerLock(WKPageRef pageRef)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><del>-    toImpl(page)->didAllowPointerLock();
</del><ins>+    toImpl(pageRef)->didAllowPointerLock();
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageClearUserMediaState(WKPageRef page)
</del><ins>+void WKPageClearUserMediaState(WKPageRef pageRef)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><del>-    toImpl(page)->clearUserMediaState();
</del><ins>+    toImpl(pageRef)->clearUserMediaState();
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageDidDenyPointerLock(WKPageRef page)
</del><ins>+void WKPageDidDenyPointerLock(WKPageRef pageRef)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(POINTER_LOCK)
</span><del>-    toImpl(page)->didDenyPointerLock();
</del><ins>+    toImpl(pageRef)->didDenyPointerLock();
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2790,16 +2896,18 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageSetMayStartMediaWhenInWindow(WKPageRef pageRef, bool mayStartMedia)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->setMayStartMediaWhenInWindow(mayStartMedia);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-void WKPageSelectContextMenuItem(WKPageRef page, WKContextMenuItemRef item)
</del><ins>+void WKPageSelectContextMenuItem(WKPageRef pageRef, WKContextMenuItemRef item)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(CONTEXT_MENUS)
</span><del>-    toImpl(page)->contextMenuItemSelected((toImpl(item)->data()));
</del><ins>+    toImpl(pageRef)->contextMenuItemSelected((toImpl(item)->data()));
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx">     UNUSED_PARAM(item);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -2821,8 +2929,9 @@
</span><span class="cx">     return kWKScrollPinningBehaviorDoNotPin;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetScrollPinningBehavior(WKPageRef page, WKScrollPinningBehavior pinning)
</del><ins>+void WKPageSetScrollPinningBehavior(WKPageRef pageRef, WKScrollPinningBehavior pinning)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     ScrollPinningBehavior corePinning = ScrollPinningBehavior::DoNotPin;
</span><span class="cx"> 
</span><span class="cx">     switch (pinning) {
</span><span class="lines">@@ -2839,7 +2948,7 @@
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    toImpl(page)->setScrollPinningBehavior(corePinning);
</del><ins>+    toImpl(pageRef)->setScrollPinningBehavior(corePinning);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageGetAddsVisitedLinks(WKPageRef page)
</span><span class="lines">@@ -2847,9 +2956,10 @@
</span><span class="cx">     return toImpl(page)->addsVisitedLinks();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetAddsVisitedLinks(WKPageRef page, bool addsVisitedLinks)
</del><ins>+void WKPageSetAddsVisitedLinks(WKPageRef pageRef, bool addsVisitedLinks)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setAddsVisitedLinks(addsVisitedLinks);
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setAddsVisitedLinks(addsVisitedLinks);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WKPageIsPlayingAudio(WKPageRef page)
</span><span class="lines">@@ -2884,20 +2994,23 @@
</span><span class="cx"> 
</span><span class="cx"> void WKPageClearWheelEventTestMonitor(WKPageRef pageRef)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->clearWheelEventTestMonitor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKPageCallAfterNextPresentationUpdate(WKPageRef pageRef, void* context, WKPagePostPresentationUpdateFunction callback)
</span><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx">     toImpl(pageRef)->callAfterNextPresentationUpdate([context, callback](WebKit::CallbackBase::Error error) {
</span><span class="cx">         callback(error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits)
</del><ins>+void WKPageSetIgnoresViewportScaleLimits(WKPageRef pageRef, bool ignoresViewportScaleLimits)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(META_VIEWPORT)
</span><del>-    toImpl(page)->setForceAlwaysUserScalable(ignoresViewportScaleLimits);
</del><ins>+    toImpl(pageRef)->setForceAlwaysUserScalable(ignoresViewportScaleLimits);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2907,93 +3020,105 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #ifdef __BLOCKS__
</span><del>-void WKPageGetApplicationManifest_b(WKPageRef page, WKPageGetApplicationManifestBlock block)
</del><ins>+void WKPageGetApplicationManifest_b(WKPageRef pageRef, WKPageGetApplicationManifestBlock block)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(APPLICATION_MANIFEST)
</span><del>-    toImpl(page)->getApplicationManifest([block](const Optional<WebCore::ApplicationManifest>& manifest) {
</del><ins>+    toImpl(pageRef)->getApplicationManifest([block](const Optional<WebCore::ApplicationManifest>& manifest) {
</ins><span class="cx">         block();
</span><span class="cx">     });
</span><span class="cx"> #else // ENABLE(APPLICATION_MANIFEST)
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx">     block();
</span><span class="cx"> #endif // not ENABLE(APPLICATION_MANIFEST)
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WKPageDumpPrivateClickMeasurement(WKPageRef page, WKPageDumpPrivateClickMeasurementFunction callback, void* callbackContext)
</del><ins>+void WKPageDumpPrivateClickMeasurement(WKPageRef pageRef, WKPageDumpPrivateClickMeasurementFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->dumpPrivateClickMeasurement([callbackContext, callback] (const String& privateClickMeasurement) {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->dumpPrivateClickMeasurement([callbackContext, callback] (const String& privateClickMeasurement) {
</ins><span class="cx">         callback(WebKit::toAPI(privateClickMeasurement.impl()), callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageClearPrivateClickMeasurement(WKPageRef page, WKPageClearPrivateClickMeasurementFunction callback, void* callbackContext)
</del><ins>+void WKPageClearPrivateClickMeasurement(WKPageRef pageRef, WKPageClearPrivateClickMeasurementFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->clearPrivateClickMeasurement([callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->clearPrivateClickMeasurement([callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetPrivateClickMeasurementOverrideTimerForTesting(WKPageRef page, bool value, WKPageSetPrivateClickMeasurementOverrideTimerForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageSetPrivateClickMeasurementOverrideTimerForTesting(WKPageRef pageRef, bool value, WKPageSetPrivateClickMeasurementOverrideTimerForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setPrivateClickMeasurementOverrideTimerForTesting(value, [callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setPrivateClickMeasurementOverrideTimerForTesting(value, [callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTesting(WKPageRef page, WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTesting(WKPageRef pageRef, WKPageMarkAttributedPrivateClickMeasurementsAsExpiredForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->markAttributedPrivateClickMeasurementsAsExpiredForTesting([callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->markAttributedPrivateClickMeasurementsAsExpiredForTesting([callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSimulateResourceLoadStatisticsSessionRestart(WKPageRef page, WKPageSimulateResourceLoadStatisticsSessionRestartFunction callback, void* callbackContext)
</del><ins>+void WKPageSimulateResourceLoadStatisticsSessionRestart(WKPageRef pageRef, WKPageSimulateResourceLoadStatisticsSessionRestartFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->simulateResourceLoadStatisticsSessionRestart([callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->simulateResourceLoadStatisticsSessionRestart([callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting(WKPageRef page, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTesting(WKPageRef pageRef, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenPublicKeyURLForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setPrivateClickMeasurementTokenPublicKeyURLForTesting(URL(URL(), toWTFString(URLRef)), [callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setPrivateClickMeasurementTokenPublicKeyURLForTesting(URL(URL(), toWTFString(URLRef)), [callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting(WKPageRef page, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenSignatureURLForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageSetPrivateClickMeasurementTokenSignatureURLForTesting(WKPageRef pageRef, WKURLRef URLRef, WKPageSetPrivateClickMeasurementTokenSignatureURLForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setPrivateClickMeasurementTokenSignatureURLForTesting(URL(URL(), toWTFString(URLRef)), [callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setPrivateClickMeasurementTokenSignatureURLForTesting(URL(URL(), toWTFString(URLRef)), [callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetPrivateClickMeasurementAttributionReportURLsForTesting(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKPageSetPrivateClickMeasurementAttributionReportURLsForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageSetPrivateClickMeasurementAttributionReportURLsForTesting(WKPageRef pageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKPageSetPrivateClickMeasurementAttributionReportURLsForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setPrivateClickMeasurementAttributionReportURLsForTesting(URL(URL(), toWTFString(sourceURL)), URL(URL(), toWTFString(destinationURL)), [callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setPrivateClickMeasurementAttributionReportURLsForTesting(URL(URL(), toWTFString(sourceURL)), URL(URL(), toWTFString(destinationURL)), [callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageMarkPrivateClickMeasurementsAsExpiredForTesting(WKPageRef page, WKPageMarkPrivateClickMeasurementsAsExpiredForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageMarkPrivateClickMeasurementsAsExpiredForTesting(WKPageRef pageRef, WKPageMarkPrivateClickMeasurementsAsExpiredForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->markPrivateClickMeasurementsAsExpiredForTesting([callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->markPrivateClickMeasurementsAsExpiredForTesting([callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetPCMFraudPreventionValuesForTesting(WKPageRef page, WKStringRef unlinkableToken, WKStringRef secretToken, WKStringRef signature, WKStringRef keyID, WKPageSetPCMFraudPreventionValuesForTestingFunction callback, void* callbackContext)
</del><ins>+void WKPageSetPCMFraudPreventionValuesForTesting(WKPageRef pageRef, WKStringRef unlinkableToken, WKStringRef secretToken, WKStringRef signature, WKStringRef keyID, WKPageSetPCMFraudPreventionValuesForTestingFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setPCMFraudPreventionValuesForTesting(toWTFString(unlinkableToken), toWTFString(secretToken), toWTFString(signature), toWTFString(keyID), [callbackContext, callback] () {
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setPCMFraudPreventionValuesForTesting(toWTFString(unlinkableToken), toWTFString(secretToken), toWTFString(signature), toWTFString(keyID), [callbackContext, callback] () {
</ins><span class="cx">         callback(callbackContext);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetMockCameraOrientation(WKPageRef page, uint64_t orientation)
</del><ins>+void WKPageSetMockCameraOrientation(WKPageRef pageRef, uint64_t orientation)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
</span><del>-    toImpl(page)->setOrientationForMediaCapture(orientation);
</del><ins>+    toImpl(pageRef)->setOrientationForMediaCapture(orientation);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3006,10 +3131,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageLoadedSubresourceDomains(WKPageRef page, WKPageLoadedSubresourceDomainsFunction callback, void* callbackContext)
</del><ins>+void WKPageLoadedSubresourceDomains(WKPageRef pageRef, WKPageLoadedSubresourceDomainsFunction callback, void* callbackContext)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><del>-    toImpl(page)->getLoadedSubresourceDomains([callbackContext, callback](Vector<RegistrableDomain>&& domains) {
</del><ins>+    toImpl(pageRef)->getLoadedSubresourceDomains([callbackContext, callback](Vector<RegistrableDomain>&& domains) {
</ins><span class="cx">         Vector<RefPtr<API::Object>> apiDomains = WTF::map(domains, [](auto& domain) {
</span><span class="cx">             return RefPtr<API::Object>(API::String::create(WTFMove(domain.string())));
</span><span class="cx">         });
</span><span class="lines">@@ -3016,26 +3142,29 @@
</span><span class="cx">         callback(toAPI(API::Array::create(WTFMove(apiDomains)).ptr()), callbackContext);
</span><span class="cx">     });
</span><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx">     callback(nullptr, callbackContext);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageClearLoadedSubresourceDomains(WKPageRef page)
</del><ins>+void WKPageClearLoadedSubresourceDomains(WKPageRef pageRef)
</ins><span class="cx"> {
</span><ins>+    CRASH_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><del>-    toImpl(page)->clearLoadedSubresourceDomains();
</del><ins>+    toImpl(pageRef)->clearLoadedSubresourceDomains();
</ins><span class="cx"> #else
</span><del>-    UNUSED_PARAM(page);
</del><ins>+    UNUSED_PARAM(pageRef);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageSetMediaCaptureReportingDelayForTesting(WKPageRef page, double delay)
</del><ins>+void WKPageSetMediaCaptureReportingDelayForTesting(WKPageRef pageRef, double delay)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->setMediaCaptureReportingDelay(Seconds(delay));
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->setMediaCaptureReportingDelay(Seconds(delay));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WKPageDispatchActivityStateUpdateForTesting(WKPageRef page)
</del><ins>+void WKPageDispatchActivityStateUpdateForTesting(WKPageRef pageRef)
</ins><span class="cx"> {
</span><del>-    toImpl(page)->dispatchActivityStateUpdateForTesting();
</del><ins>+    CRASH_IF_SUSPENDED;
+    toImpl(pageRef)->dispatchActivityStateUpdateForTesting();
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm     2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm        2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -199,6 +199,9 @@
</span><span class="cx"> static const uint32_t firstSDKVersionWithLinkPreviewEnabledByDefault = 0xA0000;
</span><span class="cx"> #endif // PLATFORM(IOS_FAMILY)
</span><span class="cx"> 
</span><ins>+#define THROW_IF_SUSPENDED if (UNLIKELY(_page && _page->isSuspended())) \
+    [NSException raise:NSInternalInconsistencyException format:@"The WKWebView is suspended"]
+
</ins><span class="cx"> RetainPtr<NSError> nsErrorFromExceptionDetails(const WebCore::ExceptionDetails& details)
</span><span class="cx"> {
</span><span class="cx">     auto userInfo = adoptNS([[NSMutableDictionary alloc] init]);
</span><span class="lines">@@ -718,11 +721,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadRequest:(NSURLRequest *)request
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->loadRequest(request));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadFileURL:(NSURL *)URL allowingReadAccessToURL:(NSURL *)readAccessURL
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (![URL isFileURL])
</span><span class="cx">         [NSException raise:NSInvalidArgumentException format:@"%@ is not a file URL", URL];
</span><span class="cx"> 
</span><span class="lines">@@ -734,6 +739,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
</span><span class="cx"> 
</span><span class="cx">     return [self loadData:data MIMEType:@"text/html" characterEncodingName:@"UTF-8" baseURL:baseURL];
</span><span class="lines">@@ -741,11 +747,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)startDownloadUsingRequest:(NSURLRequest *)request completionHandler:(void(^)(WKDownload *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->downloadRequest(request, [completionHandler = makeBlockPtr(completionHandler)] (auto* download) {
</span><span class="cx">         if (download)
</span><span class="cx">             completionHandler(wrapper(download));
</span><span class="lines">@@ -756,6 +764,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)resumeDownloadFromResumeData:(NSData *)resumeData completionHandler:(void(^)(WKDownload *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:resumeData error:nil]);
</span><span class="cx">     [unarchiver setDecodingFailurePolicy:NSDecodingFailurePolicyRaiseException];
</span><span class="cx">     NSDictionary *dictionary = [unarchiver decodeObjectOfClasses:[NSSet setWithObjects:[NSDictionary class], [NSArray class], [NSString class], [NSNumber class], [NSData class], [NSURL class], [NSURLRequest class], nil] forKey:@"NSKeyedArchiveRootObjectKey"];
</span><span class="lines">@@ -782,6 +791,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)goToBackForwardListItem:(WKBackForwardListItem *)item
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->goToBackForwardItem(item._item));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -840,6 +850,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)goBack
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (self._safeBrowsingWarning)
</span><span class="cx">         return [self reload];
</span><span class="cx">     return wrapper(_page->goBack());
</span><span class="lines">@@ -847,11 +858,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)goForward
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->goForward());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)reload
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     OptionSet<WebCore::ReloadOption> reloadOptions;
</span><span class="cx">     if (linkedOnOrAfter(WebCore::SDKVersion::FirstWithExpiredOnlyReloadBehavior))
</span><span class="cx">         reloadOptions.add(WebCore::ReloadOption::ExpiredOnly);
</span><span class="lines">@@ -861,26 +874,31 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)reloadFromOrigin
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->reload(WebCore::ReloadOption::FromOrigin));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)stopLoading
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->stopLoading();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)evaluateJavaScript:(NSString *)javaScriptString completionHandler:(void (^)(id, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)evaluateJavaScript:(NSString *)javaScriptString inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)callAsyncJavaScript:(NSString *)javaScriptString arguments:(NSDictionary<NSString *, id> *)arguments inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:YES withSourceURL:nil withArguments:arguments forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -920,6 +938,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)closeAllMediaPresentationsWithCompletionHandler:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(FULLSCREEN_API)
</span><span class="lines">@@ -936,6 +955,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)pauseAllMediaPlaybackWithCompletionHandler:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!completionHandler) {
</span><span class="cx">         _page->pauseAllMediaPlayback([] { });
</span><span class="cx">         return;
</span><span class="lines">@@ -946,6 +966,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllMediaPlaybackSuspended:(BOOL)suspended completionHandler:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!completionHandler)
</span><span class="cx">         completionHandler = [] { };
</span><span class="cx"> 
</span><span class="lines">@@ -976,6 +997,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)requestMediaPlaybackStateWithCompletionHandler:(void (^)(WKMediaPlaybackState))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!completionHandler)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -1006,6 +1028,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setMicrophoneCaptureState:(WKMediaCaptureState)state completionHandler:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!completionHandler)
</span><span class="cx">         completionHandler = [] { };
</span><span class="cx"> 
</span><span class="lines">@@ -1027,6 +1050,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setCameraCaptureState:(WKMediaCaptureState)state completionHandler:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!completionHandler)
</span><span class="cx">         completionHandler = [] { };
</span><span class="cx"> 
</span><span class="lines">@@ -1048,6 +1072,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_evaluateJavaScript:(NSString *)javaScriptString asAsyncFunction:(BOOL)asAsyncFunction withSourceURL:(NSURL *)sourceURL withArguments:(NSDictionary<NSString *, id> *)arguments forceUserGesture:(BOOL)forceUserGesture inFrame:(WKFrameInfo *)frame inWorld:(WKContentWorld *)world completionHandler:(void (^)(id, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto handler = adoptNS([completionHandler copy]);
</span><span class="cx"> 
</span><span class="cx">     Optional<WebCore::ArgumentWireBytesMap> argumentsMap;
</span><span class="lines">@@ -1109,6 +1134,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)takeSnapshotWithConfiguration:(WKSnapshotConfiguration *)snapshotConfiguration completionHandler:(void(^)(CocoaImage *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     constexpr bool snapshotFailedTraceValue = false;
</span><span class="cx">     tracePoint(TakeSnapshotStart);
</span><span class="cx"> 
</span><span class="lines">@@ -1182,6 +1208,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigationGestures
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     _impl->setAllowsBackForwardNavigationGestures(allowsBackForwardNavigationGestures);
</span><span class="cx"> #elif PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -1220,6 +1247,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setCustomUserAgent:(NSString *)customUserAgent
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setCustomUserAgent(customUserAgent);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1234,6 +1262,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllowsLinkPreview:(BOOL)allowsLinkPreview
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     _impl->setAllowsLinkPreview(allowsLinkPreview);
</span><span class="cx">     return;
</span><span class="lines">@@ -1255,6 +1284,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setPageZoom:(CGFloat)pageZoom
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setPageZoomFactor(pageZoom);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1279,6 +1309,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)findString:(NSString *)string withConfiguration:(WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!string.length) {
</span><span class="cx">         completionHandler(adoptNS([[WKFindResult alloc] _initWithMatchFound:NO]).get());
</span><span class="cx">         return;
</span><span class="lines">@@ -1296,6 +1327,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setMediaType:(NSString *)mediaStyle
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setOverriddenMediaType(mediaStyle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1311,6 +1343,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setInteractionState:(id)interactionState
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (![(id)interactionState isKindOfClass:[NSData class]])
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -1335,6 +1368,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setAllowsMagnification:(BOOL)allowsMagnification
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _impl->setAllowsMagnification(allowsMagnification);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1345,11 +1379,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setMagnification:(double)magnification centeredAtPoint:(NSPoint)point
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _impl->setMagnification(magnification, NSPointToCGPoint(point));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setMagnification:(double)magnification
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _impl->setMagnification(magnification);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1360,6 +1396,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (auto webFrameProxy = _page->mainFrame())
</span><span class="cx">         return _impl->printOperationWithPrintInfo(printInfo, *webFrameProxy);
</span><span class="cx">     return nil;
</span><span class="lines">@@ -1527,6 +1564,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)createPDFWithConfiguration:(WKPDFConfiguration *)pdfConfiguration completionHandler:(void (^)(NSData *pdfDocumentData, NSError *error))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     WebCore::FrameIdentifier frameID;
</span><span class="cx">     if (auto mainFrame = _page->mainFrame())
</span><span class="cx">         frameID = mainFrame->frameID();
</span><span class="lines">@@ -1552,6 +1590,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getWebArchiveOfFrame(_page->mainFrame(), [completionHandler = makeBlockPtr(completionHandler)](API::Data* data) {
</span><span class="cx">         completionHandler(wrapper(data), nil);
</span><span class="cx">     });
</span><span class="lines">@@ -1633,6 +1672,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadSimulatedRequest:(NSURLRequest *)request response:(NSURLResponse *)response responseData:(NSData *)data
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->loadSimulatedRequest(request, response, { static_cast<const uint8_t*>(data.bytes), data.length }));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1639,11 +1679,13 @@
</span><span class="cx"> // FIXME(223658): Remove this once adopters have moved to the final API.
</span><span class="cx"> - (WKNavigation *)loadSimulatedRequest:(NSURLRequest *)request withResponse:(NSURLResponse *)response responseData:(NSData *)data
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return [self loadSimulatedRequest:request response:response responseData:data];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadSimulatedRequest:(NSURLRequest *)request responseHTMLString:(NSString *)string
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
</span><span class="cx">     auto response = adoptNS([[NSURLResponse alloc] initWithURL:request.URL MIMEType:@"text/html" expectedContentLength:string.length textEncodingName:@"UTF-8"]);
</span><span class="cx"> 
</span><span class="lines">@@ -1653,11 +1695,13 @@
</span><span class="cx"> // FIXME(223658): Remove this once adopters have moved to the final API.
</span><span class="cx"> - (WKNavigation *)loadSimulatedRequest:(NSURLRequest *)request withResponseHTMLString:(NSString *)string
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return [self loadSimulatedRequest:request responseHTMLString:string];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)loadFileRequest:(NSURLRequest *)request allowingReadAccessToURL:(NSURL *)readAccessURL
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto URL = request.URL;
</span><span class="cx"> 
</span><span class="cx">     if (![URL isFileURL])
</span><span class="lines">@@ -1687,7 +1731,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><del>-#define WEBCORE_PRIVATE_COMMAND(command) - (void)_##command:(id)sender { _page->executeEditCommand(#command ## _s); }
</del><ins>+#define WEBCORE_PRIVATE_COMMAND(command) - (void)_##command:(id)sender { THROW_IF_SUSPENDED; _page->executeEditCommand(#command ## _s); }
</ins><span class="cx"> 
</span><span class="cx"> WEBCORE_PRIVATE_COMMAND(alignCenter)
</span><span class="cx"> WEBCORE_PRIVATE_COMMAND(alignJustified)
</span><span class="lines">@@ -1706,21 +1750,25 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_toggleStrikeThrough:(id)sender
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->executeEditCommand("strikethrough"_s);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_increaseListLevel:(id)sender
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->increaseListLevel();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_decreaseListLevel:(id)sender
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->decreaseListLevel();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_changeListType:(id)sender
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->changeListType();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1772,6 +1820,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setViewportSizeForCSSViewportUnits:(CGSize)viewportSize
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto viewportSizeForViewportUnits = WebCore::IntSize(viewportSize);
</span><span class="cx">     if (viewportSizeForViewportUnits.isEmpty())
</span><span class="cx">         [NSException raise:NSInvalidArgumentException format:@"Viewport size should not be empty"];
</span><span class="lines">@@ -1793,6 +1842,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didEnableBrowserExtensions:(NSDictionary<NSString *, NSString *> *)extensionIDToNameMap
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     HashMap<String, String> transformed;
</span><span class="cx">     transformed.reserveInitialCapacity(extensionIDToNameMap.count);
</span><span class="cx">     [extensionIDToNameMap enumerateKeysAndObjectsUsingBlock:[&](NSString *extensionID, NSString *extensionName, BOOL *) {
</span><span class="lines">@@ -1803,6 +1853,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didDisableBrowserExtensions:(NSSet<NSString *> *)extensionIDs
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     HashSet<String> transformed;
</span><span class="cx">     transformed.reserveInitialCapacity(extensionIDs.count);
</span><span class="cx">     for (NSString *extensionID in extensionIDs)
</span><span class="lines">@@ -1851,6 +1902,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setEditable:(BOOL)editable
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     bool wasEditable = _page->isEditable();
</span><span class="cx">     _page->setEditable(editable);
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="lines">@@ -1868,6 +1920,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_executeEditCommand:(NSString *)command argument:(NSString *)argument completion:(void (^)(BOOL))completion
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->executeEditCommand(command, argument, [capturedCompletionBlock = makeBlockPtr(completion)] {
</span><span class="cx">         if (capturedCompletionBlock)
</span><span class="cx">             capturedCompletionBlock(YES);
</span><span class="lines">@@ -1903,6 +1956,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_startTextManipulationsWithConfiguration:(_WKTextManipulationConfiguration *)configuration completion:(void(^)())completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     using ExclusionRule = WebCore::TextManipulationController::ExclusionRule;
</span><span class="cx"> 
</span><span class="cx">     if (!_textManipulationDelegate || !_page) {
</span><span class="lines">@@ -1967,6 +2021,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_completeTextManipulation:(_WKTextManipulationItem *)item completion:(void(^)(BOOL success))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!_page) {
</span><span class="cx">         completionHandler(false);
</span><span class="cx">         return;
</span><span class="lines">@@ -2024,6 +2079,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_completeTextManipulationForItems:(NSArray<_WKTextManipulationItem *> *)items completion:(void(^)(NSArray<NSError *> *errors))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!_page) {
</span><span class="cx">         completionHandler(makeFailureSetForAllTextManipulationItems(items).get());
</span><span class="cx">         return;
</span><span class="lines">@@ -2051,6 +2107,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_takeFindStringFromSelection:(id)sender
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     [self _takeFindStringFromSelectionInternal:sender];
</span><span class="cx"> #else
</span><span class="lines">@@ -2105,6 +2162,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateMediaPlaybackControlsManager
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</span><span class="cx">     _impl->updateMediaPlaybackControlsManager();
</span><span class="cx"> #endif
</span><span class="lines">@@ -2130,6 +2188,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_togglePictureInPicture
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
</span><span class="cx">     _impl->togglePictureInPicture();
</span><span class="cx"> #endif
</span><span class="lines">@@ -2142,26 +2201,31 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_closeAllMediaPresentations
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self closeAllMediaPresentationsWithCompletionHandler:nil];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_stopMediaCapture
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->stopMediaCapture(WebCore::MediaProducer::MediaCaptureKind::AudioVideo);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_stopAllMediaPlayback
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self pauseAllMediaPlaybackWithCompletionHandler:nil];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_suspendAllMediaPlayback
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self setAllMediaPlaybackSuspended:YES completionHandler:nil];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_resumeAllMediaPlayback
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self setAllMediaPlaybackSuspended:NO completionHandler:nil];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2178,6 +2242,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_restoreAppHighlights:(NSArray<NSData *> *)highlights
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(APP_HIGHLIGHTS)
</span><span class="cx">     Vector<Ref<WebKit::SharedMemory>> buffers;
</span><span class="cx"> 
</span><span class="lines">@@ -2192,6 +2257,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_restoreAndScrollToAppHighlight:(NSData *)highlight
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(APP_HIGHLIGHTS)
</span><span class="cx">     Vector<Ref<WebKit::SharedMemory>> buffers;
</span><span class="cx">     
</span><span class="lines">@@ -2204,6 +2270,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_addAppHighlight
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(APP_HIGHLIGHTS)
</span><span class="cx">     _page->createAppHighlightInSelectedRange(WebCore::CreateNewGroupForHighlight::No, WebCore::HighlightRequestOriginatedInApp::Yes);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2223,6 +2290,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
</span><span class="cx">     _page->loadAlternateHTML({ static_cast<const uint8_t*>(data.bytes), data.length }, "UTF-8"_s, baseURL, unreachableURL);
</span><span class="cx"> }
</span><span class="lines">@@ -2229,11 +2297,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_loadData:(NSData *)data MIMEType:(NSString *)MIMEType characterEncodingName:(NSString *)characterEncodingName baseURL:(NSURL *)baseURL userData:(id)userData
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->loadData({ static_cast<const uint8_t*>(data.bytes), data.length }, MIMEType, characterEncodingName, baseURL.absoluteString, WebKit::ObjCObjectGraph::create(userData).ptr()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_loadRequest:(NSURLRequest *)request shouldOpenExternalURLs:(BOOL)shouldOpenExternalURLs
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _WKShouldOpenExternalURLsPolicy policy = shouldOpenExternalURLs ? _WKShouldOpenExternalURLsPolicyAllow : _WKShouldOpenExternalURLsPolicyNotAllow;
</span><span class="cx">     return [self _loadRequest:request shouldOpenExternalURLsPolicy:policy];
</span><span class="cx"> }
</span><span class="lines">@@ -2240,6 +2310,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_loadRequest:(NSURLRequest *)request shouldOpenExternalURLsPolicy:(_WKShouldOpenExternalURLsPolicy)shouldOpenExternalURLsPolicy
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     WebCore::ShouldOpenExternalURLsPolicy policy;
</span><span class="cx">     switch (shouldOpenExternalURLsPolicy) {
</span><span class="cx">     case _WKShouldOpenExternalURLsPolicyNotAllow:
</span><span class="lines">@@ -2257,6 +2328,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_grantAccessToAssetServices
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (_page)
</span><span class="cx">         _page->grantAccessToAssetServices();
</span><span class="cx"> }
</span><span class="lines">@@ -2263,6 +2335,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_revokeAccessToAssetServices
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (_page)
</span><span class="cx">         _page->revokeAccessToAssetServices();
</span><span class="cx"> }
</span><span class="lines">@@ -2269,6 +2342,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_switchFromStaticFontRegistryToUserFontRegistry
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (_page)
</span><span class="cx">         _page->switchFromStaticFontRegistryToUserFontRegistry();
</span><span class="cx"> }
</span><span class="lines">@@ -2275,6 +2349,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_appBoundNavigationDataForDomain:(NSString *)domain completionHandler:(void (^)(NSString * context))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->appBoundNavigationData([registrableDomain = WebCore::RegistrableDomain::uncheckedCreateFromHost(domain), completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
</span><span class="cx">         if (!appBoundData.contextData.contains(registrableDomain)) {
</span><span class="cx">             completionHandler(nil);
</span><span class="lines">@@ -2287,6 +2362,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->appBoundNavigationData([completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
</span><span class="cx">         completionHandler(appBoundData.hasLoadedAppBoundRequestTesting);
</span><span class="cx">     });
</span><span class="lines">@@ -2294,11 +2370,34 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->appBoundNavigationData([completionHandler = makeBlockPtr(completionHandler)] (auto&& appBoundData) mutable {
</span><span class="cx">         completionHandler(appBoundData.hasLoadedNonAppBoundRequestTesting);
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_suspendPage:(void (^)(BOOL))completionHandler
+{
+    if (!_page) {
+        completionHandler(NO);
+        return;
+    }
+    _page->suspend([completionHandler = makeBlockPtr(completionHandler)](bool success) {
+        completionHandler(success);
+    });
+}
+
+- (void)_resumePage:(void (^)(BOOL))completionHandler
+{
+    if (!_page) {
+        completionHandler(NO);
+        return;
+    }
+    _page->resume([completionHandler = makeBlockPtr(completionHandler)](bool success) {
+        completionHandler(success);
+    });
+}
+
</ins><span class="cx"> - (NSArray *)_certificateChain
</span><span class="cx"> {
</span><span class="cx">     if (WebKit::WebFrameProxy* mainFrame = _page->mainFrame())
</span><span class="lines">@@ -2332,6 +2431,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setApplicationNameForUserAgent:(NSString *)applicationNameForUserAgent
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setApplicationNameForUserAgent(applicationNameForUserAgent);
</span><span class="cx">     _page->setApplicationNameForDesktopUserAgent(applicationNameForUserAgent);
</span><span class="cx"> }
</span><span class="lines">@@ -2384,6 +2484,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_killWebContentProcess
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (![self _isValid])
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -2392,16 +2493,19 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_reloadWithoutContentBlockers
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->reload(WebCore::ReloadOption::DisableContentBlockers));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_reloadExpiredOnly
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->reload(WebCore::ReloadOption::ExpiredOnly));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_killWebContentProcessAndResetState
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     Ref<WebKit::WebProcessProxy> protectedProcessProxy(_page->process());
</span><span class="cx">     protectedProcessProxy->requestTermination(WebKit::ProcessTerminationReason::RequestedByClient);
</span><span class="cx"> 
</span><span class="lines">@@ -2413,6 +2517,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_takePDFSnapshotWithConfiguration:(WKSnapshotConfiguration *)snapshotConfiguration completionHandler:(void (^)(NSData *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     RetainPtr<WKPDFConfiguration> pdfConfiguration;
</span><span class="cx">     if (snapshotConfiguration) {
</span><span class="cx">         pdfConfiguration = adoptNS([[WKPDFConfiguration alloc] init]);
</span><span class="lines">@@ -2424,6 +2529,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getPDFFirstPageSizeInFrame:(_WKFrameHandle *)frame completionHandler:(void(^)(CGSize))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getPDFFirstPageSize(frame->_frameHandle->frameID(), [completionHandler = makeBlockPtr(completionHandler)](WebCore::FloatSize size) {
</span><span class="cx">         completionHandler(static_cast<CGSize>(size));
</span><span class="cx">     });
</span><span class="lines">@@ -2454,6 +2560,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_restoreFromSessionStateData:(NSData *)sessionStateData
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     // FIXME: This should not use the legacy session state decoder.
</span><span class="cx">     WebKit::SessionState sessionState;
</span><span class="cx">     if (!WebKit::decodeLegacySessionState(static_cast<const uint8_t*>(sessionStateData.bytes), sessionStateData.length, sessionState))
</span><span class="lines">@@ -2464,6 +2571,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (WKNavigation *)_restoreSessionState:(_WKSessionState *)sessionState andNavigate:(BOOL)navigate
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return wrapper(_page->restoreFromSessionState(sessionState ? sessionState->_sessionState : WebKit::SessionState { }, navigate));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2474,6 +2582,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_tryClose
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return _page->tryClose();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2484,6 +2593,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (_WKAttachment *)_insertAttachmentWithFilename:(NSString *)filename contentType:(NSString *)contentType data:(NSData *)data options:(_WKAttachmentDisplayOptions *)options completion:(void(^)(BOOL success))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     UNUSED_PARAM(options);
</span><span class="cx">     auto fileWrapper = adoptNS([[NSFileWrapper alloc] initRegularFileWithContents:data]);
</span><span class="cx">     if (filename)
</span><span class="lines">@@ -2493,6 +2603,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (_WKAttachment *)_insertAttachmentWithFileWrapper:(NSFileWrapper *)fileWrapper contentType:(NSString *)contentType options:(_WKAttachmentDisplayOptions *)options completion:(void(^)(BOOL success))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     UNUSED_PARAM(options);
</span><span class="cx">     return [self _insertAttachmentWithFileWrapper:fileWrapper contentType:contentType completion:completionHandler];
</span><span class="cx"> }
</span><span class="lines">@@ -2499,6 +2610,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (_WKAttachment *)_insertAttachmentWithFileWrapper:(NSFileWrapper *)fileWrapper contentType:(NSString *)contentType completion:(void(^)(BOOL success))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx">     auto identifier = createCanonicalUUIDString();
</span><span class="cx">     auto attachment = API::Attachment::create(identifier, *_page);
</span><span class="lines">@@ -2518,6 +2630,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (_WKAttachment *)_attachmentForIdentifier:(NSString *)identifier
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(ATTACHMENT_ELEMENT)
</span><span class="cx">     if (auto attachment = _page->attachmentForIdentifier(identifier))
</span><span class="cx">         return wrapper(attachment);
</span><span class="lines">@@ -2527,6 +2640,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_simulateDeviceOrientationChangeWithAlpha:(double)alpha beta:(double)beta gamma:(double)gamma
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->simulateDeviceOrientationChange(alpha, beta, gamma);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2542,6 +2656,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_showSafeBrowsingWarningWithTitle:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _showSafeBrowsingWarningWithURL:nil title:title warning:warning detailsWithLinks:details completionHandler:^(BOOL continueUnsafeLoad, NSURL *url) {
</span><span class="cx">         ASSERT(!url);
</span><span class="cx">         completionHandler(continueUnsafeLoad);
</span><span class="lines">@@ -2550,6 +2665,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_showSafeBrowsingWarningWithURL:(NSURL *)url title:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _showSafeBrowsingWarningWithURL:nil title:title warning:warning detailsWithLinks:details completionHandler:^(BOOL continueUnsafeLoad, NSURL *url) {
</span><span class="cx">         ASSERT(!url);
</span><span class="cx">         completionHandler(continueUnsafeLoad);
</span><span class="lines">@@ -2558,6 +2674,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_showSafeBrowsingWarningWithURL:(NSURL *)url title:(NSString *)title warning:(NSString *)warning detailsWithLinks:(NSAttributedString *)details completionHandler:(void(^)(BOOL, NSURL *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     auto safeBrowsingWarning = WebKit::SafeBrowsingWarning::create(url, title, warning, details);
</span><span class="cx">     auto wrapper = [completionHandler = makeBlockPtr(completionHandler)] (Variant<WebKit::ContinueUnsafeLoad, URL>&& variant) {
</span><span class="cx">         switchOn(variant, [&] (WebKit::ContinueUnsafeLoad continueUnsafeLoad) {
</span><span class="lines">@@ -2590,6 +2707,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_isJITEnabled:(void(^)(BOOL))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->isJITEnabled([completionHandler = makeBlockPtr(completionHandler)] (bool enabled) {
</span><span class="cx">         completionHandler(enabled);
</span><span class="cx">     });
</span><span class="lines">@@ -2597,11 +2715,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_evaluateJavaScriptWithoutUserGesture:(NSString *)javaScriptString completionHandler:(void (^)(id, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:NO inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_callAsyncJavaScript:(NSString *)functionBody arguments:(NSDictionary<NSString *, id> *)arguments inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:functionBody asAsyncFunction:YES withSourceURL:nil withArguments:arguments forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2626,11 +2746,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_evaluateJavaScript:(NSString *)javaScriptString inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_evaluateJavaScript:(NSString *)javaScriptString withSourceURL:(NSURL *)url inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld completionHandler:(void (^)(id, NSError *error))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _evaluateJavaScript:javaScriptString asAsyncFunction:NO withSourceURL:url withArguments:nil forceUserGesture:YES inFrame:frame inWorld:contentWorld completionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2640,6 +2762,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_updateWebpagePreferences:(WKWebpagePreferences *)webpagePreferences
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (webpagePreferences._websiteDataStore)
</span><span class="cx">         [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
</span><span class="cx">     if (webpagePreferences._userContentController)
</span><span class="lines">@@ -2650,11 +2773,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_notifyUserScripts
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->notifyUserScripts();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_deferrableUserScriptsNeedNotification
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     return _page->userScriptsNeedNotification();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2669,6 +2794,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setAllowsRemoteInspection:(BOOL)allow
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx">     _page->setAllowsRemoteInspection(allow);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2685,6 +2811,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setRemoteInspectionNameOverride:(NSString *)name
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx">     _page->setRemoteInspectionNameOverride(name);
</span><span class="cx"> #endif
</span><span class="lines">@@ -2697,6 +2824,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setAddsVisitedLinks:(BOOL)addsVisitedLinks
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setAddsVisitedLinks(addsVisitedLinks);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2744,6 +2872,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getMainResourceDataOfFrame(_page->mainFrame(), [completionHandler = makeBlockPtr(completionHandler)](API::Data* data) {
</span><span class="cx">         completionHandler(wrapper(data), nil);
</span><span class="cx">     });
</span><span class="lines">@@ -2751,11 +2880,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self createWebArchiveDataWithCompletionHandler:completionHandler];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::No, [handler = makeBlockPtr(completionHandler)](String string) {
</span><span class="cx">         handler(string, nil);
</span><span class="cx">     });
</span><span class="lines">@@ -2763,6 +2894,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getContentsOfAllFramesAsStringWithCompletionHandler:(void (^)(NSString *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::Yes, [handler = makeBlockPtr(completionHandler)](String string) {
</span><span class="cx">         handler(string);
</span><span class="cx">     });
</span><span class="lines">@@ -2770,6 +2902,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getContentsAsAttributedStringWithCompletionHandler:(void (^)(NSAttributedString *, NSDictionary<NSAttributedStringDocumentAttributeKey, id> *, NSError *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getContentsAsAttributedString([handler = makeBlockPtr(completionHandler)](auto& attributedString) {
</span><span class="cx">         if (attributedString.string)
</span><span class="cx">             handler(attributedString.string.get(), attributedString.documentAttributes.get(), nil);
</span><span class="lines">@@ -2780,6 +2913,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_getApplicationManifestWithCompletionHandler:(void (^)(_WKApplicationManifest *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(APPLICATION_MANIFEST)
</span><span class="cx">     _page->getApplicationManifest([completionHandler = makeBlockPtr(completionHandler)](const Optional<WebCore::ApplicationManifest>& manifest) {
</span><span class="cx">         if (completionHandler) {
</span><span class="lines">@@ -2817,6 +2951,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPaginationMode:(_WKPaginationMode)paginationMode
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     WebCore::Pagination::Mode mode;
</span><span class="cx">     switch (paginationMode) {
</span><span class="cx">     case _WKPaginationModeUnpaginated:
</span><span class="lines">@@ -2848,6 +2983,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setPaginationBehavesLikeColumns(behavesLikeColumns);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2858,6 +2994,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPageLength:(CGFloat)pageLength
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setPageLength(pageLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2868,6 +3005,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setGapBetweenPages:(CGFloat)gapBetweenPages
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setGapBetweenPages(gapBetweenPages);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2878,6 +3016,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPaginationLineGridEnabled:(BOOL)lineGridEnabled
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setPaginationLineGridEnabled(lineGridEnabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2898,6 +3037,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setTextZoomFactor:(double)zoomFactor
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setTextZoomFactor(zoomFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2908,6 +3048,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPageZoomFactor:(double)zoomFactor
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self setPageZoom:zoomFactor];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2969,6 +3110,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     if (_customContentView) {
</span><span class="cx">         [_customContentView web_countStringMatches:string options:options maxCount:maxCount];
</span><span class="lines">@@ -2980,6 +3122,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     // While AppKit contains logic in NSBarTextFinder to automatically update the find pasteboard
</span><span class="cx">     // when the find string changes, this (along with the find pasteboard itself) are both missing
</span><span class="lines">@@ -2996,6 +3139,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_hideFindUI
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     if (_customContentView) {
</span><span class="cx">         [_customContentView web_hideFindUI];
</span><span class="lines">@@ -3007,6 +3151,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_saveBackForwardSnapshotForItem:(WKBackForwardListItem *)item
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (!item)
</span><span class="cx">         return;
</span><span class="cx">     _page->recordNavigationSnapshot(item._item);
</span><span class="lines">@@ -3020,6 +3165,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_clearServiceWorkerEntitlementOverride:(void (^)(void))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->clearServiceWorkerEntitlementOverride([completionHandler = makeBlockPtr(completionHandler)] {
</span><span class="cx">         completionHandler();
</span><span class="cx">     });
</span><span class="lines">@@ -3027,6 +3173,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_preconnectToServer:(NSURL *)url
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->preconnectTo(url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3037,6 +3184,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setCanUseCredentialStorage:(BOOL)canUseCredentialStorage
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setCanUseCredentialStorage(canUseCredentialStorage);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3177,6 +3325,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setLayoutMode:(_WKLayoutMode)layoutMode
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     WKLayoutMode wkViewLayoutMode;
</span><span class="cx">     switch (layoutMode) {
</span><span class="lines">@@ -3207,11 +3356,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setFixedLayoutSize:(CGSize)fixedLayoutSize
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setFixedLayoutSize(WebCore::expandedIntSize(WebCore::FloatSize(fixedLayoutSize)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setBackgroundExtendsBeyondPage:(BOOL)backgroundExtends
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setBackgroundExtendsBeyondPage(backgroundExtends);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3231,6 +3382,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setViewScale:(CGFloat)viewScale
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (viewScale <= 0 || isnan(viewScale) || isinf(viewScale))
</span><span class="cx">         [NSException raise:NSInvalidArgumentException format:@"View scale should be a positive number"];
</span><span class="cx"> 
</span><span class="lines">@@ -3251,11 +3403,13 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setCORSDisablingPatterns:(NSArray<NSString *> *)patterns
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setCORSDisablingPatterns(makeVector<String>(patterns));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_getProcessDisplayNameWithCompletionHandler:(void (^)(NSString *))completionHandler
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->getProcessDisplayName([handler = makeBlockPtr(completionHandler)](auto&& name) {
</span><span class="cx">         handler(name);
</span><span class="cx">     });
</span><span class="lines">@@ -3263,6 +3417,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setMinimumEffectiveDeviceWidth:(CGFloat)minimumEffectiveDeviceWidth
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     if (_page->minimumEffectiveDeviceWidth() == minimumEffectiveDeviceWidth)
</span><span class="cx">         return;
</span><span class="lines">@@ -3285,6 +3440,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_grantAccessToPreferenceService
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     if (_page)
</span><span class="cx">         _page->grantAccessToPreferenceService();
</span><span class="cx"> }
</span><span class="lines">@@ -3293,6 +3449,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setScrollPerformanceDataCollectionEnabled:(BOOL)enabled
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setScrollPerformanceDataCollectionEnabled(enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3323,6 +3480,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setAllowsMediaDocumentInlinePlayback:(BOOL)flag
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="cx">     _page->setAllowsMediaDocumentInlinePlayback(flag);
</span><span class="cx"> #endif
</span><span class="lines">@@ -3361,6 +3519,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setMediaCaptureEnabled:(BOOL)enabled
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     _page->setMediaCaptureEnabled(enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3371,6 +3530,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_setPageMuted:(_WKMediaMutedState)mutedState
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     WebCore::MediaProducer::MutedStateFlags coreState;
</span><span class="cx"> 
</span><span class="cx">     if (mutedState & _WKMediaAudioMuted)
</span><span class="lines">@@ -3385,6 +3545,7 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_removeDataDetectedLinks:(dispatch_block_t)completion
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx"> #if ENABLE(DATA_DETECTION)
</span><span class="cx">     _page->removeDataDetectedLinks([completion = makeBlockPtr(completion), page = makeWeakPtr(_page.get())] (auto& result) {
</span><span class="cx">         if (page)
</span><span class="lines">@@ -3400,11 +3561,13 @@
</span><span class="cx"> // Execute the supplied block after the next transaction from the WebProcess.
</span><span class="cx"> - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _internalDoAfterNextPresentationUpdate:updateBlock withoutWaitingForPainting:NO withoutWaitingForAnimatedResize:NO];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_doAfterNextPresentationUpdateWithoutWaitingForPainting:(void (^)(void))updateBlock
</span><span class="cx"> {
</span><ins>+    THROW_IF_SUSPENDED;
</ins><span class="cx">     [self _internalDoAfterNextPresentationUpdate:updateBlock withoutWaitingForPainting:YES withoutWaitingForAnimatedResize:NO];
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h       2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h  2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -410,6 +410,9 @@
</span><span class="cx"> - (void)_didLoadAppBoundRequest:(void (^)(BOOL result))completionHandler;
</span><span class="cx"> - (void)_didLoadNonAppBoundRequest:(void (^)(BOOL result))completionHandler;
</span><span class="cx"> 
</span><ins>+- (void)_suspendPage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_resumePage:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #if TARGET_OS_IPHONE
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -3146,7 +3146,7 @@
</span><span class="cx">     // If the page is suspended, which should be the case during panning, pinching
</span><span class="cx">     // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
</span><span class="cx">     // we do not send any of the events to the page even if is has listeners.
</span><del>-    if (!m_isPageSuspended) {
</del><ins>+    if (!m_areActiveDOMObjectsAndAnimationsSuspended) {
</ins><span class="cx">         m_touchEventQueue.append(event);
</span><span class="cx">         m_process->startResponsivenessTimer();
</span><span class="cx">         send(Messages::WebPage::TouchEvent(event));
</span><span class="lines">@@ -3594,10 +3594,10 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
</span><span class="cx"> {
</span><del>-    if (!hasRunningProcess() || !m_isPageSuspended)
</del><ins>+    if (!hasRunningProcess() || !m_areActiveDOMObjectsAndAnimationsSuspended)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_isPageSuspended = false;
</del><ins>+    m_areActiveDOMObjectsAndAnimationsSuspended = false;
</ins><span class="cx"> 
</span><span class="cx">     send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations());
</span><span class="cx"> }
</span><span class="lines">@@ -3604,14 +3604,35 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
</span><span class="cx"> {
</span><del>-    if (!hasRunningProcess() || m_isPageSuspended)
</del><ins>+    if (!hasRunningProcess() || m_areActiveDOMObjectsAndAnimationsSuspended)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_isPageSuspended = true;
</del><ins>+    m_areActiveDOMObjectsAndAnimationsSuspended = true;
</ins><span class="cx"> 
</span><span class="cx">     send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::suspend(CompletionHandler<void(bool)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED(Loading, "suspend:");
+    if (!hasRunningProcess() || m_isSuspended)
+        return completionHandler(false);
+
+    m_isSuspended = true;
+    sendWithAsyncReply(Messages::WebPage::Suspend(), WTFMove(completionHandler));
+}
+
+void WebPageProxy::resume(CompletionHandler<void(bool)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED(Loading, "resume:");
+
+    if (!hasRunningProcess() || !m_isSuspended)
+        return completionHandler(false);
+
+    m_isSuspended = false;
+    sendWithAsyncReply(Messages::WebPage::Resume(), WTFMove(completionHandler));
+}
+
</ins><span class="cx"> bool WebPageProxy::supportsTextEncoding() const
</span><span class="cx"> {
</span><span class="cx">     // FIXME (118840): We should probably only support this for text documents, not all non-image documents.
</span><span class="lines">@@ -6081,7 +6102,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::requestMediaPlaybackState(CompletionHandler<void(WebKit::MediaPlaybackState)>&& completionHandler)
</del><ins>+void WebPageProxy::requestMediaPlaybackState(CompletionHandler<void(MediaPlaybackState)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     if (!hasRunningProcess()) {
</span><span class="cx">         completionHandler({ });
</span><span class="lines">@@ -7722,7 +7743,7 @@
</span><span class="cx">     m_visiblePageToken = nullptr;
</span><span class="cx"> 
</span><span class="cx">     m_hasRunningProcess = false;
</span><del>-    m_isPageSuspended = false;
</del><ins>+    m_areActiveDOMObjectsAndAnimationsSuspended = false;
</ins><span class="cx"> 
</span><span class="cx">     m_userScriptsNotified = false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -505,6 +505,10 @@
</span><span class="cx">     void didEnterFullscreen();
</span><span class="cx">     void didExitFullscreen();
</span><span class="cx"> 
</span><ins>+    void suspend(CompletionHandler<void(bool)>&&);
+    void resume(CompletionHandler<void(bool)>&&);
+    bool isSuspended() const { return m_isSuspended; }
+
</ins><span class="cx">     WebInspectorUIProxy* inspector() const;
</span><span class="cx">     GeolocationPermissionRequestManagerProxy& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
</span><span class="cx"> 
</span><span class="lines">@@ -1014,7 +1018,7 @@
</span><span class="cx">     void setCustomTextEncodingName(const String&);
</span><span class="cx">     String customTextEncodingName() const { return m_customTextEncodingName; }
</span><span class="cx"> 
</span><del>-    bool areActiveDOMObjectsAndAnimationsSuspended() const { return m_isPageSuspended; }
</del><ins>+    bool areActiveDOMObjectsAndAnimationsSuspended() const { return m_areActiveDOMObjectsAndAnimationsSuspended; }
</ins><span class="cx">     void resumeActiveDOMObjectsAndAnimations();
</span><span class="cx">     void suspendActiveDOMObjectsAndAnimations();
</span><span class="cx"> 
</span><span class="lines">@@ -2753,7 +2757,7 @@
</span><span class="cx">     RefPtr<WebCore::ValidationBubble> m_validationBubble;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    bool m_isPageSuspended { false };
</del><ins>+    bool m_areActiveDOMObjectsAndAnimationsSuspended { false };
</ins><span class="cx">     bool m_addsVisitedLinks { true };
</span><span class="cx"> 
</span><span class="cx">     bool m_controlledByAutomation { false };
</span><span class="lines">@@ -3015,6 +3019,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool m_lastNavigationWasAppBound { false };
</span><span class="cx">     bool m_isRunningModalJavaScriptDialog { false };
</span><ins>+    bool m_isSuspended { false };
</ins><span class="cx"> 
</span><span class="cx">     Optional<WebCore::PrivateClickMeasurement> m_privateClickMeasurement;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx"> #include <WebCore/ArchiveResource.h>
</span><span class="cx"> #include <WebCore/BackForwardCache.h>
</span><span class="cx"> #include <WebCore/BackForwardController.h>
</span><ins>+#include <WebCore/CachedPage.h>
</ins><span class="cx"> #include <WebCore/Chrome.h>
</span><span class="cx"> #include <WebCore/CommonVM.h>
</span><span class="cx"> #include <WebCore/ContactsRequestData.h>
</span><span class="lines">@@ -3596,6 +3597,37 @@
</span><span class="cx">     m_page->resumeActiveDOMObjectsAndAnimations();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::suspend(CompletionHandler<void(bool)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED(Loading, "suspend: m_page=%p", m_page.get());
+    if (!m_page)
+        return completionHandler(false);
+
+    freezeLayerTree(LayerTreeFreezeReason::PageSuspended);
+
+    m_cachedPage = BackForwardCache::singleton().suspendPage(*m_page);
+    ASSERT(m_cachedPage);
+    if (auto mainFrame = m_mainFrame->coreFrame())
+        mainFrame->loader().detachFromAllOpenedFrames();
+    completionHandler(true);
+}
+
+void WebPage::resume(CompletionHandler<void(bool)>&& completionHandler)
+{
+    RELEASE_LOG_IF_ALLOWED(Loading, "resume: m_page=%p", m_page.get());
+    if (!m_page)
+        return completionHandler(false);
+
+    auto cachedPage = std::exchange(m_cachedPage, nullptr);
+    ASSERT(cachedPage);
+    if (!cachedPage)
+        return completionHandler(false);
+
+    cachedPage->restore(*m_page);
+    unfreezeLayerTree(LayerTreeFreezeReason::PageSuspended);
+    completionHandler(true);
+}
+
</ins><span class="cx"> IntPoint WebPage::screenToRootView(const IntPoint& point)
</span><span class="cx"> {
</span><span class="cx">     IntPoint windowPoint;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -177,6 +177,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class CachedPage;
</ins><span class="cx"> class CaptureDevice;
</span><span class="cx"> class DocumentLoader;
</span><span class="cx"> class DragData;
</span><span class="lines">@@ -1669,6 +1670,9 @@
</span><span class="cx">     void suspendActiveDOMObjectsAndAnimations();
</span><span class="cx">     void resumeActiveDOMObjectsAndAnimations();
</span><span class="cx"> 
</span><ins>+    void suspend(CompletionHandler<void(bool)>&&);
+    void resume(CompletionHandler<void(bool)>&&);
+
</ins><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
</span><span class="cx">     void performDictionaryLookupOfCurrentSelection();
</span><span class="lines">@@ -2318,6 +2322,8 @@
</span><span class="cx"> 
</span><span class="cx">     Vector<String> m_corsDisablingPatterns;
</span><span class="cx"> 
</span><ins>+    std::unique_ptr<WebCore::CachedPage> m_cachedPage;
+
</ins><span class="cx"> #if ENABLE(IPC_TESTING_API)
</span><span class="cx">     bool m_ipcTestingAPIEnabled { false };
</span><span class="cx">     uint64_t m_visitedLinkTableID;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -250,6 +250,9 @@
</span><span class="cx">     SuspendActiveDOMObjectsAndAnimations()
</span><span class="cx">     ResumeActiveDOMObjectsAndAnimations()
</span><span class="cx"> 
</span><ins>+    Suspend() -> (bool success) Async
+    Resume() -> (bool success) Async
+
</ins><span class="cx">     Close()
</span><span class="cx">     TryClose() -> (bool shouldClose) Async
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Tools/ChangeLog       2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Add SPI to suspend / resume a WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=225333
+        <rdar://77462543>
+
+        Reviewed by Geoff Garen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html: Added.
+
</ins><span class="cx"> 2021-05-11  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Remove the String::toInt family of functions
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -262,6 +262,7 @@
</span><span class="cx">          463F4723255B49B600D9E0CC /* VisibilityState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 463F4722255B49B600D9E0CC /* VisibilityState.mm */; };
</span><span class="cx">          4647B1261EBA3B850041D7EF /* ProcessDidTerminate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4647B1251EBA3B730041D7EF /* ProcessDidTerminate.cpp */; };
</span><span class="cx">          464C764D230DF85C00AFB020 /* BadServiceWorkerRegistrations-4.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 464C764C230DF83200AFB020 /* BadServiceWorkerRegistrations-4.sqlite3 */; };
</span><ins>+               465C23AF2640C3FE00F2FC7F /* postMessage-regularly.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 465C23AE2640C3C500F2FC7F /* postMessage-regularly.html */; };
</ins><span class="cx">           465E2807255B2A6A0063A787 /* GPUProcess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 465E2806255B2A690063A787 /* GPUProcess.mm */; };
</span><span class="cx">          466C3843210637DE006A88DE /* notify-resourceLoadObserver.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 466C3842210637CE006A88DE /* notify-resourceLoadObserver.html */; };
</span><span class="cx">          467C565321B5ED130057516D /* GetSessionCookie.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 467C565121B5ECDF0057516D /* GetSessionCookie.html */; };
</span><span class="lines">@@ -1651,6 +1652,7 @@
</span><span class="cx">                          3FCC4FE81EC4E8CA0076E37C /* PictureInPictureDelegate.html in Copy Resources */,
</span><span class="cx">                          F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
</span><span class="cx">                          0EBBCC661FFF9E0C00FA42AB /* pop-up-check.html in Copy Resources */,
</span><ins>+                               465C23AF2640C3FE00F2FC7F /* postMessage-regularly.html in Copy Resources */,
</ins><span class="cx">                           F41AB9A81EF4696B0083FA08 /* prevent-operation.html in Copy Resources */,
</span><span class="cx">                          F41AB9A91EF4696B0083FA08 /* prevent-start.html in Copy Resources */,
</span><span class="cx">                          F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */,
</span><span class="lines">@@ -2068,6 +2070,7 @@
</span><span class="cx">          463F4722255B49B600D9E0CC /* VisibilityState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VisibilityState.mm; sourceTree = "<group>"; };
</span><span class="cx">          4647B1251EBA3B730041D7EF /* ProcessDidTerminate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessDidTerminate.cpp; sourceTree = "<group>"; };
</span><span class="cx">          464C764C230DF83200AFB020 /* BadServiceWorkerRegistrations-4.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "BadServiceWorkerRegistrations-4.sqlite3"; sourceTree = "<group>"; };
</span><ins>+               465C23AE2640C3C500F2FC7F /* postMessage-regularly.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "postMessage-regularly.html"; sourceTree = "<group>"; };
</ins><span class="cx">           465E2806255B2A690063A787 /* GPUProcess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUProcess.mm; sourceTree = "<group>"; };
</span><span class="cx">          466C3842210637CE006A88DE /* notify-resourceLoadObserver.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "notify-resourceLoadObserver.html"; sourceTree = "<group>"; };
</span><span class="cx">          467C565121B5ECDF0057516D /* GetSessionCookie.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = GetSessionCookie.html; sourceTree = "<group>"; };
</span><span class="lines">@@ -4075,6 +4078,7 @@
</span><span class="cx">                          9B7D740E1F8377E60006C432 /* paste-rtfd.html */,
</span><span class="cx">                          3FCC4FE61EC4E87E0076E37C /* PictureInPictureDelegate.html */,
</span><span class="cx">                          F415086C1DA040C10044BE9B /* play-audio-on-click.html */,
</span><ins>+                               465C23AE2640C3C500F2FC7F /* postMessage-regularly.html */,
</ins><span class="cx">                           F41AB9941EF4692C0083FA08 /* prevent-operation.html */,
</span><span class="cx">                          F41AB99A1EF4692C0083FA08 /* prevent-start.html */,
</span><span class="cx">                          A12DDBFF1E8373C100CF6CAE /* rendered-image-excluding-overflow.html */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProcessSuspensionmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm (277355 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm 2021-05-12 04:23:30 UTC (rev 277355)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSuspension.mm    2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -26,11 +26,13 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> 
</span><span class="cx"> #import "PlatformUtilities.h"
</span><ins>+#import "TestNavigationDelegate.h"
</ins><span class="cx"> #import "TestWKWebView.h"
</span><span class="cx"> #import <WebKit/WKWebViewConfiguration.h>
</span><span class="cx"> #import <WebKit/WKWebViewConfigurationPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebViewPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebViewPrivateForTesting.h>
</span><ins>+#import <wtf/Function.h>
</ins><span class="cx"> 
</span><span class="cx"> TEST(ProcessSuspension, CancelWebProcessSuspension)
</span><span class="cx"> {
</span><span class="lines">@@ -83,3 +85,151 @@
</span><span class="cx">     TestWebKitAPI::Util::sleep(1);
</span><span class="cx">     EXPECT_EQ(pid1, [webView3 _webProcessIdentifier]);
</span><span class="cx"> }
</span><ins>+
+TEST(ProcessSuspension, WKWebViewSuspendPage)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+    auto testMessageHandler = adoptNS([[TestMessageHandler alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:testMessageHandler.get() name:@"testHandler"];
+    __block unsigned timerFiredCount = 0;
+    [testMessageHandler addMessage:@"timer fired" withHandler:^{
+        ++timerFiredCount;
+    }];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get() addToWindow:YES]);
+    [webView synchronouslyLoadTestPageNamed:@"postMessage-regularly"];
+
+    auto pid = [webView _webProcessIdentifier];
+    EXPECT_NE(pid, 0);
+
+    // The timer should be firing.
+    auto lastTimerFireCount = timerFiredCount;
+    while (lastTimerFireCount == timerFiredCount)
+        TestWebKitAPI::Util::spinRunLoop(10);
+    EXPECT_TRUE(timerFiredCount > lastTimerFireCount);
+
+    auto testRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://webkit.org/"]];
+    id testInteractionState = [webView interactionState];
+    auto originalURL = [webView URL];
+
+    // Suspend the page.
+    [webView removeFromSuperview];
+    __block bool done = false;
+    [webView _suspendPage:^(BOOL success) {
+        EXPECT_TRUE(success);
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+
+    // The timer should no longer be firing.
+    lastTimerFireCount = timerFiredCount;
+    TestWebKitAPI::Util::spinRunLoop(100);
+    EXPECT_EQ(lastTimerFireCount, timerFiredCount);
+
+    auto checkThrows = [](Function<void()>&& f) {
+        @try {
+            f();
+        } @catch (NSException *e) {
+            return true;
+        }
+        return false;
+    };
+
+    // Most operations on WKWebView should throw an exception when suspended.
+    EXPECT_TRUE(checkThrows([&] { [webView evaluateJavaScript:@"window.name" completionHandler:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView synchronouslyLoadTestPageNamed:@"simple2"]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView loadHTMLString:@"foo" baseURL:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView goToBackForwardListItem:webView.get().backForwardList.currentItem]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView reload]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView reloadFromOrigin]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView goBack]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView goForward]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView stopLoading]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView closeAllMediaPresentationsWithCompletionHandler:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView pauseAllMediaPlaybackWithCompletionHandler:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView setAllMediaPlaybackSuspended:YES completionHandler:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView requestMediaPlaybackStateWithCompletionHandler:^(WKMediaPlaybackState) { }]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView setCameraCaptureState:WKMediaCaptureStateActive completionHandler:nil]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView setMicrophoneCaptureState:WKMediaCaptureStateActive completionHandler:nil]; }));
+#if TARGET_OS_IPHONE
+    EXPECT_TRUE(checkThrows([&] { [webView takeSnapshotWithConfiguration:nil completionHandler:^(UIImage *snapshot, NSError *error) { }]; }));
+#else
+    EXPECT_TRUE(checkThrows([&] { [webView takeSnapshotWithConfiguration:nil completionHandler:^(NSImage *snapshot, NSError *error) { }]; }));
+#endif
+    EXPECT_TRUE(checkThrows([&] { [webView createPDFWithConfiguration:nil completionHandler:^(NSData *data, NSError *error) { }]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView createWebArchiveDataWithCompletionHandler:^(NSData *data, NSError *error) { }]; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().allowsBackForwardNavigationGestures = YES; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().customUserAgent = @"foo"; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().allowsLinkPreview = YES; }));
+#if !TARGET_OS_IPHONE
+    EXPECT_TRUE(checkThrows([&] { webView.get().allowsMagnification = YES; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().magnification = 1.1; }));
+    EXPECT_TRUE(checkThrows([&] { [webView setMagnification:1.1 centeredAtPoint:CGPointMake(0, 0)]; }));
+#endif
+    EXPECT_TRUE(checkThrows([&] { webView.get().pageZoom = 1.1; }));
+    EXPECT_TRUE(checkThrows([&] { [webView findString:@"foo" withConfiguration:nil completionHandler:^(WKFindResult *result) { }]; }));
+    EXPECT_TRUE(checkThrows([&] { [webView startDownloadUsingRequest:testRequest completionHandler:^(WKDownload *download) { }]; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().interactionState = testInteractionState; }));
+    EXPECT_TRUE(checkThrows([&] { webView.get().mediaType = @"text/html"; }));
+
+    // Some of the basic API still works.
+    EXPECT_WK_STREQ([webView URL].absoluteString, originalURL.absoluteString);
+    EXPECT_EQ([webView backForwardList].backItem, nil);
+    EXPECT_WK_STREQ([webView title], @"");
+    EXPECT_FALSE([webView isLoading]);
+    EXPECT_EQ([webView estimatedProgress], 1.0);
+    EXPECT_FALSE([webView canGoBack]);
+    EXPECT_FALSE([webView canGoForward]);
+    EXPECT_FALSE([webView hasOnlySecureContent]);
+    EXPECT_EQ([webView serverTrust], nil);
+    EXPECT_EQ([webView cameraCaptureState], WKMediaCaptureStateNone);
+    EXPECT_EQ([webView microphoneCaptureState], WKMediaCaptureStateNone);
+    EXPECT_WK_STREQ([webView customUserAgent], @"");
+    EXPECT_TRUE([webView allowsLinkPreview]);
+#if !TARGET_OS_IPHONE
+    EXPECT_FALSE([webView allowsMagnification]);
+    EXPECT_EQ([webView magnification], 1.0);
+#endif
+    EXPECT_EQ([webView pageZoom], 1.0);
+    EXPECT_WK_STREQ([webView mediaType], @"");
+    EXPECT_FALSE(checkThrows([&] { [webView interactionState]; }));
+    EXPECT_FALSE(checkThrows([&] { [webView themeColor]; }));
+
+    // Resume the page.
+    done = false;
+    [webView _resumePage:^(BOOL success) {
+        EXPECT_TRUE(success);
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+    [webView addToTestWindow];
+
+    // The timer should start firing again.
+    lastTimerFireCount = timerFiredCount;
+    while (lastTimerFireCount == timerFiredCount)
+        TestWebKitAPI::Util::spinRunLoop(10);
+    EXPECT_TRUE(timerFiredCount > lastTimerFireCount);
+
+    // Make sure we did not crash.
+    EXPECT_EQ(pid, [webView _webProcessIdentifier]);
+}
+
+TEST(ProcessSuspension, DeallocateSuspendedView)
+{
+    // Deallocating a suspended WebView should not throw or crash.
+    @autoreleasepool {
+        auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+        [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+        [webView _test_waitForDidFinishNavigation];
+
+        __block bool done = false;
+        [webView _suspendPage:^(BOOL success) {
+            EXPECT_TRUE(success);
+            done = true;
+        }];
+        TestWebKitAPI::Util::run(&done);
+
+        [webView _close];
+    }
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoapostMessageregularlyhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html (0 => 277356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html                           (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/postMessage-regularly.html      2021-05-12 05:53:13 UTC (rev 277356)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE>
+<html>
+<body>
+<script>
+setInterval(() => {
+    webkit.messageHandlers.testHandler.postMessage('timer fired');
+}, 5);
+</script>
+</body>
+</html>
</ins></span></pre>
</div>
</div>

</body>
</html>