Backed out changeset ffda592c113d (bug 1573924) for failures in browser_sessionRestore.js
authorNoemi Erli <nerli@mozilla.com>
Sat, 24 Aug 2019 02:43:14 +0300
changeset 553428 5d843f2c8ed9c2c4b3895588a492de3a3e526e5a
parent 553427 f6e49da543c7e4de6806f3ad9ea8c7b1bb4fd557
child 553429 c4c43bf71488d253bd9035afdff47c5c0d31aa45
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1573924
milestone70.0a1
backs outffda592c113d2fc619438e11a12fef412f6c0ffb
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset ffda592c113d (bug 1573924) for failures in browser_sessionRestore.js
browser/components/aboutlogins/content/aboutLogins.js
browser/components/aboutlogins/tests/browser/browser.ini
browser/components/aboutlogins/tests/browser/browser_sessionRestore.js
--- a/browser/components/aboutlogins/content/aboutLogins.js
+++ b/browser/components/aboutlogins/content/aboutLogins.js
@@ -1,107 +1,84 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 }));
--- a/browser/components/aboutlogins/tests/browser/browser.ini
+++ b/browser/components/aboutlogins/tests/browser/browser.ini
@@ -21,10 +21,9 @@ skip-if = asan || debug
 skip-if = (os == 'linux') # bug 1569789
 [browser_noLoginsView.js]
 [browser_openFiltered.js]
 [browser_openImport.js]
 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]
deleted file mode 100644
--- a/browser/components/aboutlogins/tests/browser/browser_sessionRestore.js
+++ /dev/null
@@ -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);
-});