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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // This test ensures that attempts made to save/restore ("duplicate") pages |
michael@0 | 5 | // using designmode AND make changes to document structure (remove body) |
michael@0 | 6 | // don't result in uncaught errors and a broken browser state. |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | let testURL = "http://mochi.test:8888/browser/" + |
michael@0 | 12 | "browser/components/sessionstore/test/browser_739531_sample.html"; |
michael@0 | 13 | |
michael@0 | 14 | let loadCount = 0; |
michael@0 | 15 | let tab = gBrowser.addTab(testURL); |
michael@0 | 16 | tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) { |
michael@0 | 17 | // make sure both the page and the frame are loaded |
michael@0 | 18 | if (++loadCount < 2) |
michael@0 | 19 | return; |
michael@0 | 20 | tab.linkedBrowser.removeEventListener("load", onLoad, true); |
michael@0 | 21 | |
michael@0 | 22 | // executeSoon to allow the JS to execute on the page |
michael@0 | 23 | executeSoon(function() { |
michael@0 | 24 | |
michael@0 | 25 | let tab2; |
michael@0 | 26 | let caughtError = false; |
michael@0 | 27 | try { |
michael@0 | 28 | tab2 = ss.duplicateTab(window, tab); |
michael@0 | 29 | } |
michael@0 | 30 | catch (e) { |
michael@0 | 31 | caughtError = true; |
michael@0 | 32 | info(e); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | is(gBrowser.tabs.length, 3, "there should be 3 tabs") |
michael@0 | 36 | |
michael@0 | 37 | ok(!caughtError, "duplicateTab didn't throw"); |
michael@0 | 38 | |
michael@0 | 39 | // if the test fails, we don't want to try to close a tab that doesn't exist |
michael@0 | 40 | if (tab2) |
michael@0 | 41 | gBrowser.removeTab(tab2); |
michael@0 | 42 | gBrowser.removeTab(tab); |
michael@0 | 43 | |
michael@0 | 44 | finish(); |
michael@0 | 45 | }); |
michael@0 | 46 | }, true); |
michael@0 | 47 | } |