drag-escape.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. var expectedEvents = ["dragstart", "dragend"];
  6. var i = 0;
  7. function recordEvent(e) {
  8. log(e.type);
  9. if (e.type !== expectedEvents[i]) {
  10. log("FAIL - expected " + expectedEvents[i] + " but got " + e.type);
  11. } else if (i == expectedEvents.length - 1) {
  12. log("SUCCESS");
  13. } else {
  14. i++;
  15. }
  16. }
  17. function log(msg) {
  18. var tn = document.createTextNode(msg + "\n");
  19. document.getElementById("log").appendChild(tn);
  20. }
  21. function dragStart(e) {
  22. recordEvent(e);
  23. }
  24. document.ondragend = function(e) {
  25. recordEvent(e);
  26. };
  27. document.ondrop = function(e) {
  28. log("FAIL - we should not get a " + e.type);
  29. };
  30. document.ondragenter = document.ondragover = function(e) {
  31. e.preventDefault();
  32. };
  33. </script>
  34. </head>
  35. <body>
  36. <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=26699">https://bugs.webkit.org/show_bug.cgi?id=26699</a></p>
  37. <p>Instructions: </p>
  38. <p>Drag the "Drag Me!" link below</p>
  39. <p>Press escape</p>
  40. <a id="test-link" href="http://webkit.org" ondragstart="dragStart(event)">Drag Me!</a>
  41. <pre id="log"></pre>
  42. </body>
  43. </html>