OLD | NEW |
(Empty) | |
| 1 <!DOCYUPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 |
| 6 async_test(t => { |
| 7 let testWindow = null; |
| 8 let messageCount = 0; |
| 9 |
| 10 // Test will run on testWindow that is opened below. |
| 11 // This page just received messages to confirm if tests run expectedly. |
| 12 const checkReady = e => { |
| 13 t.step(() => { |
| 14 // Will receive "READY" twice because of a reload, then receive "PASS". |
| 15 assert_equals(e.data, "READY", "received message is " + e.data); |
| 16 messageCount++; |
| 17 |
| 18 if (messageCount == 2) { |
| 19 window.removeEventListener("message", checkReady, false); |
| 20 window.addEventListener("message", e => { |
| 21 assert_equals(e.data, "PASS", "received message is " + e.data); |
| 22 t.done(); |
| 23 }, { once: true }); |
| 24 } |
| 25 |
| 26 // Send back "START" message for "READY". |
| 27 assert_class_string(testWindow, "Window", "testWindow is invalid"); |
| 28 testWindow.postMessage("START", location.origin); |
| 29 }); |
| 30 }; |
| 31 window.addEventListener("message", checkReady, false); |
| 32 |
| 33 // Start a test in a dedicated window because we can not track navigations |
| 34 // within a test harness. |
| 35 t.step(() => { |
| 36 testWindow = open("./resources/location-reload-window.html", "testWindow"); |
| 37 assert_class_string(testWindow, "Window", "window.open() failed"); |
| 38 }); |
| 39 }, "Test location.reload() cache behaviors"); |
| 40 </script> |
OLD | NEW |