WebKit Bugzilla
Attachment 340140 Details for
Bug 185532
: Make sure history navigations reuse the existing process when necessary.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185532-20180510155546.patch (text/plain), 22.11 KB, created by
Brady Eidson
on 2018-05-10 15:55:47 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brady Eidson
Created:
2018-05-10 15:55:47 PDT
Size:
22.11 KB
patch
obsolete
>Subversion Revision: 231666 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d8a5acbd2caa2a67c145422d4257509d47c95f5d..0762363e02b2e9e1297fe6c06be8ddb31bf3a2e6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2018-05-10 Brady Eidson <beidson@apple.com> >+ >+ Make sure history navigations reuse the existing process when necessary. >+ <rdar://problem/39746516> and https://bugs.webkit.org/show_bug.cgi?id=185532 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Covered by new API tests. >+ >+ In WebCore-land, make sure *all* NavigationActions to a back/forward item are tagged with >+ the item identifier. >+ >+ * history/HistoryItem.cpp: >+ (WebCore::HistoryItem::HistoryItem): >+ (WebCore::HistoryItem::logString const): >+ * history/HistoryItem.h: >+ >+ * loader/FrameLoader.cpp: >+ (WebCore::FrameLoader::loadDifferentDocumentItem): >+ >+ * loader/NavigationAction.cpp: >+ (WebCore::NavigationAction::setTargetBackForwardItem): >+ >+ * loader/NavigationAction.h: >+ (WebCore::NavigationAction::targetBackForwardItemIdentifier const): >+ > 2018-05-10 Matt Baker <mattbaker@apple.com> > > Web Inspector: ASSERT_NOT_REACHED in PageDebuggerAgent::didAddEventListener when page adds attribute event listener >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 18849a7274c4e9ba463718e410106e7fad8c6c75..90b32eb2cfad4cf7164cc90410c6f2458bd201f0 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,37 @@ >+2018-05-10 Brady Eidson <beidson@apple.com> >+ >+ Make sure history navigations reuse the existing process when necessary. >+ <rdar://problem/39746516> and https://bugs.webkit.org/show_bug.cgi?id=185532 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ If a view navigates to either a data: or blob: URL, it reuses the existing process. >+ >+ In such cases we need to also ensure that history navigations back will also reuse the existing process. >+ >+ * Shared/NavigationActionData.cpp: >+ (WebKit::NavigationActionData::encode const): >+ (WebKit::NavigationActionData::decode): >+ * Shared/NavigationActionData.h: >+ >+ * UIProcess/API/APINavigation.h: >+ (API::Navigation::setTargetItem): >+ >+ * UIProcess/API/Cocoa/WKProcessPool.mm: >+ (-[WKProcessPool _contextForTesting]): >+ * UIProcess/API/Cocoa/WKProcessPoolInternal.h: >+ >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::receivedPolicyDecision): >+ (WebKit::WebPageProxy::decidePolicyForNavigationAction): >+ >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::processForNavigationInternal): If the current and target back/forward items both >+ came from the same process, then reuse the existing process. >+ >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction): >+ > 2018-05-10 Megan Gardner <megan_gardner@apple.com> > > Remove Unused Chinese/Japanese Reanalyze code >diff --git a/Source/WebCore/history/HistoryItem.cpp b/Source/WebCore/history/HistoryItem.cpp >index a5ba95e4356643cb7ef3237ae622ce3878e6677c..d308b907c4bc0f5e03f394ca19db925e7e26118b 100644 >--- a/Source/WebCore/history/HistoryItem.cpp >+++ b/Source/WebCore/history/HistoryItem.cpp >@@ -35,6 +35,7 @@ > #include "SharedBuffer.h" > #include <stdio.h> > #include <wtf/DateMath.h> >+#include <wtf/DebugUtilities.h> > #include <wtf/WallTime.h> > #include <wtf/text/CString.h> > >@@ -105,6 +106,7 @@ inline HistoryItem::HistoryItem(const HistoryItem& item) > , m_scale(item.m_scale) > , m_scaleIsInitial(item.m_scaleIsInitial) > #endif >+ , m_identifier(item.m_identifier) > { > if (item.m_formData) > m_formData = item.m_formData->copy(); >@@ -489,7 +491,14 @@ int HistoryItem::showTreeWithIndent(unsigned indentLevel) const > } > > #endif >- >+ >+#if !LOG_DISABLED >+const char* HistoryItem::logString() const >+{ >+ return debugString("HistoryItem current URL ", urlString(), ", identifier ", m_identifier.logString()); >+} >+#endif >+ > } // namespace WebCore > > #ifndef NDEBUG >diff --git a/Source/WebCore/history/HistoryItem.h b/Source/WebCore/history/HistoryItem.h >index ee466c7f14d1bf8e74c095f126cb9a75a65f7e68..e72b589394981ecec4107f6d62b77c9d7438351d 100644 >--- a/Source/WebCore/history/HistoryItem.h >+++ b/Source/WebCore/history/HistoryItem.h >@@ -215,6 +215,10 @@ public: > void setWasRestoredFromSession(bool wasRestoredFromSession) { m_wasRestoredFromSession = wasRestoredFromSession; } > bool wasRestoredFromSession() const { return m_wasRestoredFromSession; } > >+#if !LOG_DISABLED >+ const char* logString() const; >+#endif >+ > private: > WEBCORE_EXPORT HistoryItem(); > WEBCORE_EXPORT HistoryItem(const String& urlString, const String& title); >diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp >index 1b7a099307317386aeb57219a74d76a0156988d4..0a5aff2181acf02e78963ed472d4b64e6435eb61 100644 >--- a/Source/WebCore/loader/FrameLoader.cpp >+++ b/Source/WebCore/loader/FrameLoader.cpp >@@ -3528,7 +3528,11 @@ void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, FrameLoadType loa > if (CachedPage* cachedPage = PageCache::singleton().get(item, m_frame.page())) { > auto documentLoader = cachedPage->documentLoader(); > m_client.updateCachedDocumentLoader(*documentLoader); >- documentLoader->setTriggeringAction({ *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false }); >+ >+ auto action = NavigationAction { *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false }; >+ action.setTargetBackForwardItem(item); >+ documentLoader->setTriggeringAction(WTFMove(action)); >+ > documentLoader->setLastCheckedRequest(ResourceRequest()); > loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes, navigationPolicyCheck, [] { }); > return; >@@ -3616,6 +3620,8 @@ void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, FrameLoadType loa > action = { *m_frame.document(), requestForOriginalURL, initiatedByMainFrame, loadType, isFormSubmission, event, shouldOpenExternalURLsPolicy }; > } > >+ action.setTargetBackForwardItem(item); >+ > loadWithNavigationAction(request, action, LockHistory::No, loadType, 0, AllowNavigationToInvalidURL::Yes, [] { }); > } > >diff --git a/Source/WebCore/loader/NavigationAction.cpp b/Source/WebCore/loader/NavigationAction.cpp >index 71f13fcfbb5992fe3c0c787f52c06cc37ccafa39..8fcdb4861098bc54973885456a588e7875b2897c 100644 >--- a/Source/WebCore/loader/NavigationAction.cpp >+++ b/Source/WebCore/loader/NavigationAction.cpp >@@ -32,6 +32,7 @@ > #include "Document.h" > #include "Event.h" > #include "FrameLoader.h" >+#include "HistoryItem.h" > > namespace WebCore { > >@@ -95,4 +96,9 @@ NavigationAction NavigationAction::copyWithShouldOpenExternalURLsPolicy(ShouldOp > return result; > } > >+void NavigationAction::setTargetBackForwardItem(HistoryItem& item) >+{ >+ m_targetBackForwardItemIdentifier = item.identifier(); >+} >+ > } >diff --git a/Source/WebCore/loader/NavigationAction.h b/Source/WebCore/loader/NavigationAction.h >index a5af33456b0126d67ddf629da67e9e339618e04c..234108b23f078018d462b2d6079382fb529f4fcf 100644 >--- a/Source/WebCore/loader/NavigationAction.h >+++ b/Source/WebCore/loader/NavigationAction.h >@@ -28,6 +28,7 @@ > > #pragma once > >+#include "BackForwardItemIdentifier.h" > #include "FrameLoaderTypes.h" > #include "ResourceRequest.h" > #include "UserGestureIndicator.h" >@@ -37,6 +38,7 @@ namespace WebCore { > > class Document; > class Event; >+class HistoryItem; > > class NavigationAction { > public: >@@ -80,6 +82,9 @@ public: > void setOpener(std::optional<std::pair<uint64_t, uint64_t>>&& opener) { m_opener = WTFMove(opener); } > const std::optional<std::pair<uint64_t, uint64_t>>& opener() const { return m_opener; } > >+ void setTargetBackForwardItem(HistoryItem&); >+ const std::optional<BackForwardItemIdentifier>& targetBackForwardItemIdentifier() const { return m_targetBackForwardItemIdentifier; } >+ > private: > RefPtr<Document> m_sourceDocument; > ResourceRequest m_resourceRequest; >@@ -92,6 +97,7 @@ private: > bool m_treatAsSameOriginNavigation; > bool m_isCrossOriginWindowOpenNavigation { false }; > std::optional<std::pair<uint64_t /* pageID */, uint64_t /* frameID */>> m_opener; >+ std::optional<BackForwardItemIdentifier> m_targetBackForwardItemIdentifier; > }; > > } // namespace WebCore >diff --git a/Source/WebKit/Shared/NavigationActionData.cpp b/Source/WebKit/Shared/NavigationActionData.cpp >index 5133c42c3e5bbc0b107415676dd6aaaa10ca22b8..e61b2acaa1f70e7d05bca7fb4990aed2950714d6 100644 >--- a/Source/WebKit/Shared/NavigationActionData.cpp >+++ b/Source/WebKit/Shared/NavigationActionData.cpp >@@ -50,6 +50,7 @@ void NavigationActionData::encode(IPC::Encoder& encoder) const > encoder << treatAsSameOriginNavigation; > encoder << isCrossOriginWindowOpenNavigation; > encoder << opener; >+ encoder << targetBackForwardItemIdentifier; > } > > std::optional<NavigationActionData> NavigationActionData::decode(IPC::Decoder& decoder) >@@ -113,9 +114,14 @@ std::optional<NavigationActionData> NavigationActionData::decode(IPC::Decoder& d > if (!opener) > return std::nullopt; > >+ std::optional<std::optional<BackForwardItemIdentifier>> targetBackForwardItemIdentifier; >+ decoder >> targetBackForwardItemIdentifier; >+ if (!targetBackForwardItemIdentifier) >+ return std::nullopt; >+ > return {{ WTFMove(navigationType), WTFMove(modifiers), WTFMove(mouseButton), WTFMove(syntheticClickType), WTFMove(*userGestureTokenIdentifier), > WTFMove(*canHandleRequest), WTFMove(shouldOpenExternalURLsPolicy), WTFMove(*downloadAttribute), WTFMove(clickLocationInRootViewCoordinates), >- WTFMove(*isRedirect), *treatAsSameOriginNavigation, *isCrossOriginWindowOpenNavigation, WTFMove(*opener) }}; >+ WTFMove(*isRedirect), *treatAsSameOriginNavigation, *isCrossOriginWindowOpenNavigation, WTFMove(*opener), WTFMove(*targetBackForwardItemIdentifier) }}; > } > > } // namespace WebKit >diff --git a/Source/WebKit/Shared/NavigationActionData.h b/Source/WebKit/Shared/NavigationActionData.h >index c23132711fbcaf1ca1eb5043c3f5d5a73040df23..bf73982dd710b1507663ada305057318883fe492 100644 >--- a/Source/WebKit/Shared/NavigationActionData.h >+++ b/Source/WebKit/Shared/NavigationActionData.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "WebEvent.h" >+#include <WebCore/BackForwardItemIdentifier.h> > #include <WebCore/FloatPoint.h> > #include <WebCore/FrameLoaderTypes.h> > >@@ -53,6 +54,7 @@ struct NavigationActionData { > bool treatAsSameOriginNavigation { false }; > bool isCrossOriginWindowOpenNavigation { false }; > std::optional<std::pair<uint64_t, uint64_t>> opener; >+ std::optional<WebCore::BackForwardItemIdentifier> targetBackForwardItemIdentifier; > }; > > } >diff --git a/Source/WebKit/UIProcess/API/APINavigation.h b/Source/WebKit/UIProcess/API/APINavigation.h >index 1ea94d6d92988b4cfc8aa9df9b46cb3c7aa61711..9e5917710e58c384cb57aeaf26f21ada119363cd 100644 >--- a/Source/WebKit/UIProcess/API/APINavigation.h >+++ b/Source/WebKit/UIProcess/API/APINavigation.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "APIObject.h" >+#include "WebBackForwardListItem.h" > #include <WebCore/Process.h> > #include <WebCore/ResourceRequest.h> > #include <wtf/Ref.h> >@@ -35,7 +36,6 @@ enum class FrameLoadType; > } > > namespace WebKit { >-class WebBackForwardListItem; > class WebNavigationState; > } > >@@ -71,6 +71,7 @@ public: > void setCurrentRequestIsRedirect(bool isRedirect) { m_isRedirect = isRedirect; } > bool currentRequestIsRedirect() const { return m_isRedirect; } > >+ void setTargetItem(WebKit::WebBackForwardListItem& item) { m_targetItem = &item; } > WebKit::WebBackForwardListItem* targetItem() const { return m_targetItem.get(); } > WebKit::WebBackForwardListItem* fromItem() const { return m_fromItem.get(); } > std::optional<WebCore::FrameLoadType> backForwardFrameLoadType() const { return m_backForwardFrameLoadType; } >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >index a27a7b5eb4b2305f84529f8a1798215ab2655917..a9405f90812f77f1182cda7af8826f0bb1039a2f 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm >@@ -147,6 +147,11 @@ - (WKGeolocationProviderIOS *)_geolocationProvider > } > #endif // PLATFORM(IOS) > >+- (WKContextRef)_contextForTesting >+{ >+ return toAPI(_processPool.get()); >+} >+ > @end > > @implementation WKProcessPool (WKPrivate) >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolInternal.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolInternal.h >index 94548090a1963fcf1dd88831f86419cb68adbf69..a6383cb71e9b99e26bbc963e1676177ac17164ef 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolInternal.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolInternal.h >@@ -34,6 +34,8 @@ > @class WKGeolocationProviderIOS; > #endif > >+typedef const struct OpaqueWKContext* WKContextRef; >+ > namespace WebKit { > > inline WKProcessPool *wrapper(WebProcessPool& processPool) >@@ -52,6 +54,8 @@ inline WKProcessPool *wrapper(WebProcessPool& processPool) > #if TARGET_OS_IPHONE > @property(readonly) WKGeolocationProviderIOS *_geolocationProvider; > #endif >+ >+- (WKContextRef)_contextForTesting; > @end > > #endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index d7df4cf81669d23ec70f89f1a4e87d4fa4092aaf..a67ba08eebe49ef21a4a095781c94e84fb71cd2e 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -2423,7 +2423,7 @@ void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& fr > auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, action); > > if (proposedProcess.ptr() != &process()) { >- LOG(ProcessSwapping, "Switching from process %i to new process for navigation %" PRIu64 " '%s'", processIdentifier(), navigation->navigationID(), navigation->loggingString()); >+ LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), proposedProcess->processIdentifier(), navigation->navigationID(), navigation->loggingString()); > > RunLoop::main().dispatch([this, protectedThis = makeRef(*this), navigation = makeRef(*navigation), proposedProcess = WTFMove(proposedProcess)]() mutable { > continueNavigationInNewProcess(navigation.get(), WTFMove(proposedProcess)); >@@ -3964,8 +3964,22 @@ void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, const Secur > MESSAGE_CHECK(frame); > MESSAGE_CHECK_URL(request.url()); > MESSAGE_CHECK_URL(originalRequest.url()); >- >- Ref<API::Navigation> navigation = navigationID ? makeRef(m_navigationState->navigation(navigationID)) : m_navigationState->createLoadRequestNavigation(ResourceRequest(request), m_backForwardList->currentItem()); >+ >+ RefPtr<API::Navigation> navigation; >+ if (navigationID) >+ navigation = makeRef(m_navigationState->navigation(navigationID)); >+ >+ if (auto targetBackForwardItemIdentifier = navigationActionData.targetBackForwardItemIdentifier) { >+ if (auto* item = m_backForwardList->itemForID(*navigationActionData.targetBackForwardItemIdentifier)) { >+ if (!navigation) >+ navigation = m_navigationState->createBackForwardNavigation(*item, m_backForwardList->currentItem(), FrameLoadType::IndexedBackForward); >+ else >+ navigation->setTargetItem(*item); >+ } >+ } >+ >+ if (!navigation) >+ navigation = m_navigationState->createLoadRequestNavigation(ResourceRequest(request), m_backForwardList->currentItem()); > > uint64_t newNavigationID = navigation->navigationID(); > navigation->setWasUserInitiated(!!navigationActionData.userGestureTokenIdentifier); >@@ -3977,7 +3991,7 @@ void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, const Secur > navigation->setOpener(navigationActionData.opener); > > auto listener = makeRef(frame->setUpPolicyListenerProxy(listenerID, PolicyListenerType::NavigationAction)); >- listener->setNavigation(WTFMove(navigation)); >+ listener->setNavigation(navigation.releaseNonNull()); > > #if ENABLE(CONTENT_FILTERING) > if (frame->didHandleContentFilterUnblockNavigation(request)) >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index 11cc8bd5c2ceaf5132c1bfa498e8fa9129e620b3..ebdd04570609f333121721d16f7466f9c523e79e 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -59,6 +59,8 @@ > #include "UIGamepadProvider.h" > #include "WKContextPrivate.h" > #include "WebAutomationSession.h" >+#include "WebBackForwardList.h" >+#include "WebBackForwardListItem.h" > #include "WebCertificateInfo.h" > #include "WebContextSupplement.h" > #include "WebCookieManagerProxy.h" >@@ -2106,6 +2108,15 @@ Ref<WebProcessProxy> WebProcessPool::processForNavigationInternal(WebPageProxy& > action = PolicyAction::Suspend; > return *suspendedPage->process(); > } >+ >+ // If the target back/forward item and the current back/forward item originated >+ // in the same WebProcess then we should reuse the current WebProcess. >+ if (auto* currentItem = page.backForwardList().currentItem()) { >+ if (currentItem->itemID().processIdentifier == backForwardListItem->itemID().processIdentifier) { >+ action = PolicyAction::Suspend; >+ return page.process(); >+ } >+ } > } > > if (navigation.treatAsSameOriginNavigation()) >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index 338b69914a8451bc84bda76a2ee9f0ec34ce228a..d0fe918fb2b7f896050626aaafa089fae6e97bcc 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -867,6 +867,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat > navigationActionData.treatAsSameOriginNavigation = navigationAction.treatAsSameOriginNavigation(); > navigationActionData.isCrossOriginWindowOpenNavigation = navigationAction.isCrossOriginWindowOpenNavigation(); > navigationActionData.opener = navigationAction.opener(); >+ navigationActionData.targetBackForwardItemIdentifier = navigationAction.targetBackForwardItemIdentifier(); > > WebCore::Frame* coreFrame = m_frame->coreFrame(); > if (!coreFrame) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index adc8cfed2402339ebe305a5756c79f80c6f7206d..5bdad238bb24be037edfdbe999ef81ca31c70232 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,12 @@ >+2018-05-10 Brady Eidson <beidson@apple.com> >+ >+ Make sure history navigations reuse the existing process when necessary. >+ <rdar://problem/39746516> and https://bugs.webkit.org/show_bug.cgi?id=185532 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: >+ > 2018-05-10 Michael Catanzaro <mcatanzaro@igalia.com> > > Fix some -Wstring-op-truncation warnings >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >index 5db6b85568cead05faa799a345b940b335083f44..5495082b0ae98eb62af06b2c2c9ff77dc4a35b80 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm >@@ -54,6 +54,10 @@ > > #if WK_API_ENABLED > >+@interface WKProcessPool () >+- (WKContextRef)_contextForTesting; >+@end >+ > static bool done; > static bool failed; > static bool didCreateWebView; >@@ -1382,4 +1386,60 @@ TEST(ProcessSwap, NavigateToInvalidURL) > EXPECT_EQ(pid1, pid2); > } > >+static const char* navigateToDataURLThenBackBytes = R"PSONRESOURCE( >+<script> >+onpageshow = function(event) { >+ if (event.persisted) >+ window.webkit.messageHandlers.pson.postMessage("pageshow persisted"); >+ else >+ window.webkit.messageHandlers.pson.postMessage("pageshow NOT persisted"); >+ >+ // Location changes need to happen outside the onload handler to generate history entries. >+ setTimeout(function() { >+ window.location.href = "data:text/html,<body onload='history.back()'></body>"; >+ }, 0); >+} >+ >+</script> >+)PSONRESOURCE"; >+ >+TEST(ProcessSwap, NavigateToDataURLThenBack) >+{ >+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]); >+ processPoolConfiguration.get().processSwapsOnNavigation = YES; >+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); >+ >+ // Disable the page cache >+ auto context = [processPool _contextForTesting]; >+ WKContextSetCacheModel(context, kWKCacheModelDocumentViewer); >+ >+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ [webViewConfiguration setProcessPool:processPool.get()]; >+ RetainPtr<PSONScheme> handler = adoptNS([[PSONScheme alloc] initWithBytes:navigateToDataURLThenBackBytes]); >+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; >+ >+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); >+ auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]); >+ [webView setNavigationDelegate:navigationDelegate.get()]; >+ >+ numberOfDecidePolicyCalls = 0; >+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://host/main1.html"]]]; >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ auto pid1 = [webView _webProcessIdentifier]; >+ >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ auto pid2 = [webView _webProcessIdentifier]; >+ >+ TestWebKitAPI::Util::run(&done); >+ done = false; >+ auto pid3 = [webView _webProcessIdentifier]; >+ >+ EXPECT_EQ(3, numberOfDecidePolicyCalls); >+ EXPECT_EQ(1u, seenPIDs.size()); >+ EXPECT_EQ(pid1, pid2); >+ EXPECT_EQ(pid2, pid3); >+} >+ > #endif // WK_API_ENABLED
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185532
:
340140
|
340151
|
340224