Backed out changeset ffda592c113d (bug 1573924) for failures in browser_sessionRestore.js

This commit is contained in:
Noemi Erli 2019-08-24 02:43:14 +03:00
Родитель a9c174c337
Коммит e9426c83aa
3 изменённых файлов: 77 добавлений и 166 удалений

Просмотреть файл

@ -2,106 +2,83 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
let aboutLogins = {
loaded: false,
handleEvent(event) {
// Run the initialization code for DOMContentLoaded and
// pageshow to handle normal loads and sessionrestore/bfcache.
if (this.loaded) {
return;
}
this.loaded = true;
this._onLoad(event);
},
_onLoad(event2) {
const gElements = {
fxAccountsButton: document.querySelector("fxaccounts-button"),
loginList: document.querySelector("login-list"),
loginIntro: document.querySelector("login-intro"),
loginItem: document.querySelector("login-item"),
loginFilter: document.querySelector("login-filter"),
// loginFooter is nested inside of loginItem
get loginFooter() {
return this.loginItem.shadowRoot.querySelector("login-footer");
},
};
let numberOfLogins = 0;
let { searchParams } = new URL(document.location);
if (searchParams.get("filter")) {
gElements.loginFilter.value = searchParams.get("filter");
}
gElements.loginFilter.focus();
function updateNoLogins() {
document.documentElement.classList.toggle(
"no-logins",
numberOfLogins == 0
);
gElements.loginList.classList.toggle("no-logins", numberOfLogins == 0);
}
window.addEventListener("AboutLoginsChromeToContent", event => {
switch (event.detail.messageType) {
case "AllLogins": {
gElements.loginList.setLogins(event.detail.value);
numberOfLogins = event.detail.value.length;
updateNoLogins();
break;
}
case "InitialInfo": {
gElements.loginFooter.hidden = event.detail.value.hideMobileFooter;
break;
}
case "LocalizeBadges": {
gElements.loginFooter.showStoreIconsForLocales(event.detail.value);
break;
}
case "LoginAdded": {
gElements.loginList.loginAdded(event.detail.value);
gElements.loginItem.loginAdded(event.detail.value);
numberOfLogins++;
updateNoLogins();
break;
}
case "LoginModified": {
gElements.loginList.loginModified(event.detail.value);
gElements.loginItem.loginModified(event.detail.value);
break;
}
case "LoginRemoved": {
gElements.loginList.loginRemoved(event.detail.value);
gElements.loginItem.loginRemoved(event.detail.value);
numberOfLogins--;
updateNoLogins();
break;
}
case "SendFavicons": {
gElements.loginList.addFavicons(event.detail.value);
break;
}
case "SyncState": {
gElements.fxAccountsButton.updateState(event.detail.value);
break;
}
case "UpdateBreaches": {
gElements.loginList.updateBreaches(event.detail.value);
gElements.loginItem.updateBreaches(event.detail.value);
break;
}
}
});
document.dispatchEvent(
new CustomEvent("AboutLoginsInit", { bubbles: true })
);
// The init code isn't wrapped in a DOMContentLoaded/load event listener so the
// page works properly when restored from session restore.
const gElements = {
fxAccountsButton: document.querySelector("fxaccounts-button"),
loginList: document.querySelector("login-list"),
loginIntro: document.querySelector("login-intro"),
loginItem: document.querySelector("login-item"),
loginFilter: document.querySelector("login-filter"),
// loginFooter is nested inside of loginItem
get loginFooter() {
return this.loginItem.shadowRoot.querySelector("login-footer");
},
};
// Run the initialization code for DOMContentLoaded and
// pageshow to handle normal loads and sessionrestore/bfcache.
window.addEventListener("DOMContentLoaded", aboutLogins, { once: true });
window.addEventListener("pageshow", aboutLogins, { once: true });
let numberOfLogins = 0;
let { searchParams } = new URL(document.location);
if (searchParams.get("filter")) {
gElements.loginFilter.value = searchParams.get("filter");
}
gElements.loginFilter.focus();
function updateNoLogins() {
document.documentElement.classList.toggle("no-logins", numberOfLogins == 0);
gElements.loginList.classList.toggle("no-logins", numberOfLogins == 0);
}
window.addEventListener("AboutLoginsChromeToContent", event => {
switch (event.detail.messageType) {
case "AllLogins": {
gElements.loginList.setLogins(event.detail.value);
numberOfLogins = event.detail.value.length;
updateNoLogins();
break;
}
case "InitialInfo": {
gElements.loginFooter.hidden = event.detail.value.hideMobileFooter;
break;
}
case "LocalizeBadges": {
gElements.loginFooter.showStoreIconsForLocales(event.detail.value);
break;
}
case "LoginAdded": {
gElements.loginList.loginAdded(event.detail.value);
gElements.loginItem.loginAdded(event.detail.value);
numberOfLogins++;
updateNoLogins();
break;
}
case "LoginModified": {
gElements.loginList.loginModified(event.detail.value);
gElements.loginItem.loginModified(event.detail.value);
break;
}
case "LoginRemoved": {
gElements.loginList.loginRemoved(event.detail.value);
gElements.loginItem.loginRemoved(event.detail.value);
numberOfLogins--;
updateNoLogins();
break;
}
case "SendFavicons": {
gElements.loginList.addFavicons(event.detail.value);
break;
}
case "SyncState": {
gElements.fxAccountsButton.updateState(event.detail.value);
break;
}
case "UpdateBreaches": {
gElements.loginList.updateBreaches(event.detail.value);
gElements.loginItem.updateBreaches(event.detail.value);
break;
}
}
});
document.dispatchEvent(new CustomEvent("AboutLoginsInit", { bubbles: true }));

Просмотреть файл

@ -26,5 +26,4 @@ skip-if = (os != "win") # import is only available on Windows
[browser_openPreferences.js]
[browser_openPreferencesExternal.js]
[browser_openSite.js]
[browser_sessionRestore.js]
[browser_updateLogin.js]

Просмотреть файл

@ -1,65 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { TabState } = ChromeUtils.import(
"resource:///modules/sessionstore/TabState.jsm"
);
add_task(async function() {
TEST_LOGIN1 = await addLogin(TEST_LOGIN1);
const testGuid = TEST_LOGIN1.guid;
const tab = BrowserTestUtils.addTab(gBrowser, "about:logins");
const browser = gBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
await ContentTask.spawn(browser, testGuid, async function(guid) {
let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
let loginFound = await ContentTaskUtils.waitForCondition(() => {
return (
loginList._loginGuidsSortedOrder.length == 1 &&
loginList._loginGuidsSortedOrder[0] == guid
);
}, "Waiting for login to be displayed in page");
ok(loginFound, "Confirming that login is displayed in page");
});
BrowserTestUtils.removeTab(tab);
info("Adding a lazy about:logins tab...");
let lazyTab = BrowserTestUtils.addTab(gBrowser, "about:logins", {
createLazyBrowser: true,
});
is(lazyTab.linkedPanel, "", "Tab is lazy");
let tabLoaded = new Promise(resolve => {
gBrowser.addTabsProgressListener({
async onLocationChange(aBrowser) {
if (lazyTab.linkedBrowser == aBrowser) {
gBrowser.removeTabsProgressListener(this);
await Promise.resolve();
resolve();
}
},
});
});
info("Switching tab to cause it to get restored");
await BrowserTestUtils.switchTab(gBrowser, lazyTab);
await tabLoaded;
let lazyBrowser = lazyTab.linkedBrowser;
await ContentTask.spawn(lazyBrowser, testGuid, async function(guid) {
let loginList = Cu.waiveXrays(content.document.querySelector("login-list"));
let loginFound = await ContentTaskUtils.waitForCondition(() => {
return (
loginList._loginGuidsSortedOrder.length == 1 &&
loginList._loginGuidsSortedOrder[0] == guid
);
}, "Waiting for login to be displayed in restored page");
ok(loginFound, "Confirming that login is displayed in restored page");
});
BrowserTestUtils.removeTab(lazyTab);
});