Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | var testUrls = |
michael@0 | 2 | [ |
michael@0 | 3 | "data:text/html,<script>" + |
michael@0 | 4 | "function handle(evt) {" + |
michael@0 | 5 | "evt.target.removeEventListener(evt.type, handle, true);" + |
michael@0 | 6 | "try { alert('This should NOT appear'); } catch(e) { }" + |
michael@0 | 7 | "}" + |
michael@0 | 8 | "window.addEventListener('pagehide', handle, true);" + |
michael@0 | 9 | "window.addEventListener('beforeunload', handle, true);" + |
michael@0 | 10 | "window.addEventListener('unload', handle, true);" + |
michael@0 | 11 | "</script><body>Testing alert during pagehide/beforeunload/unload</body>", |
michael@0 | 12 | "data:text/html,<script>" + |
michael@0 | 13 | "function handle(evt) {" + |
michael@0 | 14 | "evt.target.removeEventListener(evt.type, handle, true);" + |
michael@0 | 15 | "try { prompt('This should NOT appear'); } catch(e) { }" + |
michael@0 | 16 | "}" + |
michael@0 | 17 | "window.addEventListener('pagehide', handle, true);" + |
michael@0 | 18 | "window.addEventListener('beforeunload', handle, true);" + |
michael@0 | 19 | "window.addEventListener('unload', handle, true);" + |
michael@0 | 20 | "</script><body>Testing prompt during pagehide/beforeunload/unload</body>", |
michael@0 | 21 | "data:text/html,<script>" + |
michael@0 | 22 | "function handle(evt) {" + |
michael@0 | 23 | "evt.target.removeEventListener(evt.type, handle, true);" + |
michael@0 | 24 | "try { confirm('This should NOT appear'); } catch(e) { }" + |
michael@0 | 25 | "}" + |
michael@0 | 26 | "window.addEventListener('pagehide', handle, true);" + |
michael@0 | 27 | "window.addEventListener('beforeunload', handle, true);" + |
michael@0 | 28 | "window.addEventListener('unload', handle, true);" + |
michael@0 | 29 | "</script><body>Testing confirm during pagehide/beforeunload/unload</body>", |
michael@0 | 30 | ]; |
michael@0 | 31 | var testsDone = 0; |
michael@0 | 32 | |
michael@0 | 33 | function test() |
michael@0 | 34 | { |
michael@0 | 35 | waitForExplicitFinish(); |
michael@0 | 36 | runTest(); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function runTest() |
michael@0 | 40 | { |
michael@0 | 41 | whenNewTabLoaded(window, function() { |
michael@0 | 42 | gBrowser.selectedBrowser.addEventListener("load", onLoad, true); |
michael@0 | 43 | executeSoon(function() { |
michael@0 | 44 | info("Loading page with pagehide, beforeunload, and unload handlers that attempt to create dialogs"); |
michael@0 | 45 | gBrowser.selectedBrowser.loadURI(testUrls[testsDone]); |
michael@0 | 46 | }); |
michael@0 | 47 | }); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function onLoad(event) |
michael@0 | 51 | { |
michael@0 | 52 | info("Page loaded"); |
michael@0 | 53 | |
michael@0 | 54 | event.target.removeEventListener("load", onLoad, true); |
michael@0 | 55 | gBrowser.selectedBrowser.addEventListener("unload", done, true); |
michael@0 | 56 | |
michael@0 | 57 | executeSoon(function () { |
michael@0 | 58 | info("Closing page"); |
michael@0 | 59 | gBrowser.removeCurrentTab(); |
michael@0 | 60 | }); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function done() { |
michael@0 | 64 | ok(true, "Page closed (hopefully) without timeout"); |
michael@0 | 65 | |
michael@0 | 66 | testsDone++; |
michael@0 | 67 | if (testsDone == testUrls.length) { |
michael@0 | 68 | finish(); |
michael@0 | 69 | return; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | executeSoon(runTest); |
michael@0 | 73 | } |