+2019-01-25 Dean Jackson <dino@apple.com>
+
+ REGRESSION: Some USDz from 3rd party websites don't go directly to AR QL
+ https://bugs.webkit.org/show_bug.cgi?id=193831
+ <rdar://problem/47399263>
+
+ Reviewed by Chris Dumez.
+
+ A System Preview (<a rel="ar">) displays in a modal and doesn't trigger
+ a navigation. If the link was cross origin, it was causing a process swap,
+ which meant that the response defaulted back to a navigation.
+
+ The fix is to not cause a PSON when the navigation is a system preview.
+
+ * UIProcess/API/APINavigation.h:
+ (API::Navigation::shouldForceDownload const): This is now just tracking
+ the "download" attribute, and not including System Preview.
+ (API::Navigation::isSystemPreview const): New method to check for a
+ navigation triggered as a System Preview.
+ * UIProcess/WebPageProxy.cpp: Move the code from receivedPolicyDecision to
+ receivedNavigationPolicyDecision, so that downloads and System Previews are
+ detected before we decide to change process.
+ (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+ (WebKit::WebPageProxy::receivedPolicyDecision):
+
2019-01-25 Tim Horton <timothy_horton@apple.com>
Find-in-page on nyt.com scrolls around without touching the screen when find holes are visible
changeWebsiteDataStore(policies->websiteDataStore()->websiteDataStore());
}
+ if (policyAction == PolicyAction::Use && navigation && (navigation->isSystemPreview() || navigation->shouldForceDownload()))
+ policyAction = PolicyAction::Download;
+
if (policyAction != PolicyAction::Use || !frame.isMainFrame() || !navigation) {
receivedPolicyDecision(policyAction, navigation, WTFMove(data), WTFMove(sender));
return;
if (action == PolicyAction::Ignore)
m_pageLoadState.clearPendingAPIRequestURL(transaction);
- if (navigation && navigation->shouldForceDownload() && action == PolicyAction::Use)
- action = PolicyAction::Download;
-
DownloadID downloadID = { };
if (action == PolicyAction::Download) {
// Create a download proxy.
done = false;
}
+#if USE(SYSTEM_PREVIEW)
+
+static const char* systemPreviewSameOriginTestBytes = R"PSONRESOURCE(
+<body>
+ <a id="testLink" rel="ar" href="pson://www.webkit.org/whatever">
+ <img src="http://www.webkit.org/image">
+ </a>
+</body>
+)PSONRESOURCE";
+
+static const char* systemPreviewCrossOriginTestBytes = R"PSONRESOURCE(
+<body>
+ <a id="testLink" rel="ar" href="pson://www.apple.com/whatever">
+ <img src="http://www.webkit.org/image">
+ </a>
+</body>
+)PSONRESOURCE";
+
+TEST(ProcessSwap, SameOriginSystemPreview)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ processPoolConfiguration.get().processSwapsOnNavigation = YES;
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ auto handler = adoptNS([[PSONScheme alloc] init]);
+ [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:systemPreviewSameOriginTestBytes];
+ [handler addMappingFromURLString:@"pson://www.webkit.org/whatever" toData:"Fake USDZ data"];
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"];
+
+ [webViewConfiguration _setSystemPreviewEnabled:YES];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:navigationDelegate.get()];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ auto pidAfterFirstLoad = [webView _webProcessIdentifier];
+
+ didStartProvisionalLoad = false;
+ [webView evaluateJavaScript:@"testLink.click()" completionHandler:nil];
+
+ TestWebKitAPI::Util::sleep(0.5);
+
+ // We should still be on webkit.org.
+ EXPECT_EQ(pidAfterFirstLoad, [webView _webProcessIdentifier]);
+ EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [[webView URL] absoluteString]);
+ EXPECT_FALSE(didStartProvisionalLoad);
+}
+
+TEST(ProcessSwap, CrossOriginSystemPreview)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ processPoolConfiguration.get().processSwapsOnNavigation = YES;
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ auto handler = adoptNS([[PSONScheme alloc] init]);
+ [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:systemPreviewCrossOriginTestBytes];
+ [handler addMappingFromURLString:@"pson://www.apple.com/whatever" toData:"Fake USDZ data"];
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"];
+
+ [webViewConfiguration _setSystemPreviewEnabled:YES];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto navigationDelegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:navigationDelegate.get()];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+ [webView loadRequest:request];
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ auto pidAfterFirstLoad = [webView _webProcessIdentifier];
+
+ didStartProvisionalLoad = false;
+ [webView evaluateJavaScript:@"testLink.click()" completionHandler:nil];
+
+ TestWebKitAPI::Util::sleep(0.5);
+
+ // We should still be on webkit.org.
+ EXPECT_EQ(pidAfterFirstLoad, [webView _webProcessIdentifier]);
+ EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [[webView URL] absoluteString]);
+ EXPECT_FALSE(didStartProvisionalLoad);
+}
+
+#endif
+
enum class ShouldEnablePSON { No, Yes };
static void runClientSideRedirectTest(ShouldEnablePSON shouldEnablePSON)
{