2012-04-03 Nikolas Zimmermann <nzimmermann@rim.com>
[WebKit-https.git] / LayoutTests / fast / events / drop-handler-should-not-stop-navigate.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div>This tests that a drop handler's default action must be prevented in order to stop navigation.
5 Otherwise, if event.preventDefault() is not called, navigation should occur. To test manually,
6 simply drag and drop another link or HTML file on this page. If navigation occurs, then the test
7 passed.</div>
8 <script>
9 function log(text)
10 {
11     document.body.appendChild(document.createElement('br'));
12     document.body.appendChild(document.createElement('div').appendChild(document.createTextNode(text)));
13 }
14 window.addEventListener('beforeunload', function ()
15 {
16     log('PASS');
17     layoutTestController.notifyDone();
18 });
19 document.body.addEventListener('dragenter', function (event)
20 {
21     log('Cancelling dragenter');
22     event.preventDefault();
23 });
24 document.body.addEventListener('dragover', function (event)
25 {
26     log('Cancelling dragover');
27     event.preventDefault();
28 });
29 document.body.addEventListener('drop', function (event)
30 {
31     log('Not preventing default event on drop.');
32 });
33 (function ()
34 {
35     if (!window.layoutTestController)
36         return;
37     layoutTestController.dumpAsText();
38     layoutTestController.waitUntilDone();
39     log('Starting test');
40     eventSender.beginDragWithFiles(['DRTFakeFile']);
41     eventSender.mouseMoveTo(document.body.offsetLeft + 10, document.body.offsetTop + 10);
42     eventSender.mouseUp();
43     log('FAIL');
44     layoutTestController.notifyDone();
45 })();
46 </script>
47 </body>
48 </html>