test_window_open_close.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  6. <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  7. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  8. </head>
  9. <script type="application/javascript">
  10. SimpleTest.waitForExplicitFinish();
  11. // Opens a popup. Link should load in main browser window. Popup should be closed when link clicked.
  12. function openWindow1() {
  13. return window.open('file_window_open_close_outer.html','','width=300,height=200');
  14. }
  15. // Opens a new tab T1. Link opens in another new tab T2. T1 should close when link clicked.
  16. function openWindow2() {
  17. return window.open('file_window_open_close_outer.html');
  18. }
  19. // Opens a new window. Link should open in a new tab of that window, but then both windows should close.
  20. function openWindow3() {
  21. return window.open('file_window_open_close_outer.html', '', 'toolbar=1');
  22. }
  23. var TESTS = [openWindow1, openWindow2, openWindow3];
  24. function popupLoad(win)
  25. {
  26. info("Sending click");
  27. sendMouseEvent({type: "click"}, "link", win);
  28. ok(true, "Didn't crash");
  29. next();
  30. }
  31. function next()
  32. {
  33. if (TESTS.length == 0) {
  34. SimpleTest.finish();
  35. } else {
  36. var test = TESTS.shift();
  37. var w = test();
  38. w.addEventListener("load", (e) => popupLoad(w));
  39. }
  40. }
  41. </script>
  42. <body onload="next()">
  43. </body>
  44. </html>