Changeset 291606 in webkit
- Timestamp:
- Mar 22, 2022 12:44:10 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APINavigation.h (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (10 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r291604 r291606 1 2022-03-22 Youenn Fablet <youenn@apple.com> 2 3 Website policies are not respected when doing COOP based process swap 4 https://bugs.webkit.org/show_bug.cgi?id=238036 5 <rdar://89616625> 6 7 Reviewed by Chris Dumez. 8 9 In case of normal process swap, we make use of website policies so everything is fine. 10 For COOP based process swap, this happens later on, at a point where we lost website policies. 11 To overcome this, we store the website policies used by a navigation inside the API::Navigation object. 12 It is used by continueNavigationInNewProcess to correctly initialize the new WebPage website policies. 13 We then set the website policies in the navigation object just before continuing the load in the same process, 14 as process swap may happen later when inspecting the response. 15 Minor refactoring in continueNavigationInNewProcess to get the policies directly from the given Navigation object. 16 Minor refactoring in receivedNavigationPolicyDecision to make the code doing process swap clearer. 17 18 Covered by API test. 19 20 * UIProcess/API/APINavigation.h: 21 (API::Navigation::setWebsitePoliciesForProcessSwap): 22 (API::Navigation::takeWebsitePoliciesForProcessSwap): 23 * UIProcess/WebPageProxy.cpp: 24 (WebKit::WebPageProxy::receivedNavigationPolicyDecision): 25 (WebKit::WebPageProxy::receivedPolicyDecision): 26 (WebKit::WebPageProxy::continueNavigationInNewProcess): 27 (WebKit::WebPageProxy::triggerBrowsingContextGroupSwitchForNavigation): 28 * UIProcess/WebPageProxy.h: 29 1 30 2022-03-21 Said Abou-Hallawa <said@apple.com> 2 31 -
trunk/Source/WebKit/UIProcess/API/APINavigation.h
r284610 r291606 27 27 28 28 #include "APIObject.h" 29 #include "APIWebsitePolicies.h" 29 30 #include "DataReference.h" 30 31 #include "FrameInfoData.h" … … 172 173 bool isLoadedWithNavigationShared() const { return m_isLoadedWithNavigationShared; } 173 174 175 void setWebsitePolicies(RefPtr<API::WebsitePolicies>&& policies) { m_websitePolicies = WTFMove(policies); } 176 API::WebsitePolicies* websitePolicies() { return m_websitePolicies.get(); } 177 174 178 private: 175 179 explicit Navigation(WebKit::WebNavigationState&); … … 198 202 WebKit::ProcessThrottler::TimedActivity m_clientNavigationActivity; 199 203 bool m_isLoadedWithNavigationShared { false }; 204 RefPtr<API::WebsitePolicies> m_websitePolicies; 200 205 }; 201 206 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r291491 r291606 3423 3423 } 3424 3424 3425 void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, Ref<API::NavigationAction>&& navigationAction, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, const FrameInfoData& frameInfo, Ref Ptr<API::WebsitePolicies>&& policies, Ref<PolicyDecisionSender>&& sender)3425 void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, Ref<API::NavigationAction>&& navigationAction, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, const FrameInfoData& frameInfo, Ref<PolicyDecisionSender>&& sender) 3426 3426 { 3427 3427 WEBPAGEPROXY_RELEASE_LOG(Loading, "receivedNavigationPolicyDecision: frameID=%llu, isMainFrame=%d, navigationID=%llu, policyAction=%u", frame.frameID().toUInt64(), frame.isMainFrame(), navigation ? navigation->navigationID() : 0, (unsigned)policyAction); 3428 3428 3429 3429 Ref<WebsiteDataStore> websiteDataStore = m_websiteDataStore.copyRef(); 3430 if ( policies) {3430 if (auto* policies = navigation->websitePolicies()) { 3431 3431 if (policies->websiteDataStore() && policies->websiteDataStore() != websiteDataStore.ptr()) { 3432 3432 websiteDataStore = *policies->websiteDataStore(); … … 3438 3438 3439 3439 if (navigation && !navigation->userContentExtensionsEnabled()) { 3440 if (! policies)3441 policies = API::WebsitePolicies::create();3442 policies->setContentBlockersEnabled(false);3440 if (!navigation->websitePolicies()) 3441 navigation->setWebsitePolicies(API::WebsitePolicies::create()); 3442 navigation->websitePolicies()->setContentBlockersEnabled(false); 3443 3443 } 3444 3444 3445 3445 #if ENABLE(DEVICE_ORIENTATION) 3446 if (navigation && (! policies || policies->deviceOrientationAndMotionAccessState() == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) {3446 if (navigation && (!navigation->websitePolicies() || navigation->websitePolicies()->deviceOrientationAndMotionAccessState() == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) { 3447 3447 auto deviceOrientationPermission = websiteDataStore->deviceOrientationAndMotionAccessController().cachedDeviceOrientationPermission(SecurityOriginData::fromURL(navigation->currentRequest().url())); 3448 3448 if (deviceOrientationPermission != WebCore::DeviceOrientationOrMotionPermissionState::Prompt) { 3449 if (! policies)3450 policies = API::WebsitePolicies::create();3451 policies->setDeviceOrientationAndMotionAccessState(deviceOrientationPermission);3449 if (!navigation->websitePolicies()) 3450 navigation->setWebsitePolicies(API::WebsitePolicies::create()); 3451 navigation->websitePolicies()->setDeviceOrientationAndMotionAccessState(deviceOrientationPermission); 3452 3452 } 3453 3453 } … … 3463 3463 3464 3464 if (policyAction != PolicyAction::Use || !frame.isMainFrame() || !navigation) { 3465 receivedPolicyDecision(policyAction, navigation, WTFMove(policies), WTFMove(navigationAction), WTFMove(sender));3465 receivedPolicyDecision(policyAction, navigation, navigation->websitePolicies(), WTFMove(navigationAction), WTFMove(sender)); 3466 3466 return; 3467 3467 } … … 3476 3476 } 3477 3477 3478 m_isCaptivePortalModeExplicitlySet = (policies && policies->isCaptivePortalModeExplicitlySet()) || m_configuration->isCaptivePortalModeExplicitlySet(); 3479 auto captivePortalMode = (policies ? policies->captivePortalModeEnabled() : shouldEnableCaptivePortalMode()) ? WebProcessProxy::CaptivePortalMode::Enabled : WebProcessProxy::CaptivePortalMode::Disabled; 3480 process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, captivePortalMode, frameInfo, WTFMove(websiteDataStore), [this, protectedThis = Ref { *this }, policyAction, navigation = Ref { *navigation }, navigationAction = WTFMove(navigationAction), sourceProcess = sourceProcess.copyRef(), 3481 policies = WTFMove(policies), sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable { 3478 m_isCaptivePortalModeExplicitlySet = (navigation->websitePolicies() && navigation->websitePolicies()->isCaptivePortalModeExplicitlySet()) || m_configuration->isCaptivePortalModeExplicitlySet(); 3479 auto captivePortalMode = (navigation->websitePolicies() ? navigation->websitePolicies()->captivePortalModeEnabled() : shouldEnableCaptivePortalMode()) ? WebProcessProxy::CaptivePortalMode::Enabled : WebProcessProxy::CaptivePortalMode::Disabled; 3480 process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, captivePortalMode, frameInfo, WTFMove(websiteDataStore), [this, protectedThis = Ref { *this }, policyAction, navigation = Ref { *navigation }, navigationAction = WTFMove(navigationAction), sourceProcess = sourceProcess.copyRef(), sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable { 3482 3481 // If the navigation has been destroyed, then no need to proceed. 3483 3482 if (isClosed() || !navigationState().hasNavigation(navigation->navigationID())) { 3484 receivedPolicyDecision(policyAction, navigation.ptr(), WTFMove(policies), WTFMove(navigationAction), WTFMove(sender));3483 receivedPolicyDecision(policyAction, navigation.ptr(), navigation->websitePolicies(), WTFMove(navigationAction), WTFMove(sender)); 3485 3484 return; 3486 3485 } … … 3494 3493 WEBPAGEPROXY_RELEASE_LOG(ProcessSwapping, "decidePolicyForNavigationAction: keep using process %i for navigation, reason=%" PUBLIC_LOG_STRING, processIdentifier(), reason.utf8().data()); 3495 3494 3496 std::optional<SandboxExtension::Handle> optionalHandle;3497 3495 if (shouldProcessSwap) { 3498 3496 // Make sure the process to be used for the navigation does not get shutDown now due to destroying SuspendedPageProxy or ProvisionalPageProxy objects. … … 3512 3510 suspendedPage = nullptr; 3513 3511 3514 continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision, std::exchange(policies, nullptr)); 3515 } else { 3516 auto item = navigation->reloadItem() ? navigation->reloadItem() : navigation->targetItem(); 3517 if (policyAction == PolicyAction::Use && item) { 3518 URL fullURL { item->url() }; 3519 if (fullURL.protocolIs("file"_s)) { 3520 SandboxExtension::Handle sandboxExtensionHandle; 3521 maybeInitializeSandboxExtensionHandle(processForNavigation.get(), fullURL, item->resourceDirectoryURL(), sandboxExtensionHandle); 3522 optionalHandle = WTFMove(sandboxExtensionHandle); 3523 } 3512 continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision); 3513 3514 receivedPolicyDecision(policyAction, navigation.ptr(), nullptr, WTFMove(navigationAction), WTFMove(sender), WillContinueLoadInNewProcess::Yes); 3515 return; 3516 } 3517 3518 auto item = navigation->reloadItem() ? navigation->reloadItem() : navigation->targetItem(); 3519 std::optional<SandboxExtension::Handle> optionalHandle; 3520 if (policyAction == PolicyAction::Use && item) { 3521 URL fullURL { item->url() }; 3522 if (fullURL.protocolIs("file"_s)) { 3523 SandboxExtension::Handle sandboxExtensionHandle; 3524 maybeInitializeSandboxExtensionHandle(processForNavigation.get(), fullURL, item->resourceDirectoryURL(), sandboxExtensionHandle); 3525 optionalHandle = WTFMove(sandboxExtensionHandle); 3524 3526 } 3525 3527 } 3526 3528 3527 receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? nullptr : WTFMove(policies), WTFMove(navigationAction), WTFMove(sender), WTFMove(optionalHandle), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);3529 receivedPolicyDecision(policyAction, navigation.ptr(), navigation->websitePolicies(), WTFMove(navigationAction), WTFMove(sender), WillContinueLoadInNewProcess::No, WTFMove(optionalHandle)); 3528 3530 }); 3529 3531 } 3530 3532 3531 void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, RefPtr<API::WebsitePolicies>&& websitePolicies, std::variant<Ref<API::NavigationResponse>, Ref<API::NavigationAction>>&& navigationActionOrResponse, Ref<PolicyDecisionSender>&& sender, std::optional<SandboxExtension::Handle> sandboxExtensionHandle, WillContinueLoadInNewProcess willContinueLoadInNewProcess)3533 void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, RefPtr<API::WebsitePolicies>&& websitePolicies, std::variant<Ref<API::NavigationResponse>, Ref<API::NavigationAction>>&& navigationActionOrResponse, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess, std::optional<SandboxExtension::Handle> sandboxExtensionHandle) 3532 3534 { 3533 3535 if (!hasRunningProcess()) { … … 3619 3621 } 3620 3622 3621 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, RefPtr<API::WebsitePolicies>&& websitePolicies,std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume)3623 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad, std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume) 3622 3624 { 3623 3625 WEBPAGEPROXY_RELEASE_LOG(Loading, "continueNavigationInNewProcess: newProcessPID=%i, hasSuspendedPage=%i", newProcess->processIdentifier(), !!suspendedPage); … … 3633 3635 } 3634 3636 3637 RefPtr websitePolicies = navigation.websitePolicies(); 3635 3638 bool isServerSideRedirect = shouldTreatAsContinuingLoad == ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision && navigation.currentRequestIsRedirect(); 3636 3639 bool isProcessSwappingOnNavigationResponse = shouldTreatAsContinuingLoad == ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted; … … 5494 5497 WEBPAGEPROXY_RELEASE_LOG(Loading, "decidePolicyForNavigationAction: listener called: frameID=%llu, isMainFrame=%d, navigationID=%llu, policyAction=%u, safeBrowsingWarning=%d, isAppBoundDomain=%d", frame->frameID().toUInt64(), frame->isMainFrame(), navigation ? navigation->navigationID() : 0, (unsigned)policyAction, !!safeBrowsingWarning, !!isAppBoundDomain); 5495 5498 5496 auto completionHandler = [this, protectedThis, frame, frameInfo, sender = WTFMove(sender), navigation, navigationAction = WTFMove(navigationAction), processSwapRequestedByClient, policies = RefPtr { policies }] (PolicyAction policyAction) mutable { 5499 navigation->setWebsitePolicies(WTFMove(policies)); 5500 auto completionHandler = [this, protectedThis, frame, frameInfo, sender = WTFMove(sender), navigation, navigationAction = WTFMove(navigationAction), processSwapRequestedByClient] (PolicyAction policyAction) mutable { 5497 5501 if (frame->isMainFrame()) { 5498 if (! policies) {5502 if (!navigation->websitePolicies()) { 5499 5503 if (auto* defaultPolicies = m_configuration->defaultWebsitePolicies()) 5500 policies = defaultPolicies->copy();5504 navigation->setWebsitePolicies(defaultPolicies->copy()); 5501 5505 } 5502 if ( policies)5506 if (auto* policies = navigation->websitePolicies()) 5503 5507 navigation->setEffectiveContentMode(effectiveContentModeAfterAdjustingPolicies(*policies, navigation->currentRequest())); 5504 5508 } 5505 receivedNavigationPolicyDecision(policyAction, navigation.get(), WTFMove(navigationAction), processSwapRequestedByClient, frame, frameInfo, WTFMove( policies), WTFMove(sender));5509 receivedNavigationPolicyDecision(policyAction, navigation.get(), WTFMove(navigationAction), processSwapRequestedByClient, frame, frameInfo, WTFMove(sender)); 5506 5510 }; 5507 5511 … … 5766 5770 if (!m_provisionalPage) 5767 5771 send(Messages::WebPage::StopLoadingDueToProcessSwap()); 5768 continueNavigationInNewProcess(*navigation, nullptr, processForNavigation.releaseNonNull(), ProcessSwapRequestedByClient::No, ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted, nullptr,existingNetworkResourceLoadIdentifierToResume);5772 continueNavigationInNewProcess(*navigation, nullptr, processForNavigation.releaseNonNull(), ProcessSwapRequestedByClient::No, ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted, existingNetworkResourceLoadIdentifierToResume); 5769 5773 completionHandler(true); 5770 5774 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r291393 r291606 1271 1271 class PolicyDecisionSender; 1272 1272 enum class WillContinueLoadInNewProcess : bool { No, Yes }; 1273 void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, RefPtr<API::WebsitePolicies>&&, std::variant<Ref<API::NavigationResponse>, Ref<API::NavigationAction>>&&, Ref<PolicyDecisionSender>&&, std::optional<SandboxExtension::Handle> = { }, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);1274 void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, Ref<API::NavigationAction>&&, ProcessSwapRequestedByClient, WebFrameProxy&, const FrameInfoData&, Ref Ptr<API::WebsitePolicies>&&, Ref<PolicyDecisionSender>&&);1273 void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, RefPtr<API::WebsitePolicies>&&, std::variant<Ref<API::NavigationResponse>, Ref<API::NavigationAction>>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No, std::optional<SandboxExtension::Handle> = { }); 1274 void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, Ref<API::NavigationAction>&&, ProcessSwapRequestedByClient, WebFrameProxy&, const FrameInfoData&, Ref<PolicyDecisionSender>&&); 1275 1275 1276 1276 void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&); … … 2555 2555 void reportPageLoadResult(const WebCore::ResourceError& = { }); 2556 2556 2557 void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, WebCore::ShouldTreatAsContinuingLoad, RefPtr<API::WebsitePolicies>&&,std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume = std::nullopt);2557 void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, WebCore::ShouldTreatAsContinuingLoad, std::optional<NetworkResourceLoadIdentifier> existingNetworkResourceLoadIdentifierToResume = std::nullopt); 2558 2558 2559 2559 void setNeedsFontAttributes(bool); -
trunk/Tools/ChangeLog
r291604 r291606 1 2022-03-22 Youenn Fablet <youenn@apple.com> 2 3 Website policies are not respected when doing COOP based process swap 4 https://bugs.webkit.org/show_bug.cgi?id=238036 5 <rdar://89616625> 6 7 Reviewed by Chris Dumez. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 10 1 11 2022-03-21 Said Abou-Hallawa <said@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r291579 r291606 8309 8309 8310 8310 #endif 8311 8312 #if PLATFORM(IOS_FAMILY) 8313 TEST(ProcessSwap, ContentModeInCaseOfCoopProcessSwap) 8314 { 8315 using namespace TestWebKitAPI; 8316 8317 HTTPServer server({ 8318 { "/source.html", { "foo" } }, 8319 { "/destination.html", { { { "Content-Type", "text/html" }, { "Cross-Origin-Opener-Policy", "same-origin" } }, "bar" } }, 8320 }, HTTPServer::Protocol::Https); 8321 8322 auto processPoolConfiguration = psonProcessPoolConfiguration(); 8323 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 8324 8325 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 8326 [webViewConfiguration setProcessPool:processPool.get()]; 8327 8328 auto webpagePreferences = adoptNS([[WKWebpagePreferences alloc] init]); 8329 [webpagePreferences setPreferredContentMode:WKContentModeDesktop]; 8330 [webViewConfiguration setDefaultWebpagePreferences:webpagePreferences.get()]; 8331 8332 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768) configuration:webViewConfiguration.get()]); 8333 auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]); 8334 [webView setNavigationDelegate:navigationDelegate.get()]; 8335 8336 done = false; 8337 [webView loadRequest:server.request("/source.html")]; 8338 Util::run(&done); 8339 done = false; 8340 8341 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8342 done = true; 8343 8344 ASSERT_TRUE(!error); 8345 NSString *userAgent = (NSString *)response; 8346 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8347 }]; 8348 Util::run(&done); 8349 done = false; 8350 8351 auto pid1 = [webView _webProcessIdentifier]; 8352 8353 [webView loadRequest:server.request("/destination.html")]; 8354 Util::run(&done); 8355 done = false; 8356 8357 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8358 done = true; 8359 8360 ASSERT_TRUE(!error); 8361 NSString *userAgent = (NSString *)response; 8362 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8363 }]; 8364 Util::run(&done); 8365 done = false; 8366 8367 auto pid2 = [webView _webProcessIdentifier]; 8368 EXPECT_NE(pid1, pid2); 8369 8370 [webView goBack]; // Back to source.html. 8371 Util::run(&done); 8372 done = false; 8373 8374 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8375 done = true; 8376 8377 ASSERT_TRUE(!error); 8378 NSString *userAgent = (NSString *)response; 8379 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8380 }]; 8381 Util::run(&done); 8382 done = false; 8383 } 8384 8385 TEST(ProcessSwap, ContentModeInCaseOfPSONThenCoopProcessSwap) 8386 { 8387 using namespace TestWebKitAPI; 8388 8389 HTTPServer server1({ 8390 { "/source.html", { "foo" } }, 8391 }, HTTPServer::Protocol::Https); 8392 8393 HTTPServer server2({ 8394 { "/destination.html", { { { "Content-Type", "text/html" }, { "Cross-Origin-Opener-Policy", "same-origin" } }, "bar" } }, 8395 }, HTTPServer::Protocol::Http); 8396 8397 auto processPoolConfiguration = psonProcessPoolConfiguration(); 8398 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 8399 8400 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 8401 [webViewConfiguration setProcessPool:processPool.get()]; 8402 8403 auto webpagePreferences = adoptNS([[WKWebpagePreferences alloc] init]); 8404 [webpagePreferences setPreferredContentMode:WKContentModeDesktop]; 8405 [webViewConfiguration setDefaultWebpagePreferences:webpagePreferences.get()]; 8406 8407 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768) configuration:webViewConfiguration.get()]); 8408 auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]); 8409 [webView setNavigationDelegate:navigationDelegate.get()]; 8410 8411 done = false; 8412 [webView loadRequest:server1.request("/source.html")]; 8413 Util::run(&done); 8414 done = false; 8415 8416 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8417 done = true; 8418 8419 ASSERT_TRUE(!error); 8420 NSString *userAgent = (NSString *)response; 8421 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8422 }]; 8423 Util::run(&done); 8424 done = false; 8425 8426 auto pid1 = [webView _webProcessIdentifier]; 8427 8428 [webView loadRequest:server2.request("/destination.html")]; 8429 Util::run(&done); 8430 done = false; 8431 8432 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8433 done = true; 8434 8435 ASSERT_TRUE(!error); 8436 NSString *userAgent = (NSString *)response; 8437 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8438 }]; 8439 Util::run(&done); 8440 done = false; 8441 8442 auto pid2 = [webView _webProcessIdentifier]; 8443 EXPECT_NE(pid1, pid2); 8444 8445 [webView goBack]; // Back to source.html. 8446 Util::run(&done); 8447 done = false; 8448 8449 [webView evaluateJavaScript:@"navigator.userAgent;" completionHandler:^(id _Nullable response, NSError * _Nullable error) { 8450 done = true; 8451 8452 ASSERT_TRUE(!error); 8453 NSString *userAgent = (NSString *)response; 8454 ASSERT_TRUE([userAgent containsString:@"Macintosh; Intel Mac"]); 8455 }]; 8456 Util::run(&done); 8457 done = false; 8458 } 8459 #endif // PLATFORM(IOS_FAMILY)
Note: See TracChangeset
for help on using the changeset viewer.