browser/components/sessionstore/test/browser_label_and_icon.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 "use strict";
     6 /**
     7  * Make sure that tabs are restored on demand as otherwise the tab will start
     8  * loading immediately and we can't check its icon and label.
     9  */
    10 add_task(function setup() {
    11   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
    13   registerCleanupFunction(() => {
    14     Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
    15   });
    16 });
    18 /**
    19  * Ensure that a pending tab has label and icon correctly set.
    20  */
    21 add_task(function test_label_and_icon() {
    22   // Create a new tab.
    23   let tab = gBrowser.addTab("about:robots");
    24   let browser = tab.linkedBrowser;
    25   yield promiseBrowserLoaded(browser);
    27   // Retrieve the tab state.
    28   SyncHandlers.get(browser).flush();
    29   let state = ss.getTabState(tab);
    30   gBrowser.removeTab(tab);
    31   browser = null;
    33   // Open a new tab to restore into.
    34   let tab = gBrowser.addTab("about:blank");
    35   ss.setTabState(tab, state);
    36   yield promiseTabRestoring(tab);
    38   // Check that label and icon are set for the restoring tab.
    39   ok(gBrowser.getIcon(tab).startsWith("data:image/png;"), "icon is set");
    40   is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
    42   // Cleanup.
    43   gBrowser.removeTab(tab);
    44 });
    46 function promiseTabRestoring(tab) {
    47   let deferred = Promise.defer();
    49   tab.addEventListener("SSTabRestoring", function onRestoring() {
    50     tab.removeEventListener("SSTabRestoring", onRestoring);
    51     deferred.resolve();
    52   });
    54   return deferred.promise;
    55 }

mercurial