1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_739531.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// This test ensures that attempts made to save/restore ("duplicate") pages 1.8 +// using designmode AND make changes to document structure (remove body) 1.9 +// don't result in uncaught errors and a broken browser state. 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + let testURL = "http://mochi.test:8888/browser/" + 1.15 + "browser/components/sessionstore/test/browser_739531_sample.html"; 1.16 + 1.17 + let loadCount = 0; 1.18 + let tab = gBrowser.addTab(testURL); 1.19 + tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) { 1.20 + // make sure both the page and the frame are loaded 1.21 + if (++loadCount < 2) 1.22 + return; 1.23 + tab.linkedBrowser.removeEventListener("load", onLoad, true); 1.24 + 1.25 + // executeSoon to allow the JS to execute on the page 1.26 + executeSoon(function() { 1.27 + 1.28 + let tab2; 1.29 + let caughtError = false; 1.30 + try { 1.31 + tab2 = ss.duplicateTab(window, tab); 1.32 + } 1.33 + catch (e) { 1.34 + caughtError = true; 1.35 + info(e); 1.36 + } 1.37 + 1.38 + is(gBrowser.tabs.length, 3, "there should be 3 tabs") 1.39 + 1.40 + ok(!caughtError, "duplicateTab didn't throw"); 1.41 + 1.42 + // if the test fails, we don't want to try to close a tab that doesn't exist 1.43 + if (tab2) 1.44 + gBrowser.removeTab(tab2); 1.45 + gBrowser.removeTab(tab); 1.46 + 1.47 + finish(); 1.48 + }); 1.49 + }, true); 1.50 +}