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