Changeset 242181 in webkit
- Timestamp:
- Feb 27, 2019 4:50:30 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242176 r242181 1 2019-02-27 Brady Eidson <beidson@apple.com> 2 3 Universal links from Google search results pages don't open the app. 4 <rdar://problem/46887179> and https://bugs.webkit.org/show_bug.cgi?id=195126 5 6 Reviewed by Geoffrey Garen. 7 8 Covered by new API tests. 9 10 * loader/DocumentLoader.cpp: 11 (WebCore::DocumentLoader::shouldOpenExternalURLsPolicyToPropagate const): Propagate the external URL policy from 12 an iframe if it is from the same security origin as the main frame. 13 1 14 2019-02-27 Zalan Bujtas <zalan@apple.com> 2 15 -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r241932 r242181 2077 2077 ShouldOpenExternalURLsPolicy DocumentLoader::shouldOpenExternalURLsPolicyToPropagate() const 2078 2078 { 2079 if (!m_frame || !m_frame->isMainFrame())2079 if (!m_frame) 2080 2080 return ShouldOpenExternalURLsPolicy::ShouldNotAllow; 2081 2081 2082 return m_shouldOpenExternalURLsPolicy; 2082 if (m_frame->isMainFrame()) 2083 return m_shouldOpenExternalURLsPolicy; 2084 2085 if (auto* currentDocument = document()) { 2086 if (originsMatch(currentDocument->securityOrigin(), currentDocument->topOrigin())) 2087 return m_shouldOpenExternalURLsPolicy; 2088 } 2089 2090 return ShouldOpenExternalURLsPolicy::ShouldNotAllow; 2083 2091 } 2084 2092 -
trunk/Tools/ChangeLog
r242180 r242181 1 2019-02-27 Brady Eidson <beidson@apple.com> 2 3 Universal links from Google search results pages don't open the app. 4 <rdar://problem/46887179> and https://bugs.webkit.org/show_bug.cgi?id=195126 5 6 Reviewed by Geoffrey Garen. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/ShouldOpenExternalURLsInNewWindowActions.mm: 9 * TestWebKitAPI/cocoa/TestNavigationDelegate.h: 10 * TestWebKitAPI/cocoa/TestNavigationDelegate.mm: 11 (-[TestNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]): 12 1 13 2019-02-27 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ShouldOpenExternalURLsInNewWindowActions.mm
r221505 r242181 29 29 30 30 #import "PlatformUtilities.h" 31 #import "TestNavigationDelegate.h" 32 #import "TestURLSchemeHandler.h" 31 33 #import <WebKit/WKNavigationActionPrivate.h> 32 34 #import <WebKit/WKWebViewPrivate.h> … … 251 253 }; 252 254 255 256 257 static const char* iframeBytes = R"schemeresource( 258 <script> 259 top.location.href = "externalScheme://someotherhost/foo"; 260 </script> 261 )schemeresource"; 262 263 static const char* mainFrameBytes = R"schemeresource( 264 <script> 265 function clicked() { 266 var iframe = document.createElement('iframe'); 267 iframe.src = "custom://firsthost/iframe.html"; 268 document.body.appendChild(iframe); 269 } 270 </script> 271 272 <a style="display: block; height: 100%" onclick="clicked();">Click to start iframe dance</a> 273 )schemeresource"; 274 275 TEST(WebKit, IFrameWithSameOriginAsMainFramePropagates) 276 { 277 auto schemeHandler = adoptNS([[TestURLSchemeHandler alloc] init]); 278 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 279 [configuration setURLSchemeHandler:schemeHandler.get() forURLScheme:@"custom"]; 280 281 [schemeHandler setStartURLSchemeTaskHandler:^(WKWebView *, id<WKURLSchemeTask> task) { 282 NSURL *requestURL = [task request].URL; 283 284 NSString *responseText = nil; 285 if ([[task request].URL.absoluteString containsString:@"iframe.html"]) 286 responseText = [NSString stringWithUTF8String:iframeBytes]; 287 else if ([[task request].URL.absoluteString containsString:@"mainframe.html"]) 288 responseText = [NSString stringWithUTF8String:mainFrameBytes]; 289 290 auto response = adoptNS([[NSURLResponse alloc] initWithURL:requestURL MIMEType:@"text/html" expectedContentLength:[responseText length] textEncodingName:nil]); 291 [task didReceiveResponse:response.get()]; 292 [task didReceiveData:[responseText dataUsingEncoding:NSUTF8StringEncoding]]; 293 [task didFinish]; 294 }]; 295 296 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 297 auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]); 298 [webView setNavigationDelegate:navigationDelegate.get()]; 299 300 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"custom://firsthost/mainframe.html"]]]; 301 [navigationDelegate waitForDidFinishNavigation]; 302 303 // Install the decidePolicyListener 304 static bool openAppLinks; 305 static bool externalSchemes; 306 static bool finished = false; 307 navigationDelegate.get().decidePolicyForNavigationAction = ^(WKNavigationAction *action, void (^decisionHandler)(WKNavigationActionPolicy)) { 308 if (!action.targetFrame.mainFrame) { 309 decisionHandler(WKNavigationActionPolicyAllow); 310 return; 311 } 312 313 openAppLinks = [action _shouldOpenAppLinks]; 314 externalSchemes = [action _shouldOpenExternalSchemes]; 315 316 decisionHandler(WKNavigationActionPolicyCancel); 317 finished = true; 318 }; 319 320 // Click the link 321 NSPoint clickPoint = NSMakePoint(100, 100); 322 [[webView hitTest:clickPoint] mouseDown:[NSEvent mouseEventWithType:NSEventTypeLeftMouseDown location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[webView.get().window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]]; 323 [[webView hitTest:clickPoint] mouseUp:[NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[webView.get().window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]]; 324 325 TestWebKitAPI::Util::run(&finished); 326 327 ASSERT_TRUE(openAppLinks); 328 ASSERT_TRUE(externalSchemes); 329 }; 330 253 331 #endif 254 332 -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h
r231208 r242181 33 33 @interface TestNavigationDelegate : NSObject <WKNavigationDelegate> 34 34 35 @property (nonatomic, copy) void (^decidePolicyForNavigationAction)(WKNavigationAction *, void (^)(WKNavigationActionPolicy)); 35 36 @property (nonatomic, copy) void (^didFailProvisionalNavigation)(WKWebView *, WKNavigation *, NSError *); 36 37 @property (nonatomic, copy) void (^didStartProvisionalNavigation)(WKWebView *, WKNavigation *); -
trunk/Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm
r237266 r242181 33 33 34 34 @implementation TestNavigationDelegate 35 36 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler 37 { 38 if (_decidePolicyForNavigationAction) 39 _decidePolicyForNavigationAction(navigationAction, decisionHandler); 40 else 41 decisionHandler(WKNavigationActionPolicyAllow); 42 } 35 43 36 44 - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
Note: See TracChangeset
for help on using the changeset viewer.