Changeset 214277 in webkit
- Timestamp:
- Mar 22, 2017 2:14:23 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r214274 r214277 1 2017-03-22 Chris Dumez <cdumez@apple.com> 2 3 WebKit should disallow beforeunload alerts from web pages users have never interacted with 4 https://bugs.webkit.org/show_bug.cgi?id=169936 5 <rdar://problem/23798897> 6 7 Reviewed by Brent Fulgham. 8 9 * fast/events/before-unload-return-string-conversion-expected.txt: 10 * fast/events/before-unload-returnValue-expected.txt: 11 Rebaseline now that the CONFIRM MESSAGE is no longer shown. This is because there is 12 no user interaction with the page. 13 14 * fast/events/beforeunload-alert-no-user-interaction-expected.txt: Added. 15 * fast/events/beforeunload-alert-no-user-interaction.html: Added. 16 * fast/events/beforeunload-alert-user-interaction-expected.txt: Added. 17 * fast/events/beforeunload-alert-user-interaction.html: Added. 18 * fast/events/beforeunload-alert-user-interaction2-expected.txt: Added. 19 * fast/events/beforeunload-alert-user-interaction2.html: Added. 20 Add layout test coverage. 21 22 * fast/loader/form-submission-after-beforeunload-cancel.html: 23 * fast/loader/show-only-one-beforeunload-dialog.html: 24 * http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html: 25 * http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html: 26 Simulate user interaction with the page so that the CONFIRM MESSAGE log lines are still 27 shown. 28 1 29 2017-03-22 Nan Wang <n_wang@apple.com> 2 30 -
trunk/LayoutTests/fast/events/before-unload-return-string-conversion-expected.txt
r212625 r214277 1 CONFIRM NAVIGATION: PASS2 1 Tests that the value returned from a beforeunload event handler gets converted to a string, even if the returnValue property was already set. 3 2 -
trunk/LayoutTests/fast/events/before-unload-returnValue-expected.txt
r155367 r214277 1 CONFIRM NAVIGATION: This is beforeunload from the top level frame.2 1 Tests the returnValue attribute of the BeforeUnloadEvent. 3 2 -
trunk/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html
r122687 r214277 1 <script src="../../resources/ui-helper.js"></script> 1 2 <script> 2 3 if (window.testRunner) { … … 7 8 8 9 _confirmationDialogDisplayedOnce = false; 10 11 function submitForm() 12 { 13 document.forms[0].submit(); 14 } 9 15 10 16 window.addEventListener("beforeunload", function() { … … 35 41 36 42 <div id="console"></div> 37 43 <input id="testButton" type="button" value="Click to submit form" onclick="submitForm()"> 38 44 <form action="resources/pass-and-notify-done.html" method="POST"> 39 45 </form> 40 46 41 47 <script> 42 document.forms[0].submit(); 48 // Simulate a user interaction with the page so that the beforeunload alert shows. 49 const testButton = document.getElementById("testButton"); 50 UIHelper.activateAt(testButton.offsetLeft + 5, testButton.offsetTop + 5); 43 51 </script> -
trunk/LayoutTests/fast/loader/show-only-one-beforeunload-dialog.html
r152941 r214277 1 <script src="../../resources/ui-helper.js"></script> 1 2 <script> 2 3 … … 6 7 } 7 8 9 function navigateFrame() 10 { 11 window.location.href = 'resources/notify-done.html'; 12 } 13 8 14 window.onload = function() 9 15 { 10 window.setTimeout("window.location.href = 'resources/notify-done.html';", 0); 16 // Simulate a user interaction with the page so that the beforeunload alert shows. 17 const testButton = document.getElementById("testButton"); 18 UIHelper.activateAt(testButton.offsetLeft + 5, testButton.offsetTop + 5); 11 19 } 12 20 … … 21 29 This page also has a beforeunload dialog, itself.<br> 22 30 Only the dialog from this top-level frame should display, and none of the iframe ones should display.<br> 31 <input id="testButton" type="button" value="Click to navigate" onclick="navigateFrame()"><br> 23 32 <iframe src="resources/iframe-with-beforeunload.html"></iframe><br> 24 33 <iframe src="resources/iframe-with-beforeunload.html"></iframe><br> -
trunk/LayoutTests/http/tests/misc/iframe-beforeunload-dialog-matching-ancestor-securityorigin.html
r152941 r214277 1 <script src="/js-test-resources/ui-helper.js"></script> 1 2 <script> 2 3 … … 6 7 } 7 8 9 function navigateFrame() 10 { 11 window.location.href = 'resources/notify-done.html'; 12 } 13 8 14 window.onload = function() 9 15 { 10 window.setTimeout("window.location.href = 'resources/notify-done.html';", 0); 16 // Simulate a user interaction with the page so that the beforeunload alert shows. 17 const testButton = document.getElementById("testButton"); 18 UIHelper.activateAt(testButton.offsetLeft + 5, testButton.offsetTop + 5); 11 19 } 12 20 … … 15 23 When viewed using the host 127.0.0.1, this page has an iframe whose security origin matches the main frame.<br> 16 24 The iframe has a beforeunload handler, and that handler should result in the display of the page dismissal dialog.<br> 25 <input id="testButton" type="button" value="Click to navigate" onclick="navigateFrame()"> 17 26 <iframe src="http://127.0.0.1:8000/misc/resources/iframe-with-beforeunload.html"></iframe><br> 18 27 </body> -
trunk/LayoutTests/http/tests/misc/iframe-beforeunload-dialog-not-matching-ancestor-securityorigin.html
r152941 r214277 1 <script src="/js-test-resources/ui-helper.js"></script> 1 2 <script> 2 3 … … 6 7 } 7 8 9 function navigateFrame() 10 { 11 window.location.href = 'resources/notify-done.html'; 12 } 13 8 14 window.onload = function() 9 15 { 10 window.setTimeout("window.location.href = 'resources/notify-done.html';", 0); 16 // Simulate a user interaction with the page so that the beforeunload alert shows. 17 const testButton = document.getElementById("testButton"); 18 UIHelper.activateAt(testButton.offsetLeft + 5, testButton.offsetTop + 5); 11 19 } 12 20 … … 15 23 When viewed using the host 127.0.0.1, this page has an iframe whose security origin is different from the main frame.<br> 16 24 The iframe has a beforeunload handler, and that handler should not result in the display of the page dismissal dialog since the security origins differ.<br> 25 <input id="testButton" type="button" value="Click to navigate" onclick="navigateFrame()"><br> 17 26 <iframe src="http://localhost:8000/misc/resources/iframe-with-beforeunload.html"></iframe><br> 18 27 </body> -
trunk/LayoutTests/imported/w3c/ChangeLog
r214265 r214277 1 2017-03-22 Chris Dumez <cdumez@apple.com> 2 3 WebKit should disallow beforeunload alerts from web pages users have never interacted with 4 https://bugs.webkit.org/show_bug.cgi?id=169936 5 <rdar://problem/23798897> 6 7 Reviewed by Brent Fulgham. 8 9 * web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt: 10 * web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects-expected.txt: 11 Rebaseline now that the CONFIRM MESSAGE lines are now longer shown. This is because there is no user interaction 12 with the page. 13 1 14 2017-03-22 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt
r212625 r214277 1 CONFIRM NAVIGATION:2 CONFIRM NAVIGATION: false3 CONFIRM NAVIGATION: true4 CONFIRM NAVIGATION: 05 CONFIRM NAVIGATION: foo6 CONFIRM NAVIGATION: foo7 CONFIRM NAVIGATION: foo8 CONFIRM NAVIGATION: foo9 CONFIRM NAVIGATION: foo10 CONFIRM NAVIGATION: foo11 1 12 2 PASS Returning a string must not cancel the event: CustomEvent, non-cancelable -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/compile-event-handler-settings-objects-expected.txt
r213882 r214277 1 CONFIRM NAVIGATION: undefined2 1 3 2 PASS The Function instance must be created in the Realm of the node document -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r214195 r214277 364 364 editing/caret/emoji.html [ Skip ] 365 365 webkit.org/b/155233 fast/events/max-tabindex-focus.html [ Skip ] 366 fast/events/beforeunload-alert-user-interaction.html [ Skip ] 366 367 fast/forms/validation-bubble-escape-key-dismiss.html [ Skip ] 367 368 fast/forms/validation-message-maxLength.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r214276 r214277 1 2017-03-22 Chris Dumez <cdumez@apple.com> 2 3 WebKit should disallow beforeunload alerts from web pages users have never interacted with 4 https://bugs.webkit.org/show_bug.cgi?id=169936 5 <rdar://problem/23798897> 6 7 Reviewed by Brent Fulgham. 8 9 WebKit should disallow beforeunload alerts from web pages users have never interacted with. 10 This reduces the risk of annoyance to the user and is allowed by the specification: 11 - https://html.spec.whatwg.org/multipage/browsers.html#prompt-to-unload-a-document (Step 8): 12 which says: 13 """ 14 The user agent is encouraged to avoid asking the user for confirmation if it judges that doing 15 so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user 16 has not interacted with the document, the user agent would not ask for confirmation before 17 unloading it. 18 """ 19 20 Firefox already implements this, Chrome does not. 21 22 Tests: fast/events/beforeunload-alert-no-user-interaction.html 23 fast/events/beforeunload-alert-user-interaction.html 24 fast/events/beforeunload-alert-user-interaction2.html 25 26 * loader/FrameLoader.cpp: 27 (WebCore::shouldAskForNavigationConfirmation): 28 (WebCore::FrameLoader::dispatchBeforeUnloadEvent): 29 1 30 2017-03-22 Brent Fulgham <bfulgham@apple.com> 2 31 -
trunk/Source/WebCore/loader/FrameLoader.cpp
r214194 r214277 3069 3069 } 3070 3070 3071 static bool shouldAskForNavigationConfirmation(const BeforeUnloadEvent& event) 3072 { 3071 static bool shouldAskForNavigationConfirmation(Document& document, const BeforeUnloadEvent& event) 3072 { 3073 bool userDidInteractWithPage = document.topDocument().lastHandledUserGestureTimestamp() > 0; 3073 3074 // Web pages can request we ask for confirmation before navigating by: 3074 3075 // - Cancelling the BeforeUnloadEvent (modern way) … … 3076 3077 // - Returning a non-empty string from the event handler, which is then set as returnValue 3077 3078 // attribute on the BeforeUnloadEvent. 3078 return event.defaultPrevented() || !event.returnValue().isEmpty();3079 return userDidInteractWithPage && (event.defaultPrevented() || !event.returnValue().isEmpty()); 3079 3080 } 3080 3081 … … 3103 3104 document->defaultEventHandler(beforeUnloadEvent.get()); 3104 3105 3105 if (!shouldAskForNavigationConfirmation( beforeUnloadEvent))3106 if (!shouldAskForNavigationConfirmation(*document, beforeUnloadEvent)) 3106 3107 return true; 3107 3108
Note: See TracChangeset
for help on using the changeset viewer.