browser_739531.js (1482B)
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 = 12 "http://mochi.test:8888/browser/" + 13 "browser/components/sessionstore/test/browser_739531_sample.html"; 14 15 let loadCount = 0; 16 let tab = BrowserTestUtils.addTab(gBrowser, testURL); 17 18 let removeFunc; 19 removeFunc = BrowserTestUtils.addContentEventListener( 20 tab.linkedBrowser, 21 "load", 22 function onLoad() { 23 // make sure both the page and the frame are loaded 24 if (++loadCount < 2) { 25 return; 26 } 27 removeFunc(); 28 29 // executeSoon to allow the JS to execute on the page 30 executeSoon(function () { 31 let tab2; 32 let caughtError = false; 33 try { 34 tab2 = ss.duplicateTab(window, tab); 35 } catch (e) { 36 caughtError = true; 37 info(e); 38 } 39 40 is(gBrowser.tabs.length, 3, "there should be 3 tabs"); 41 42 ok(!caughtError, "duplicateTab didn't throw"); 43 44 // if the test fails, we don't want to try to close a tab that doesn't exist 45 if (tab2) { 46 gBrowser.removeTab(tab2); 47 } 48 gBrowser.removeTab(tab); 49 50 finish(); 51 }); 52 }, 53 true 54 ); 55 }