Changeset 229341 in webkit
- Timestamp:
- Mar 6, 2018 2:01:27 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r229335 r229341 1 2018-03-06 Chris Dumez <cdumez@apple.com> 2 3 fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates 4 https://bugs.webkit.org/show_bug.cgi?id=183345 5 6 Reviewed by Alex Christensen. 7 8 * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added. 9 * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html: Added. 10 Add layout test coverage. 11 12 * fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: 13 * fast/loader/redirect-to-invalid-url-using-javascript-disallowed.html: 14 * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt: 15 * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html: 16 * fast/loader/window-open-to-invalid-url-disallowed-expected.txt: 17 * fast/loader/window-open-to-invalid-url-disallowed.html: 18 * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt: 19 * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added. 20 * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt: 21 * platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt: 22 Update tests that were relying on a 0-timer to make sure that didCancelClientRedirectForFrame was 23 called to rely on our new test infrastructure instead. This is needed so that these tests keep passing 24 once we make policy delegates asynchronous by default. Without this, the didCancelClientRedirectForFrame lines 25 would be missing in the tests' output. 26 1 27 2018-03-06 Youenn Fablet <youenn@apple.com> 2 28 -
trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt
r207162 r229341 1 main frame - didFinishDocumentLoadForFrame 1 2 main frame - willPerformClientRedirectToURL: http://A=a%B=b 2 main frame - did FinishDocumentLoadForFrame3 main frame - didHandleOnloadEventsForFrame 3 4 main frame - didFinishLoadForFrame 4 5 main frame - didCancelClientRedirectForFrame 5 6 Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 6 7 7 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-javascript-disallowed.html
r207162 r229341 2 2 <html> 3 3 <head> 4 <script src="../../resources/js-test.js"></script> 4 5 <script> 5 if (window.testRunner) { 6 testRunner.dumpAsText(); 6 if (window.testRunner) 7 7 testRunner.dumpFrameLoadCallbacks(); 8 testRunner.waitUntilDone(); 9 } 8 jsTestIsAsync = true; 10 9 </script> 11 10 </head> 12 11 <body> 13 <p>Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".</p>14 <p>Note, this test must be run in DumpRenderTree.</p>15 12 <script> 16 window.location.href = "http://A=a%B=b";17 window.setTimeout(function() {18 if (window.testRunner)19 testRunner.notifyDone();20 } , 0);13 description("Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame"."); 14 onload = function() { 15 window.location.href = "http://A=a%B=b"; 16 shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest); 17 } 21 18 </script> 22 19 </body> -
trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt
r229340 r229341 6 6 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 7 7 8 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt
r207162 r229341 6 6 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 7 7 8 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html
r207162 r229341 3 3 <head> 4 4 <meta http-equiv="refresh" content="0; url=http://A=a%B=b"> 5 <script src="../../resources/js-test.js"></script> 5 6 <script> 6 if (window.testRunner) { 7 testRunner.dumpAsText(); 7 if (window.testRunner) 8 8 testRunner.dumpFrameLoadCallbacks(); 9 testRunner.waitUntilDone(); 10 } 9 jsTestIsAsync = true; 11 10 </script> 12 11 </head> 13 12 <body> 14 <p>Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".</p>15 <p>Note, this test must be run in DumpRenderTree.</p>16 13 <script> 17 // This ugly double-timeout ensures that the scheduled meta-refresh, whose timer isn't even started until the frame finishes loading, 18 // fires before notifyDone() is called, ensuring that didCancelClientRedirectForFrame is logged by DumpRenderTree. 19 window.setTimeout(function() { 20 window.setTimeout(function() { 21 if (window.testRunner) 22 testRunner.notifyDone(); 23 }, 0); 24 }, 0); 14 description("Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame"."); 15 16 shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest); 25 17 </script> 26 18 </body> -
trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed-expected.txt
r207162 r229341 1 main frame - didFinishDocumentLoadForFrame 1 2 main frame - willPerformClientRedirectToURL: http://A=a%B=b 2 main frame - did FinishDocumentLoadForFrame3 main frame - didHandleOnloadEventsForFrame 3 4 main frame - didFinishLoadForFrame 4 5 main frame - didCancelClientRedirectForFrame 5 6 Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 6 7 7 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS win.testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed.html
r207162 r229341 2 2 <html> 3 3 <head> 4 <script src="../../resources/js-test.js"></script> 4 5 <script> 5 6 if (window.testRunner) { 6 testRunner.dumpAsText();7 7 testRunner.dumpFrameLoadCallbacks(); 8 testRunner.waitUntilDone();9 8 testRunner.setCanOpenWindows(); 10 9 } 10 jsTestIsAsync = true; 11 11 </script> 12 12 </head> 13 13 <body> 14 <p>Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".</p>15 <p>Note, this test must be run in DumpRenderTree.</p>16 14 <script> 17 window.open("http://A=a%B=b", "_top");18 window.setTimeout(function() {19 if (window.testRunner)20 testRunner.notifyDone();21 } , 0);15 description("Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame"."); 16 onload = function() { 17 win = window.open("http://A=a%B=b", "_top"); 18 shouldBecomeEqual("win.testRunner.didCancelClientRedirect", "true", finishJSTest); 19 }; 22 20 </script> 23 21 </body> -
trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-javascript-disallowed-expected.txt
r207162 r229341 1 main frame - didFinishDocumentLoadForFrame 1 2 main frame - willPerformClientRedirectToURL: http://A=a%25B=b 2 main frame - did FinishDocumentLoadForFrame3 main frame - didHandleOnloadEventsForFrame 3 4 main frame - didFinishLoadForFrame 4 5 main frame - didCancelClientRedirectForFrame 5 6 Tests that we do not redirect to an invalid URL initiated by JavaScript. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 6 7 7 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt
r229340 r229341 6 6 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 7 7 8 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt
r207162 r229341 6 6 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 7 7 8 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/LayoutTests/platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt
r207162 r229341 1 main frame - didFinishDocumentLoadForFrame 1 2 main frame - willPerformClientRedirectToURL: http://A=a%25B=b 2 main frame - did FinishDocumentLoadForFrame3 main frame - didHandleOnloadEventsForFrame 3 4 main frame - didFinishLoadForFrame 4 5 main frame - didCancelClientRedirectForFrame 5 6 Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame". 6 7 7 Note, this test must be run in DumpRenderTree. 8 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 9 10 11 PASS win.testRunner.didCancelClientRedirect became true 12 PASS successfullyParsed is true 13 14 TEST COMPLETE 15 -
trunk/Source/WebCore/ChangeLog
r229340 r229341 1 2018-03-06 Chris Dumez <cdumez@apple.com> 2 3 fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates 4 https://bugs.webkit.org/show_bug.cgi?id=183345 5 6 Reviewed by Alex Christensen. 7 8 FrameLoader::loadURL() was calling loadWithNavigationAction() and then resetting the 9 m_quickRedirectComing flag right after. This works if the navigation policy decision 10 triggered by loadWithNavigationAction() is made synchronously. However, when it is 11 made asynchronously, the flag gets reset too early, before the policy decision 12 handler has been called. This is an issue because the policy decision handler 13 relies on the m_quickRedirectComing flag. 14 15 Similarly, FrameLoader::loadFrameRequest() was calling loadPostRequest() / loadURL() 16 and then focusing a frame right after. This does not work as intended when the navigation 17 policy decision is made asynchronously. 18 19 To address the issue, we now pass a completion handler that gets called when the operation 20 has actually completion, after the policy decision has been made. This maintains the 21 behavior in place with synchronous policy delegates. 22 23 Test: fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html 24 25 * loader/FrameLoader.cpp: 26 (WebCore::FrameLoader::loadURLIntoChildFrame): 27 (WebCore::FrameLoader::loadFrameRequest): 28 (WebCore::FrameLoader::loadURL): 29 (WebCore::FrameLoader::loadWithNavigationAction): 30 (WebCore::FrameLoader::load): 31 (WebCore::FrameLoader::loadWithDocumentLoader): 32 (WebCore::FrameLoader::reloadWithOverrideEncoding): 33 (WebCore::FrameLoader::reload): 34 (WebCore::FrameLoader::loadPostRequest): 35 (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): 36 (WebCore::FrameLoader::loadDifferentDocumentItem): 37 * loader/FrameLoader.h: 38 1 39 2018-03-06 Antoine Quint <graouts@apple.com> 2 40 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r229304 r229341 936 936 937 937 FrameLoadRequest frameLoadRequest { *m_frame.document(), m_frame.document()->securityOrigin(), { url }, ASCIILiteral("_self"), LockHistory::No, LockBackForwardList::Yes, ShouldSendReferrer::MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress, ShouldOpenExternalURLsPolicy::ShouldNotAllow, initiatedByMainFrame }; 938 childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, nullptr );938 childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, nullptr, [] { }); 939 939 } 940 940 … … 1201 1201 loadType = FrameLoadType::Standard; 1202 1202 1203 String frameName = request.frameName(); 1203 auto completionHandler = [this, protectedFrame = makeRef(m_frame), formState = makeRefPtr(formState), frameName = request.frameName()] { 1204 // FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual 1205 // load if frame names have changed. 1206 Frame* sourceFrame = formState ? formState->sourceDocument().frame() : &m_frame; 1207 if (!sourceFrame) 1208 sourceFrame = &m_frame; 1209 Frame* targetFrame = sourceFrame->loader().findFrameForNavigation(frameName); 1210 if (targetFrame && targetFrame != sourceFrame) { 1211 if (Page* page = targetFrame->page()) 1212 page->chrome().focus(); 1213 } 1214 }; 1215 1204 1216 if (request.resourceRequest().httpMethod() == "POST") 1205 loadPostRequest(WTFMove(request), referrer, loadType, event, formState );1217 loadPostRequest(WTFMove(request), referrer, loadType, event, formState, WTFMove(completionHandler)); 1206 1218 else 1207 loadURL(WTFMove(request), referrer, loadType, event, formState); 1208 1209 // FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual 1210 // load if frame names have changed. 1211 Frame* sourceFrame = formState ? formState->sourceDocument().frame() : &m_frame; 1212 if (!sourceFrame) 1213 sourceFrame = &m_frame; 1214 Frame* targetFrame = sourceFrame->loader().findFrameForNavigation(frameName); 1215 if (targetFrame && targetFrame != sourceFrame) { 1216 if (Page* page = targetFrame->page()) 1217 page->chrome().focus(); 1218 } 1219 loadURL(WTFMove(request), referrer, loadType, event, formState, WTFMove(completionHandler)); 1219 1220 } 1220 1221 … … 1262 1263 }; 1263 1264 1264 void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, FormState* formState) 1265 { 1265 void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, FormState* formState, CompletionHandler<void()>&& completionHandler) 1266 { 1267 CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler)); 1266 1268 if (m_inStopAllLoaders) 1267 1269 return; … … 1295 1297 if (targetFrame && targetFrame != &m_frame) { 1296 1298 frameLoadRequest.setFrameName("_self"); 1297 targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, formState );1299 targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, formState, completionHandlerCaller.release()); 1298 1300 return; 1299 1301 } … … 1306 1308 if (!targetFrame && !frameName.isEmpty()) { 1307 1309 action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest)); 1308 policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy ] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {1310 policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) { 1309 1311 continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy); 1312 completionHandler(); 1310 1313 }); 1311 1314 return; … … 1341 1344 // must grab this now, since this load may stop the previous load and clear this flag 1342 1345 bool isRedirect = m_quickRedirectComing; 1343 loadWithNavigationAction(request, action, lockHistory, newLoadType, formState, allowNavigationToInvalidURL); 1344 if (isRedirect) { 1345 m_quickRedirectComing = false; 1346 if (m_provisionalDocumentLoader) 1347 m_provisionalDocumentLoader->setIsClientRedirect(true); 1348 else if (m_policyDocumentLoader) 1349 m_policyDocumentLoader->setIsClientRedirect(true); 1350 } else if (sameURL && !isReload(newLoadType)) { 1351 // Example of this case are sites that reload the same URL with a different cookie 1352 // driving the generated content, or a master frame with links that drive a target 1353 // frame, where the user has clicked on the same link repeatedly. 1354 m_loadType = FrameLoadType::Same; 1355 } 1346 loadWithNavigationAction(request, action, lockHistory, newLoadType, formState, allowNavigationToInvalidURL, [this, isRedirect, sameURL, newLoadType, protectedFrame = makeRef(m_frame), completionHandler = completionHandlerCaller.release()] { 1347 if (isRedirect) { 1348 m_quickRedirectComing = false; 1349 if (m_provisionalDocumentLoader) 1350 m_provisionalDocumentLoader->setIsClientRedirect(true); 1351 else if (m_policyDocumentLoader) 1352 m_policyDocumentLoader->setIsClientRedirect(true); 1353 } else if (sameURL && !isReload(newLoadType)) { 1354 // Example of this case are sites that reload the same URL with a different cookie 1355 // driving the generated content, or a master frame with links that drive a target 1356 // frame, where the user has clicked on the same link repeatedly. 1357 m_loadType = FrameLoadType::Same; 1358 } 1359 completionHandler(); 1360 }); 1356 1361 } 1357 1362 … … 1402 1407 } 1403 1408 1404 void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, LockHistory lockHistory, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL )1409 void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, LockHistory lockHistory, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL, CompletionHandler<void()>&& completionHandler) 1405 1410 { 1406 1411 Ref<DocumentLoader> loader = m_client.createDocumentLoader(request, defaultSubstituteDataForURL(request.url())); … … 1414 1419 loader->setOverrideEncoding(m_documentLoader->overrideEncoding()); 1415 1420 1416 loadWithDocumentLoader(loader.ptr(), type, formState, allowNavigationToInvalidURL );1421 loadWithDocumentLoader(loader.ptr(), type, formState, allowNavigationToInvalidURL, WTFMove(completionHandler)); 1417 1422 } 1418 1423 … … 1453 1458 } 1454 1459 1455 loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes );1456 } 1457 1458 void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL )1460 loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes, [] { }); 1461 } 1462 1463 void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL, CompletionHandler<void()>&& completionHandler) 1459 1464 { 1460 1465 // Retain because dispatchBeforeLoadEvent may release the last reference to it. 1461 1466 Ref<Frame> protect(m_frame); 1467 1468 CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler)); 1462 1469 1463 1470 ASSERT(m_client.hasWebView()); … … 1532 1539 m_frame.navigationScheduler().cancel(true); 1533 1540 1534 policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), false /* didReceiveRedirectResponse */, loader, formState, [this, protectedFrame = makeRef(m_frame), allowNavigationToInvalidURL ] (const ResourceRequest& request, FormState* formState, bool shouldContinue) {1541 policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), false /* didReceiveRedirectResponse */, loader, formState, [this, protectedFrame = makeRef(m_frame), allowNavigationToInvalidURL, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, FormState* formState, bool shouldContinue) { 1535 1542 continueLoadAfterNavigationPolicy(request, formState, shouldContinue, allowNavigationToInvalidURL); 1543 completionHandler(); 1536 1544 }); 1537 1545 } … … 1631 1639 loader->setOverrideEncoding(encoding); 1632 1640 1633 loadWithDocumentLoader(loader.ptr(), FrameLoadType::Reload, 0, AllowNavigationToInvalidURL::Yes );1641 loadWithDocumentLoader(loader.ptr(), FrameLoadType::Reload, 0, AllowNavigationToInvalidURL::Yes, [] { }); 1634 1642 } 1635 1643 … … 1676 1684 }; 1677 1685 1678 loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), 0, AllowNavigationToInvalidURL::Yes );1686 loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), 0, AllowNavigationToInvalidURL::Yes, [] { }); 1679 1687 } 1680 1688 … … 2748 2756 } 2749 2757 2750 void FrameLoader::loadPostRequest(FrameLoadRequest&& request, const String& referrer, FrameLoadType loadType, Event* event, FormState* formState )2758 void FrameLoader::loadPostRequest(FrameLoadRequest&& request, const String& referrer, FrameLoadType loadType, Event* event, FormState* formState, CompletionHandler<void()>&& completionHandler) 2751 2759 { 2752 2760 String frameName = request.frameName(); … … 2778 2786 // The search for a target frame is done earlier in the case of form submission. 2779 2787 if (Frame* targetFrame = formState ? 0 : findFrameForNavigation(frameName)) { 2780 targetFrame->loader().loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL );2788 targetFrame->loader().loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL, WTFMove(completionHandler)); 2781 2789 return; 2782 2790 } 2783 2791 2784 policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy ] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {2792 policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = WTFMove(completionHandler)] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) { 2785 2793 continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy); 2794 completionHandler(); 2786 2795 }); 2787 2796 return; … … 2790 2799 // must grab this now, since this load may stop the previous load and clear this flag 2791 2800 bool isRedirect = m_quickRedirectComing; 2792 loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL); 2793 if (isRedirect) { 2794 m_quickRedirectComing = false; 2795 if (m_provisionalDocumentLoader) 2796 m_provisionalDocumentLoader->setIsClientRedirect(true); 2797 else if (m_policyDocumentLoader) 2798 m_policyDocumentLoader->setIsClientRedirect(true); 2799 } 2801 loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL, [this, isRedirect, protectedFrame = makeRef(m_frame), completionHandler = WTFMove(completionHandler)] { 2802 if (isRedirect) { 2803 m_quickRedirectComing = false; 2804 if (m_provisionalDocumentLoader) 2805 m_provisionalDocumentLoader->setIsClientRedirect(true); 2806 else if (m_policyDocumentLoader) 2807 m_policyDocumentLoader->setIsClientRedirect(true); 2808 } 2809 completionHandler(); 2810 }); 2800 2811 } 2801 2812 … … 3259 3270 3260 3271 NavigationAction newAction { *frame->document(), request, InitiatedByMainFrame::Unknown, NavigationType::Other, action.shouldOpenExternalURLsPolicy() }; 3261 mainFrame->loader().loadWithNavigationAction(request, newAction, LockHistory::No, FrameLoadType::Standard, formState, allowNavigationToInvalidURL );3272 mainFrame->loader().loadWithNavigationAction(request, newAction, LockHistory::No, FrameLoadType::Standard, formState, allowNavigationToInvalidURL, [] { }); 3262 3273 } 3263 3274 … … 3449 3460 documentLoader->setTriggeringAction({ *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false }); 3450 3461 documentLoader->setLastCheckedRequest(ResourceRequest()); 3451 loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes );3462 loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes, [] { }); 3452 3463 return; 3453 3464 } … … 3535 3546 } 3536 3547 3537 loadWithNavigationAction(request, action, LockHistory::No, loadType, 0, AllowNavigationToInvalidURL::Yes );3548 loadWithNavigationAction(request, action, LockHistory::No, loadType, 0, AllowNavigationToInvalidURL::Yes, [] { }); 3538 3549 } 3539 3550 -
trunk/Source/WebCore/loader/FrameLoader.h
r228942 r229341 360 360 void urlSelected(FrameLoadRequest&&, Event*); 361 361 362 void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, FormState*, AllowNavigationToInvalidURL ); // Calls continueLoadAfterNavigationPolicy362 void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, FormState*, AllowNavigationToInvalidURL, CompletionHandler<void()>&&); // Calls continueLoadAfterNavigationPolicy 363 363 void load(DocumentLoader*); // Calls loadWithDocumentLoader 364 364 365 void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, LockHistory, FrameLoadType, FormState*, AllowNavigationToInvalidURL ); // Calls loadWithDocumentLoader366 367 void loadPostRequest(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState* );368 void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState* );365 void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, LockHistory, FrameLoadType, FormState*, AllowNavigationToInvalidURL, CompletionHandler<void()>&&); // Calls loadWithDocumentLoader 366 367 void loadPostRequest(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*, CompletionHandler<void()>&&); 368 void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*, CompletionHandler<void()>&&); 369 369 370 370 bool shouldReload(const URL& currentURL, const URL& destinationURL); -
trunk/Tools/ChangeLog
r229325 r229341 1 2018-03-06 Chris Dumez <cdumez@apple.com> 2 3 fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates 4 https://bugs.webkit.org/show_bug.cgi?id=183345 5 6 Reviewed by Alex Christensen. 7 8 Add layout test infrastructure so a test can know when didCancelClientRedirectForFrame has 9 been called. The tests used to rely on a 0-timer but this does not work when the client 10 responds to the navigation policy asynchronously. 11 12 * DumpRenderTree/TestRunner.cpp: 13 (getDidCancelClientRedirect): 14 (TestRunner::staticValues): 15 * DumpRenderTree/TestRunner.h: 16 (TestRunner::didCancelClientRedirect const): 17 (TestRunner::setDidCancelClientRedirect): 18 * DumpRenderTree/mac/FrameLoadDelegate.mm: 19 (-[FrameLoadDelegate webView:didCancelClientRedirectForFrame:]): 20 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 21 * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: 22 (WTR::InjectedBundlePage::didCancelClientRedirectForFrame): 23 * WebKitTestRunner/InjectedBundle/TestRunner.h: 24 (WTR::TestRunner::didCancelClientRedirect const): 25 (WTR::TestRunner::setDidCancelClientRedirect): 26 1 27 2018-03-06 Zan Dobersek <zdobersek@igalia.com> 2 28 -
trunk/Tools/DumpRenderTree/TestRunner.cpp
r229143 r229341 1810 1810 } 1811 1811 1812 static JSValueRef getDidCancelClientRedirect(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) 1813 { 1814 TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject)); 1815 return JSValueMakeBoolean(context, controller->didCancelClientRedirect()); 1816 } 1817 1812 1818 static JSValueRef getDatabaseDefaultQuotaCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) 1813 1819 { … … 2078 2084 { 2079 2085 static JSStaticValue staticValues[] = { 2086 { "didCancelClientRedirect", getDidCancelClientRedirect, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2080 2087 { "timeout", getTimeoutCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 2081 2088 { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone }, -
trunk/Tools/DumpRenderTree/TestRunner.h
r223211 r229341 381 381 void setOpenPanelFiles(JSContextRef, JSValueRef); 382 382 383 bool didCancelClientRedirect() const { return m_didCancelClientRedirect; } 384 void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; } 385 383 386 private: 384 387 TestRunner(const std::string& testURL, const std::string& expectedPixelHash); … … 446 449 bool m_hasPendingWebNotificationClick; 447 450 bool m_dumpJSConsoleLogInStdErr { false }; 451 bool m_didCancelClientRedirect { false }; 448 452 449 453 double m_databaseDefaultQuota; -
trunk/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
r210519 r229341 405 405 printf ("%s\n", [string UTF8String]); 406 406 } 407 gTestRunner->setDidCancelClientRedirect(true); 407 408 } 408 409 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r229177 r229341 317 317 void terminateServiceWorkerProcess(); 318 318 319 readonly attribute boolean didCancelClientRedirect; 320 319 321 void removeAllSessionCredentials(object callback); 320 322 -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
r229304 r229341 1007 1007 return; 1008 1008 1009 if ( !injectedBundle.testRunner()->shouldDumpFrameLoadCallbacks())1010 return;1011 1012 dumpLoadEvent(frame, "didCancelClientRedirectForFrame");1009 if (injectedBundle.testRunner()->shouldDumpFrameLoadCallbacks()) 1010 dumpLoadEvent(frame, "didCancelClientRedirectForFrame"); 1011 1012 injectedBundle.testRunner()->setDidCancelClientRedirect(true); 1013 1013 } 1014 1014 -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r229177 r229341 335 335 void setIgnoresViewportScaleLimits(bool); 336 336 void setShouldDownloadUndisplayableMIMETypes(bool); 337 338 bool didCancelClientRedirect() const { return m_didCancelClientRedirect; } 339 void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; } 337 340 338 341 void runUIScript(JSStringRef script, JSValueRef callback); … … 480 483 bool m_shouldDecideResponsePolicyAfterDelay { false }; 481 484 bool m_shouldFinishAfterDownload { false }; 485 bool m_didCancelClientRedirect { false }; 482 486 483 487 bool m_userStyleSheetEnabled;
Note: See TracChangeset
for help on using the changeset viewer.