Backed out 2 changesets (bug 1259729) for pocket test failures
authorWes Kocher <wkocher@mozilla.com>
Fri, 01 Apr 2016 09:53:07 -0700
changeset 291401 543ba2e092d2d4de86b1994a646ee75df5519c58
parent 291400 320b39130851d20d0f4dd654e1b6f8f322c686fb
child 291402 c40c0b2f3b4c778af4307e090b4063b63c806cda
child 291457 8e350c4b966f97902ab2d95cd9d70a88d1e70c68
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1259729
milestone48.0a1
backs out9b5113e833ff005d4845e88d8de1041985a8c5c7
24134582d0ce49abdb224820c95e5ae5dae60174
Backed out 2 changesets (bug 1259729) for pocket test failures Backed out changeset 9b5113e833ff (bug 1259729) Backed out changeset 24134582d0ce (bug 1259729) MozReview-Commit-ID: AKMIgo1HJBi
browser/extensions/pocket/bootstrap.js
browser/extensions/pocket/test/browser.ini
browser/extensions/pocket/test/browser_pocket_ui_check.js
browser/extensions/pocket/test/head.js
browser/extensions/pocket/test/test.html
--- a/browser/extensions/pocket/bootstrap.js
+++ b/browser/extensions/pocket/bootstrap.js
@@ -378,18 +378,22 @@ var PocketOverlay = {
                                                        this._sheetType);
     AboutSaved.register();
     AboutSignup.register();
     PocketReader.startup();
     CustomizableUI.addListener(this);
     CreatePocketWidget(reason);
     PocketContextMenu.init();
 
