michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // This test ensures that attempts made to save/restore ("duplicate") pages michael@0: // using designmode AND make changes to document structure (remove body) michael@0: // don't result in uncaught errors and a broken browser state. michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let testURL = "http://mochi.test:8888/browser/" + michael@0: "browser/components/sessionstore/test/browser_739531_sample.html"; michael@0: michael@0: let loadCount = 0; michael@0: let tab = gBrowser.addTab(testURL); michael@0: tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) { michael@0: // make sure both the page and the frame are loaded michael@0: if (++loadCount < 2) michael@0: return; michael@0: tab.linkedBrowser.removeEventListener("load", onLoad, true); michael@0: michael@0: // executeSoon to allow the JS to execute on the page michael@0: executeSoon(function() { michael@0: michael@0: let tab2; michael@0: let caughtError = false; michael@0: try { michael@0: tab2 = ss.duplicateTab(window, tab); michael@0: } michael@0: catch (e) { michael@0: caughtError = true; michael@0: info(e); michael@0: } michael@0: michael@0: is(gBrowser.tabs.length, 3, "there should be 3 tabs") michael@0: michael@0: ok(!caughtError, "duplicateTab didn't throw"); michael@0: michael@0: // if the test fails, we don't want to try to close a tab that doesn't exist michael@0: if (tab2) michael@0: gBrowser.removeTab(tab2); michael@0: gBrowser.removeTab(tab); michael@0: michael@0: finish(); michael@0: }); michael@0: }, true); michael@0: }