OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <style> | 4 <style> |
5 div, span { | 5 div, span { |
6 border: 1px solid black; | 6 border: 1px solid black; |
7 }; | 7 }; |
8 </style> | 8 </style> |
9 <script> | 9 <script> |
10 var dropReceived; | 10 var dropReceived; |
| 11 var beforeUnloadReceived = false; |
11 function log(str) | 12 function log(str) |
12 { | 13 { |
13 var result = document.getElementById('result'); | 14 var result = document.getElementById('result'); |
14 result.appendChild(document.createTextNode(str)); | 15 result.appendChild(document.createTextNode(str)); |
15 result.appendChild(document.createElement('br')); | 16 result.appendChild(document.createElement('br')); |
16 } | 17 } |
17 function dragDrop(target) | 18 function dragDrop(target) |
18 { | 19 { |
19 log('Starting drag...'); | 20 log('Starting drag...'); |
20 eventSender.beginDragWithFiles(['test']); | 21 eventSender.beginDragWithFiles(['test']); |
(...skipping 29 matching lines...) Expand all Loading... |
50 }, false); | 51 }, false); |
51 | 52 |
52 if (!window.testRunner) | 53 if (!window.testRunner) |
53 return; | 54 return; |
54 testRunner.dumpAsText(); | 55 testRunner.dumpAsText(); |
55 testRunner.waitUntilDone(); | 56 testRunner.waitUntilDone(); |
56 | 57 |
57 window.addEventListener('beforeunload', function (e) { | 58 window.addEventListener('beforeunload', function (e) { |
58 if (!dropReceived) | 59 if (!dropReceived) |
59 log('Drop not received'); | 60 log('Drop not received'); |
| 61 beforeUnloadReceived = true; |
60 e.preventDefault(); | 62 e.preventDefault(); |
61 testRunner.notifyDone(); | 63 testRunner.notifyDone(); |
62 }); | 64 }); |
63 | 65 |
64 dragDrop(drop1); | 66 dragDrop(drop1); |
65 unloadExpected = true; | |
66 dragDrop(drop2); | 67 dragDrop(drop2); |
67 window.setTimeout(function () { | 68 window.setTimeout(function () { |
68 // Deadman's switch to fail quickly. | 69 // Deadman's switch to fail quickly. |
69 log('FAIL: navigation expected'); | 70 if (!beforeUnloadReceived) |
| 71 log('FAIL: navigation expected'); |
70 testRunner.notifyDone(); | 72 testRunner.notifyDone(); |
71 }, 0); | 73 }, 0); |
72 } | 74 } |
73 </script> | 75 </script> |
74 </head> | 76 </head> |
75 <body> | 77 <body> |
76 <p>To run this test manually, drag a file to one of the two boxes below. | 78 <p>To run this test manually, drag a file to one of the two boxes below. |
77 <div id="drop1">Dropping in drop target 1 should result in a drop event.</div> | 79 <div id="drop1">Dropping in drop target 1 should result in a drop event.</div> |
78 <div id="drop2">Dropping in drop target 2 should NOT result in a drop event (pag
e will navigate).</div> | 80 <div id="drop2">Dropping in drop target 2 should NOT result in a drop event (pag
e will navigate).</div> |
79 <div id="result"> | 81 <div id="result"> |
80 </div> | 82 </div> |
81 </body> | 83 </body> |
82 </html> | 84 </html> |
OLD | NEW |