2014-01-17 20:17:14 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that a pending tab has label and icon correctly set.
|
|
|
|
*/
|
2017-05-12 15:42:39 +03:00
|
|
|
add_task(async function test_label_and_icon() {
|
2017-07-06 12:40:42 +03:00
|
|
|
// Make sure that tabs are restored on demand as otherwise the tab will start
|
|
|
|
// loading immediately and we can't check its icon and label.
|
|
|
|
await SpecialPowers.pushPrefEnv({
|
|
|
|
set: [["browser.sessionstore.restore_on_demand", true]],
|
|
|
|
});
|
|
|
|
|
2014-01-17 20:17:14 +04:00
|
|
|
// Create a new tab.
|
2017-05-15 22:49:50 +03:00
|
|
|
let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
|
2014-01-17 20:17:14 +04:00
|
|
|
let browser = tab.linkedBrowser;
|
2017-05-12 15:42:39 +03:00
|
|
|
await promiseBrowserLoaded(browser);
|
2017-09-12 16:47:51 +03:00
|
|
|
// Because there is debounce logic in ContentLinkHandler.jsm to reduce the
|
|
|
|
// favicon loads, we have to wait some time before checking that icon was
|
|
|
|
// stored properly.
|
|
|
|
await BrowserTestUtils.waitForCondition(() => {
|
|
|
|
return gBrowser.getIcon(tab) != null;
|
|
|
|
}, "wait for favicon load to finish", 100, 5);
|
2014-01-17 20:17:14 +04:00
|
|
|
|
|
|
|
// Retrieve the tab state.
|
2017-05-12 15:42:39 +03:00
|
|
|
await TabStateFlusher.flush(browser);
|
2014-01-17 20:17:14 +04:00
|
|
|
let state = ss.getTabState(tab);
|
2018-03-19 05:12:13 +03:00
|
|
|
BrowserTestUtils.removeTab(tab);
|
2014-01-17 20:17:14 +04:00
|
|
|
browser = null;
|
|
|
|
|
|
|
|
// Open a new tab to restore into.
|
2017-05-15 22:49:50 +03:00
|
|
|
tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
2014-01-17 20:17:14 +04:00
|
|
|
ss.setTabState(tab, state);
|
2017-05-12 15:42:39 +03:00
|
|
|
await promiseTabRestoring(tab);
|
2014-01-17 20:17:14 +04:00
|
|
|
|
|
|
|
// Check that label and icon are set for the restoring tab.
|
2017-04-28 00:59:16 +03:00
|
|
|
is(gBrowser.getIcon(tab), "chrome://browser/content/robot.ico", "icon is set");
|
2014-01-17 20:17:14 +04:00
|
|
|
is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
|
|
|
|
|
2016-09-13 16:18:38 +03:00
|
|
|
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
|
|
|
|
.getService(Ci.nsISerializationHelper);
|
2017-10-20 04:19:57 +03:00
|
|
|
let serializedPrincipal = tab.getAttribute("iconloadingprincipal");
|
2016-09-13 16:18:38 +03:00
|
|
|
let iconLoadingPrincipal = serhelper.deserializeObject(serializedPrincipal)
|
|
|
|
.QueryInterface(Ci.nsIPrincipal);
|
|
|
|
is(iconLoadingPrincipal.origin, "about:robots", "correct loadingPrincipal used");
|
|
|
|
|
2014-01-17 20:17:14 +04:00
|
|
|
// Cleanup.
|
2018-03-19 05:12:13 +03:00
|
|
|
BrowserTestUtils.removeTab(tab);
|
2014-01-17 20:17:14 +04:00
|
|
|
});
|