Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/before-unload-reloads.html

Issue 2801813005: Only show a beforeunload dialog if a frame has had a user gesture since its load. (Closed)
Patch Set: aw Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <script> 1 <script>
2 window.onload = function () 2 window.onload = function ()
3 { 3 {
4 if (window.testRunner) { 4 if (window.testRunner) {
5 testRunner.dumpAsText(); 5 testRunner.dumpAsText();
6 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true); 6 testRunner.setShouldStayOnPageAfterHandlingBeforeUnload(true);
7 testRunner.waitUntilDone(); 7 testRunner.waitUntilDone();
8 } 8 }
9 // JavaScript onbeforeunload dialogs require a user gesture.
10 if (window.eventSender) {
11 eventSender.mouseMoveTo(5, 5);
12 eventSender.mouseDown();
13 eventSender.mouseUp();
14 }
9 if (sessionStorage.fail) { 15 if (sessionStorage.fail) {
10 if (window.testRunner) 16 if (window.testRunner)
11 testRunner.notifyDone(); 17 testRunner.notifyDone();
12 return; 18 return;
13 } 19 }
14 20
15 location = location.href + '?done'; 21 location = location.href + '?done';
16 window.setTimeout(passTest, 0); 22 window.setTimeout(passTest, 0);
17 }; 23 };
18 window.onbeforeunload = function () 24 window.onbeforeunload = function ()
19 { 25 {
20 if (sessionStorage.fail) 26 if (sessionStorage.fail)
21 return; 27 return;
22 sessionStorage.fail = true; 28 sessionStorage.fail = true;
23 location.reload(); 29 location.reload();
24 return ""; 30 return "";
25 }; 31 };
26 function passTest() 32 function passTest()
27 { 33 {
28 document.getElementById('status').textContent = 'PASS'; 34 document.getElementById('status').textContent = 'PASS';
29 if (window.testRunner) 35 if (window.testRunner)
30 testRunner.notifyDone(); 36 testRunner.notifyDone();
31 } 37 }
32 </script> 38 </script>
33 <body> 39 <body>
34 This test passes if the FAIL changes to PASS after clicking "Stay on this page". 40 This test passes if the FAIL changes to PASS after clicking "Stay on this page".
35 41
36 <div id="status">FAIL</div> 42 <div id="status">FAIL</div>
37 </body> 43 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698