browser/base/content/test/general/browser_bug817947.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial