|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 |
|
5 const URL = "http://mochi.test:8888/browser/"; |
|
6 const PREF = "browser.sessionstore.restore_on_demand"; |
|
7 |
|
8 function test() { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 Services.prefs.setBoolPref(PREF, true); |
|
12 registerCleanupFunction(function () { |
|
13 Services.prefs.clearUserPref(PREF); |
|
14 }); |
|
15 |
|
16 preparePendingTab(function (aTab) { |
|
17 let win = gBrowser.replaceTabWithWindow(aTab); |
|
18 |
|
19 whenDelayedStartupFinished(win, function () { |
|
20 let [tab] = win.gBrowser.tabs; |
|
21 |
|
22 whenLoaded(tab.linkedBrowser, function () { |
|
23 is(tab.linkedBrowser.currentURI.spec, URL, "correct url should be loaded"); |
|
24 ok(!tab.hasAttribute("pending"), "tab should not be pending"); |
|
25 |
|
26 win.close(); |
|
27 finish(); |
|
28 }); |
|
29 }); |
|
30 }); |
|
31 } |
|
32 |
|
33 function preparePendingTab(aCallback) { |
|
34 let tab = gBrowser.addTab(URL); |
|
35 |
|
36 whenLoaded(tab.linkedBrowser, function () { |
|
37 gBrowser.removeTab(tab); |
|
38 let [{state}] = JSON.parse(SessionStore.getClosedTabData(window)); |
|
39 |
|
40 tab = gBrowser.addTab("about:blank"); |
|
41 whenLoaded(tab.linkedBrowser, function () { |
|
42 SessionStore.setTabState(tab, JSON.stringify(state)); |
|
43 ok(tab.hasAttribute("pending"), "tab should be pending"); |
|
44 aCallback(tab); |
|
45 }); |
|
46 }); |
|
47 } |
|
48 |
|
49 function whenLoaded(aElement, aCallback) { |
|
50 aElement.addEventListener("load", function onLoad() { |
|
51 aElement.removeEventListener("load", onLoad, true); |
|
52 executeSoon(aCallback); |
|
53 }, true); |
|
54 } |