fune/browser/components/sessionstore/test/browser_restore_pageProxyState.js
Nika Layzell b5f81092ed Bug 1766951 - Avoid setting userTypedValue when restoring tabs, r=Gijs,farre
This userTypedValue being set was preventing the UrlbarInput from
updating the page proxy state to "valid", and showing the firefox badge
correctly, as the browser thinks the user typed the URL into the urlbar,
rather than it reflecting the currently loaded page.

This patch removes that set which was introduced as a wallpaper fix in
bug 439675 as it should no longer be required for its original purpose
since bug 599909. See bug 1766951 comment 6 for more details about the
reasoning behind removing this assignment.

Differential Revision: https://phabricator.services.mozilla.com/D145389
2022-05-05 22:55:38 +00:00

77 lines
2.1 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const BACKUP_STATE = SessionStore.getBrowserState();
registerCleanupFunction(() => promiseBrowserState(BACKUP_STATE));
// The pageproxystate of the restored tab controls whether the identity
// information in the URL bar will display correctly. See bug 1766951 for more
// context.
async function test_pageProxyState(url1, url2) {
info(`urls: "${url1}", "${url2}"`);
await SpecialPowers.pushPrefEnv({
set: [
["browser.sessionstore.restore_on_demand", true],
["browser.sessionstore.restore_tabs_lazily", true],
],
});
await promiseBrowserState({
windows: [
{
tabs: [
{
entries: [
{
url: url1,
triggeringPrincipal_base64,
},
],
},
{
entries: [
{
url: url2,
triggeringPrincipal_base64,
},
],
},
],
selected: 1,
},
],
});
// The first tab isn't lazy and should be initialized.
ok(gBrowser.tabs[0].linkedPanel, "first tab is not lazy");
is(gBrowser.selectedTab, gBrowser.tabs[0], "first tab is selected");
is(gBrowser.userTypedValue, null, "no user typed value");
is(
gURLBar.getAttribute("pageproxystate"),
"valid",
"has valid page proxy state"
);
// The second tab is lazy until selected.
ok(!gBrowser.tabs[1].linkedPanel, "second tab should be lazy");
gBrowser.selectedTab = gBrowser.tabs[1];
await promiseTabRestored(gBrowser.tabs[1]);
is(gBrowser.userTypedValue, null, "no user typed value");
is(
gURLBar.getAttribute("pageproxystate"),
"valid",
"has valid page proxy state"
);
}
add_task(async function test_system() {
await test_pageProxyState("about:support", "about:addons");
});
add_task(async function test_http() {
await test_pageProxyState(
"https://example.com/document-builder.sjs?html=tab1",
"https://example.com/document-builder.sjs?html=tab2"
);
});