haikuwebkit/LayoutTests/fast/events/beforeunload-alert-user-int...

30 lines
1.0 KiB
HTML
Raw Permalink Normal View History

WebKit should disallow beforeunload alerts from web pages users have never interacted with https://bugs.webkit.org/show_bug.cgi?id=169936 <rdar://problem/23798897> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt: * web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects-expected.txt: Rebaseline now that the CONFIRM MESSAGE lines are now longer shown. This is because there is no user interaction with the page. Source/WebCore: WebKit should disallow beforeunload alerts from web pages users have never interacted with. This reduces the risk of annoyance to the user and is allowed by the specification: - https://html.spec.whatwg.org/multipage/browsers.html#prompt-to-unload-a-document (Step 8): which says: """ The user agent is encouraged to avoid asking the user for confirmation if it judges that doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user has not interacted with the document, the user agent would not ask for confirmation before unloading it. """ Firefox already implements this, Chrome does not. Tests: fast/events/beforeunload-alert-no-user-interaction.html fast/events/beforeunload-alert-user-interaction.html fast/events/beforeunload-alert-user-interaction2.html * loader/FrameLoader.cpp: (WebCore::shouldAskForNavigationConfirmation): (WebCore::FrameLoader::dispatchBeforeUnloadEvent): LayoutTests: * fast/events/before-unload-return-string-conversion-expected.txt: * fast/events/before-unload-returnValue-expected.txt: Rebaseline now that the CONFIRM MESSAGE is no longer shown. This is because there is no user interaction with the page. * fast/events/beforeunload-alert-no-user-interaction-expected.txt: Added. * fast/events/beforeunload-alert-no-user-interaction.html: Added. * fast/events/beforeunload-alert-user-interaction-expected.txt: Added. * fast/events/beforeunload-alert-user-interaction.html: Added. * fast/events/beforeunload-alert-user-interaction2-expected.txt: Added. * fast/events/beforeunload-alert-user-interaction2.html: Added. Add layout test coverage. * fast/loader/form-submission-after-beforeunload-cancel.html: * fast/loader/show-only-one-beforeunload-dialog.html: * http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html: * http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html: Simulate user interaction with the page so that the CONFIRM MESSAGE log lines are still shown. Canonical link: https://commits.webkit.org/186904@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214277 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-22 21:14:23 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
description("Tests that the beforeunload alert is shown when the user interacted with the page. You should see a 'CONFIRM NAVIGATION' message at the top.");
jsTestIsAsync = true;
onload = function() {
const testFrame = document.getElementById("testFrame");
testFrame.contentWindow.onbeforeunload = function(e) {
return "PASS: a beforeunload alert was shown.";
};
// Simulate a user interaction.
const testInput = document.getElementById("testInput");
UIHelper.activateAt(testInput.offsetLeft + 5, testInput.offsetTop + 5).then(function() {
setTimeout(function() {
HTML String load cannot be prevented by responding 'Cancel' asynchronously in decidePolicyForNavigationAction https://bugs.webkit.org/show_bug.cgi?id=184848 <rdar://problem/39145306> Reviewed by Brady Eidson. Source/WebCore: When calling loadHTMLString on a WebView, we end up doing a load for 'about:blank' with substitute data. In such case, we want to do a regular asynchronous policy delegate check, there is no reason we need it to be synchronous. Update our check to make sure we only do a synchronous policy check for initial 'about:blank' loads that do not have substitute data. * loader/PolicyChecker.cpp: (WebCore::PolicyChecker::checkNavigationPolicy): Tools: Add API test coverage. * TestWebKitAPI/Tests/WebKitCocoa/DecidePolicyForNavigationAction.mm: (-[DecidePolicyForNavigationActionController webView:decidePolicyForNavigationAction:decisionHandler:]): (TEST): LayoutTests: Update layout tests that wrongly expected 'about:blank' to load synchronously even when it is not the initial empty document of an iframe. I have checked that our behavior is now consistent with Chrome. * fast/events/beforeunload-alert-user-interaction2.html: * http/tests/security/cross-origin-reified-window-location-setting-expected.txt: * http/tests/security/cross-origin-reified-window-location-setting.html: * webarchive/loading/javascript-url-iframe-crash-expected.txt: Canonical link: https://commits.webkit.org/200394@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-23 20:49:57 +00:00
testFrame.onload = finishJSTest;
WebKit should disallow beforeunload alerts from web pages users have never interacted with https://bugs.webkit.org/show_bug.cgi?id=169936 <rdar://problem/23798897> Reviewed by Brent Fulgham. LayoutTests/imported/w3c: * web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt: * web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects-expected.txt: Rebaseline now that the CONFIRM MESSAGE lines are now longer shown. This is because there is no user interaction with the page. Source/WebCore: WebKit should disallow beforeunload alerts from web pages users have never interacted with. This reduces the risk of annoyance to the user and is allowed by the specification: - https://html.spec.whatwg.org/multipage/browsers.html#prompt-to-unload-a-document (Step 8): which says: """ The user agent is encouraged to avoid asking the user for confirmation if it judges that doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user has not interacted with the document, the user agent would not ask for confirmation before unloading it. """ Firefox already implements this, Chrome does not. Tests: fast/events/beforeunload-alert-no-user-interaction.html fast/events/beforeunload-alert-user-interaction.html fast/events/beforeunload-alert-user-interaction2.html * loader/FrameLoader.cpp: (WebCore::shouldAskForNavigationConfirmation): (WebCore::FrameLoader::dispatchBeforeUnloadEvent): LayoutTests: * fast/events/before-unload-return-string-conversion-expected.txt: * fast/events/before-unload-returnValue-expected.txt: Rebaseline now that the CONFIRM MESSAGE is no longer shown. This is because there is no user interaction with the page. * fast/events/beforeunload-alert-no-user-interaction-expected.txt: Added. * fast/events/beforeunload-alert-no-user-interaction.html: Added. * fast/events/beforeunload-alert-user-interaction-expected.txt: Added. * fast/events/beforeunload-alert-user-interaction.html: Added. * fast/events/beforeunload-alert-user-interaction2-expected.txt: Added. * fast/events/beforeunload-alert-user-interaction2.html: Added. Add layout test coverage. * fast/loader/form-submission-after-beforeunload-cancel.html: * fast/loader/show-only-one-beforeunload-dialog.html: * http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html: * http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html: Simulate user interaction with the page so that the CONFIRM MESSAGE log lines are still shown. Canonical link: https://commits.webkit.org/186904@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214277 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-22 21:14:23 +00:00
testFrame.src = "about:blank";
}, 0);
});
};
</script>
<iframe id="testFrame" src="resources/onclick.html"></iframe>
<input id="testInput" type="text"></input>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>