-    for (let win of allBrowserWindows()) {
-      this.onWindowOpened(win);
+    if (reason != APP_STARTUP) {
+      for (let win of allBrowserWindows()) {
+        this.setWindowScripts(win);
+        this.addStyles(win);
+        this.updateWindow(win);
+      }
     }
   },
   shutdown: function(reason) {
     AboutSaved.unregister();
     AboutSignup.unregister();
     CustomizableUI.removeListener(this);
     for (let window of allBrowserWindows()) {
       for (let id of ["panelMenu_pocket", "menu_pocket", "BMB_pocket",
@@ -405,18 +409,16 @@ var PocketOverlay = {
       delete window.pktUI;
       delete window.pktUIMessaging;
     }
     CustomizableUI.destroyWidget("pocket-button");
     PocketContextMenu.shutdown();
     PocketReader.shutdown();
   },
   onWindowOpened: function(window) {
-    if (window.hasOwnProperty("pktUI"))
-      return;
     this.setWindowScripts(window);
     this.addStyles(window);
     this.updateWindow(window);
   },
   setWindowScripts: function(window) {
     XPCOMUtils.defineLazyModuleGetter(window, "Pocket",
                                       "chrome://pocket/content/Pocket.jsm");
     // Can't use XPCOMUtils for these because the scripts try to define the variables
--- a/browser/extensions/pocket/test/browser.ini
+++ b/browser/extensions/pocket/test/browser.ini
@@ -1,6 +1,1 @@
-[DEFAULT]
-support-files =
-  head.js
-
 [browser_pocket_ui_check.js]
-support-files = test.html
--- a/browser/extensions/pocket/test/browser_pocket_ui_check.js
+++ b/browser/extensions/pocket/test/browser_pocket_ui_check.js
@@ -1,54 +1,21 @@
 "use strict";
 
-function checkWindowProperties(expectPresent, l) {
-  for (let name of l) {
-    is(!!window.hasOwnProperty(name), expectPresent, "property " + name + (expectPresent ? " is" : " is not") + " present");
-  }
-}
-function checkElements(expectPresent, l) {
-  for (let id of l) {
-    is(!!document.getElementById(id), expectPresent, "element " + id + (expectPresent ? " is" : " is not") + " present");
-  }
-}
-
 add_task(function*() {
-  let enabledOnStartup = yield promisePocketEnabled();
-  registerCleanupFunction(() => {
-    // Extra insurance that this is disabled again, but it should have been set
-    // in promisePocketReset.
-    Services.prefs.setBoolPref("extensions.pocket.enabled", enabledOnStartup);
+  let pocketAddon = yield new Promise(resolve => {
+    AddonManager.getAddonByID("firefox@getpocket.com", resolve);
   });
-
-  checkWindowProperties(true, ["Pocket", "pktUI", "pktUIMessaging"]);
-  checkElements(true, ["pocket-button", "panelMenu_pocket", "menu_pocket", "BMB_pocket",
-                       "panelMenu_pocketSeparator", "menu_pocketSeparator",
-                       "BMB_pocketSeparator"]);
-
-  // check context menu exists
-  info("checking content context menu");
-  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "https://example.com/browser/browser/extensions/pocket/test/test.html");
+  if (!pocketAddon) {
+    ok(true, "Pocket is not installed");
+    return;
+  }
+  if (!Services.prefs.getBoolPref("extensions.pocket.enabled")) {
+    ok(true, "Pocket add-on is not enabled");
+    return;
+  }
 
-  let contextMenu = document.getElementById("contentAreaContextMenu");
-  let popupShown = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
-  let popupHidden = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
-  yield BrowserTestUtils.synthesizeMouseAtCenter("body", {
-    type: "contextmenu",
-    button: 2
-  }, tab.linkedBrowser);
-  yield popupShown;
-
-  checkElements(true, ["context-pocket", "context-savelinktopocket"]);
-
-  contextMenu.hidePopup();
-  yield popupHidden;
-  yield BrowserTestUtils.removeTab(tab);
-
-  yield promisePocketDisabled();
-
-  checkWindowProperties(false, ["Pocket", "pktUI", "pktUIMessaging"]);
-  checkElements(false, ["pocket-button", "panelMenu_pocket", "menu_pocket", "BMB_pocket",
-                       "panelMenu_pocketSeparator", "menu_pocketSeparator",
-                       "BMB_pocketSeparator", "context-pocket", "context-savelinktopocket"]);
-
-  yield promisePocketReset();
+  for (let id of ["panelMenu_pocket", "menu_pocket", "BMB_pocket",
+                  "panelMenu_pocketSeparator", "menu_pocketSeparator",
+                  "BMB_pocketSeparator"]) {
+    ok(document.getElementById(id), "Should see element with id " + id);
+  }
 });
deleted file mode 100644
--- a/browser/extensions/pocket/test/head.js
+++ /dev/null
@@ -1,68 +0,0 @@
-// Currently Pocket is disabled in tests.  We want these tests to work under
-// either case that Pocket is disabled or enabled on startup of the browser,
-// and that at the end we're reset to the correct state.
-let enabledOnStartup = false;
-
-// PocketEnabled/Disabled promises return true if it was already
-// Enabled/Disabled, and false if it need to Enable/Disable.
-function promisePocketEnabled() {
-  if (Services.prefs.getPrefType("extensions.pocket.enabled") != Services.prefs.PREF_INVALID &&
-      Services.prefs.getBoolPref("extensions.pocket.enabled")) {
-    info( "pocket was already enabled, assuming enabled by default for tests");
-    enabledOnStartup = true;
-    return Promise.resolve(true);
-  }
-  info( "pocket is not enabled");
-  return new Promise((resolve, reject) => {
-    let listener = {
-      onWidgetAfterCreation(widgetid) {
-        if (widgetid == "pocket-button") {
-          info("pocket-button created");
-          CustomizableUI.removeListener(listener);
-          resolve(false);
-        }
-      }
-    }
-    CustomizableUI.addListener(listener);
-    Services.prefs.setBoolPref("extensions.pocket.enabled", true);
-  });
-}
-
-function promisePocketDisabled() {
-  if (Services.prefs.getPrefType("extensions.pocket.enabled") == Services.prefs.PREF_INVALID ||
-      !Services.prefs.getBoolPref("extensions.pocket.enabled")) {
-    info("pocket-button already disabled");
-    return Promise.resolve(true);
-  }
-  return new Promise((resolve, reject) => {
-    let listener = {
-      onWidgetDestroyed: function(widgetid) {
-        if (widgetid == "pocket-button") {
-          CustomizableUI.removeListener(listener);
-          info( "pocket-button destroyed");
-          // wait for a full unload of pocket
-          BrowserTestUtils.waitForCondition(() => {
-            return !window.hasOwnProperty("pktUI");
-          }, "pocket properties removed from window").then(() => {
-            resolve(false);
-          })
-        }
-      }
-    }
-    CustomizableUI.addListener(listener);
-    info("reset pocket enabled pref");
-    // testing/profiles/prefs_general.js uses user_pref to disable pocket, set
-    // back to false.
-    Services.prefs.setBoolPref("extensions.pocket.enabled", false);
-  });
-}
-
-function promisePocketReset() {
-  if (enabledOnStartup) {
-    info("reset is enabling pocket addon");
-    return promisePocketEnabled();
-  } else {
-    info("reset is disabling pocket addon");
-    return promisePocketDisabled();
-  }
-}
deleted file mode 100644
--- a/browser/extensions/pocket/test/test.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-
-<html>
-<head>
-    <title>Page Title</title>
-    <meta charset="utf-8" />
-</head>
-
-<body>
-</body>
-</html>