michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: /** michael@0: * Make sure that tabs are restored on demand as otherwise the tab will start michael@0: * loading immediately and we can't check its icon and label. michael@0: */ michael@0: add_task(function setup() { michael@0: Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true); michael@0: michael@0: registerCleanupFunction(() => { michael@0: Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand"); michael@0: }); michael@0: }); michael@0: michael@0: /** michael@0: * Ensure that a pending tab has label and icon correctly set. michael@0: */ michael@0: add_task(function test_label_and_icon() { michael@0: // Create a new tab. michael@0: let tab = gBrowser.addTab("about:robots"); michael@0: let browser = tab.linkedBrowser; michael@0: yield promiseBrowserLoaded(browser); michael@0: michael@0: // Retrieve the tab state. michael@0: SyncHandlers.get(browser).flush(); michael@0: let state = ss.getTabState(tab); michael@0: gBrowser.removeTab(tab); michael@0: browser = null; michael@0: michael@0: // Open a new tab to restore into. michael@0: let tab = gBrowser.addTab("about:blank"); michael@0: ss.setTabState(tab, state); michael@0: yield promiseTabRestoring(tab); michael@0: michael@0: // Check that label and icon are set for the restoring tab. michael@0: ok(gBrowser.getIcon(tab).startsWith("data:image/png;"), "icon is set"); michael@0: is(tab.label, "Gort! Klaatu barada nikto!", "label is set"); michael@0: michael@0: // Cleanup. michael@0: gBrowser.removeTab(tab); michael@0: }); michael@0: michael@0: function promiseTabRestoring(tab) { michael@0: let deferred = Promise.defer(); michael@0: michael@0: tab.addEventListener("SSTabRestoring", function onRestoring() { michael@0: tab.removeEventListener("SSTabRestoring", onRestoring); michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: return deferred.promise; michael@0: }