michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: michael@0: const URL = "http://mochi.test:8888/browser/"; michael@0: const PREF = "browser.sessionstore.restore_on_demand"; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: Services.prefs.setBoolPref(PREF, true); michael@0: registerCleanupFunction(function () { michael@0: Services.prefs.clearUserPref(PREF); michael@0: }); michael@0: michael@0: preparePendingTab(function (aTab) { michael@0: let win = gBrowser.replaceTabWithWindow(aTab); michael@0: michael@0: whenDelayedStartupFinished(win, function () { michael@0: let [tab] = win.gBrowser.tabs; michael@0: michael@0: whenLoaded(tab.linkedBrowser, function () { michael@0: is(tab.linkedBrowser.currentURI.spec, URL, "correct url should be loaded"); michael@0: ok(!tab.hasAttribute("pending"), "tab should not be pending"); michael@0: michael@0: win.close(); michael@0: finish(); michael@0: }); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function preparePendingTab(aCallback) { michael@0: let tab = gBrowser.addTab(URL); michael@0: michael@0: whenLoaded(tab.linkedBrowser, function () { michael@0: gBrowser.removeTab(tab); michael@0: let [{state}] = JSON.parse(SessionStore.getClosedTabData(window)); michael@0: michael@0: tab = gBrowser.addTab("about:blank"); michael@0: whenLoaded(tab.linkedBrowser, function () { michael@0: SessionStore.setTabState(tab, JSON.stringify(state)); michael@0: ok(tab.hasAttribute("pending"), "tab should be pending"); michael@0: aCallback(tab); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function whenLoaded(aElement, aCallback) { michael@0: aElement.addEventListener("load", function onLoad() { michael@0: aElement.removeEventListener("load", onLoad, true); michael@0: executeSoon(aCallback); michael@0: }, true); michael@0: }