Backed out changeset 5d81dab28e18 (bug 1261785)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 17 Apr 2016 12:27:33 +0200
changeset 331353 ba3c8cb72bdae91bd4a81bcb69ce71b4772b3395
parent 331352 20eec5d1b5907e40e23d9a4b9d1640421bc69bef
child 331354 f8c0dd78206cac5a132b164ebacfa8ffbac9713c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1261785
milestone48.0a1
backs out5d81dab28e18ffa65aed7e996996a386dce44199
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 5d81dab28e18 (bug 1261785)
devtools/client/framework/test/shared-head.js
devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
devtools/client/storage/test/browser.ini
devtools/client/storage/test/browser_storage_cache_error.js
devtools/client/storage/test/head.js
devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
devtools/client/webconsole/test/browser_console_copy_entire_message_context_menu.js
devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
devtools/client/webconsole/test/head.js
--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -312,56 +312,8 @@ function evalInDebuggee (mm, script) {
       }
 
       info(`Successfully evaled in debuggee: ${script}`);
       mm.removeMessageListener("devtools:test:eval:response", handler);
       resolve(data.value);
     }
   });
 }
-
-/**
- * Wait for a context menu popup to open.
- *
- * @param nsIDOMElement popup
- *        The XUL popup you expect to open.
- * @param nsIDOMElement button
- *        The button/element that receives the contextmenu event. This is
- *        expected to open the popup.
- * @param function onShown
- *        Function to invoke on popupshown event.
- * @param function onHidden
- *        Function to invoke on popuphidden event.
- * @return object
- *         A Promise object that is resolved after the popuphidden event
- *         callback is invoked.
- */
-function waitForContextMenu(popup, button, onShown, onHidden) {
-  let deferred = promise.defer();
-
-  function onPopupShown() {
-    info("onPopupShown");
-    popup.removeEventListener("popupshown", onPopupShown);
-
-    onShown && onShown();
-
-    // Use executeSoon() to get out of the popupshown event.
-    popup.addEventListener("popuphidden", onPopupHidden);
-    executeSoon(() => popup.hidePopup());
-  }
-  function onPopupHidden() {
-    info("onPopupHidden");
-    popup.removeEventListener("popuphidden", onPopupHidden);
-
-    onHidden && onHidden();
-
-    deferred.resolve(popup);
-  }
-
-  popup.addEventListener("popupshown", onPopupShown);
-
-  info("wait for the context menu to open");
-  button.scrollIntoView();
-  let eventDetails = {type: "contextmenu", button: 2};
-  EventUtils.synthesizeMouse(button, 2, 2, eventDetails,
-                             button.ownerDocument.defaultView);
-  return deferred.promise;
-}
--- a/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
+++ b/devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.js
@@ -1,21 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests getAdjustedQuads works properly in a variety of use cases including
 // iframes, scroll and zoom
 
-"use strict";
-
+var {utils: Cu} = Components;
 var {getAdjustedQuads} = require("devtools/shared/layout/utils");
 
 const TEST_URI = TEST_URI_ROOT + "browser_layoutHelpers-getBoxQuads.html";
 
 add_task(function* () {
+
   let tab = yield addTab(TEST_URI);
   let doc = tab.linkedBrowser.contentDocument;
 
   ok(typeof getAdjustedQuads === "function", "getAdjustedQuads is defined");
 
   info("Running tests");
 
   returnsTheRightDataStructure(doc);
--- a/devtools/client/storage/test/browser.ini
+++ b/devtools/client/storage/test/browser.ini
@@ -10,17 +10,16 @@ support-files =
   storage-localstorage.html
   storage-overflow.html
   storage-search.html
   storage-secured-iframe.html
   storage-sessionstorage.html
   storage-unsecured-iframe.html
   storage-updates.html
   head.js
-  !/devtools/client/framework/test/shared-head.js
 
 [browser_storage_basic.js]
 [browser_storage_cache_error.js]
 [browser_storage_cookies_delete_all.js]
 [browser_storage_cookies_edit.js]
 [browser_storage_cookies_edit_keyboard.js]
 [browser_storage_cookies_tab_navigation.js]
 [browser_storage_delete.js]
--- a/devtools/client/storage/test/browser_storage_cache_error.js
+++ b/devtools/client/storage/test/browser_storage_cache_error.js
@@ -8,14 +8,14 @@
 
 // Test handling errors in CacheStorage
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cache-error.html");
 
   const cacheItemId = ["Cache", "javascript:parent.frameContent"];
 
-  yield selectTreeItem(cacheItemId);
+  gUI.tree.selectedItem = cacheItemId;
   ok(gUI.tree.isSelected(cacheItemId),
     `The item ${cacheItemId.join(" > ")} is present in the tree`);
 
   yield finishTests();
 });
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -1,63 +1,105 @@
 /* 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/. */
 
 "use strict";
 
 /* eslint no-unused-vars: [2, {"vars": "local"}] */
-/* import-globals-from ../../framework/test/shared-head.js */
 
-// shared-head.js handles imports, constants, and utility functions
-Services.scriptloader.loadSubScript(
-  "chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js",
-  this);
+var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+var { TargetFactory } = require("devtools/client/framework/target");
+var promise = require("promise");
+var DevToolsUtils = require("devtools/shared/DevToolsUtils");
 
 const {TableWidget} = require("devtools/client/shared/widgets/TableWidget");
 const SPLIT_CONSOLE_PREF = "devtools.toolbox.splitconsoleEnabled";
 const STORAGE_PREF = "devtools.storage.enabled";
 const DUMPEMIT_PREF = "devtools.dump.emit";
 const DEBUGGERLOG_PREF = "devtools.debugger.log";
 // Allows Cache API to be working on usage `http` test page
 const CACHES_ON_HTTP_PREF = "dom.caches.testing.enabled";
 const PATH = "browser/devtools/client/storage/test/";
 const MAIN_DOMAIN = "http://test1.example.org/" + PATH;
 const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
 const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
 
+waitForExplicitFinish();
+
 var gToolbox, gPanelWindow, gWindow, gUI;
 
 // Services.prefs.setBoolPref(DUMPEMIT_PREF, true);
 // Services.prefs.setBoolPref(DEBUGGERLOG_PREF, true);
 
 Services.prefs.setBoolPref(STORAGE_PREF, true);
 Services.prefs.setBoolPref(CACHES_ON_HTTP_PREF, true);
+DevToolsUtils.testing = true;
 registerCleanupFunction(() => {
+  DevToolsUtils.testing = false;
   gToolbox = gPanelWindow = gWindow = gUI = null;
   Services.prefs.clearUserPref(STORAGE_PREF);
   Services.prefs.clearUserPref(SPLIT_CONSOLE_PREF);
   Services.prefs.clearUserPref(DUMPEMIT_PREF);
   Services.prefs.clearUserPref(DEBUGGERLOG_PREF);
   Services.prefs.clearUserPref(CACHES_ON_HTTP_PREF);
 });
 
+registerCleanupFunction(function* cleanup() {
+  let target = TargetFactory.forTab(gBrowser.selectedTab);
+  yield gDevTools.closeToolbox(target);
+
+  while (gBrowser.tabs.length > 1) {
+    gBrowser.removeCurrentTab();
+  }
+});
+
+/**
+ * Add a new test tab in the browser and load the given url.
+ *
+ * @param {String} url The url to be loaded in the new tab
+ *
+ * @return a promise that resolves to the content window when the url is loaded
+ */
+function addTab(url) {
+  info("Adding a new tab with URL: '" + url + "'");
+  let def = promise.defer();
+
+  // Bug 921935 should bring waitForFocus() support to e10s, which would
+  // probably cover the case of the test losing focus when the page is loading.
+  // For now, we just make sure the window is focused.
+  window.focus();
+
+  let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
+  let linkedBrowser = tab.linkedBrowser;
+
+  linkedBrowser.addEventListener("load", function onload(event) {
+    if (event.originalTarget.location.href != url) {
+      return;
+    }
+    linkedBrowser.removeEventListener("load", onload, true);
+    info("URL '" + url + "' loading complete");
+    def.resolve(tab.linkedBrowser.contentWindow);
+  }, true);
+
+  return def.promise;
+}
+
 /**
  * This generator function opens the given url in a new tab, then sets up the
  * page by waiting for all cookies, indexedDB items etc. to be created; Then
  * opens the storage inspector and waits for the storage tree and table to be
  * populated.
  *
  * @param url {String} The url to be opened in the new tab
  *
  * @return {Promise} A promise that resolves after storage inspector is ready
  */
 function* openTabAndSetupStorage(url) {
-  let tab = yield addTab(url);
-  let content = tab.linkedBrowser.contentWindow;
+  let content = yield addTab(url);
 
   gWindow = content.wrappedJSObject;
 
   // Setup the async storages in main window and for all its iframes
   yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
     /**
      * Get all windows including frames recursively.
      *
@@ -760,16 +802,64 @@ function getCurrentEditorValue() {
  */
 function PressKeyXTimes(key, x, modifiers = {}) {
   for (let i = 0; i < x; i++) {
     EventUtils.synthesizeKey(key, modifiers);
   }
 }
 
 /**
+ * Wait for a context menu popup to open.
+ *
+ * @param nsIDOMElement popup
+ *        The XUL popup you expect to open.
+ * @param nsIDOMElement button
+ *        The button/element that receives the contextmenu event. This is
+ *        expected to open the popup.
+ * @param function onShown
+ *        Function to invoke on popupshown event.
+ * @param function onHidden
+ *        Function to invoke on popuphidden event.
+ * @return object
+ *         A Promise object that is resolved after the popuphidden event
+ *         callback is invoked.
+ */
+function waitForContextMenu(popup, button, onShown, onHidden) {
+  let deferred = promise.defer();
+
+  function onPopupShown() {
+    info("onPopupShown");
+    popup.removeEventListener("popupshown", onPopupShown);
+
+    onShown && onShown();
+
+    // Use executeSoon() to get out of the popupshown event.
+    popup.addEventListener("popuphidden", onPopupHidden);
+    executeSoon(() => popup.hidePopup());
+  }
+  function onPopupHidden() {
+    info("onPopupHidden");
+    popup.removeEventListener("popuphidden", onPopupHidden);
+
+    onHidden && onHidden();
+
+    deferred.resolve(popup);
+  }
+
+  popup.addEventListener("popupshown", onPopupShown);
+
+  info("wait for the context menu to open");
+  button.scrollIntoView();
+  let eventDetails = {type: "contextmenu", button: 2};
+  EventUtils.synthesizeMouse(button, 2, 2, eventDetails,
+                             button.ownerDocument.defaultView);
+  return deferred.promise;
+}
+
+/**
  * Verify the storage inspector state: check that given type/host exists
  * in the tree, and that the table contains rows with specified names.
  *
  * @param {Array} state Array of state specifications. For example,
  *        [["cookies", "example.com"], ["c1", "c2"]] means to select the
  *        "example.com" host in cookies and then verify there are "c1" and "c2"
  *        cookies (and no other ones).
  */
--- a/devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
+++ b/devtools/client/webconsole/test/browser_bug_638949_copy_link_location.js
@@ -42,16 +42,18 @@ add_task(function* () {
   output.focus();
   let message = [...result.matched][0];
 
   goUpdateCommand(COMMAND_NAME);
   ok(!isEnabled(), COMMAND_NAME + " is disabled");
 
   // Test that the "Copy Link Location" menu item is hidden for non-network
   // messages.
+  message.scrollIntoView();
+
   yield waitForContextMenu(menu, message, () => {
     let isHidden = menu.querySelector(CONTEXT_MENU_ID).hidden;
     ok(isHidden, CONTEXT_MENU_ID + " is hidden");
   });
 
   hud.jsterm.clearOutput();
   // Reloading will produce network logging
   content.location.reload();
@@ -88,16 +90,18 @@ add_task(function* () {
   }, () => {
     deferred.reject(null);
   });
 
   yield deferred.promise;
 
   // Test that the "Copy Link Location" menu item is visible for network-related
   // messages.
+  message.scrollIntoView();
+
   yield waitForContextMenu(menu, message, () => {
     let isVisible = !menu.querySelector(CONTEXT_MENU_ID).hidden;
     ok(isVisible, CONTEXT_MENU_ID + " is visible");
   });
 
   // Return whether "Copy Link Location" command is enabled or not.
   function isEnabled() {
     let controller = top.document.commandDispatcher
--- a/devtools/client/webconsole/test/browser_console_copy_entire_message_context_menu.js
+++ b/devtools/client/webconsole/test/browser_console_copy_entire_message_context_menu.js
@@ -37,16 +37,17 @@ function test() {
         text: "bug 1100562",
         category: CATEGORY_WEBDEV,
         severity: SEVERITY_LOG,
       }]
     });
 
     outputNode.focus();
     let message = [...results.matched][0];
+    message.scrollIntoView();
 
     yield waitForContextMenu(contextMenu, message, copyFromPopup,
                              testContextMenuCopy);
 
     function copyFromPopup() {
       let copyItem = contextMenu.querySelector("#cMenu_copy");
       copyItem.doCommand();
 
--- a/devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_764572_output_open_url.js
@@ -61,16 +61,17 @@ function onConsoleMessage(results) {
   // Check if the command is disabled non-network messages.
   goUpdateCommand(COMMAND_NAME);
   let controller = top.document.commandDispatcher
                    .getControllerForCommand(COMMAND_NAME);
 
   let isDisabled = !controller || !controller.isCommandEnabled(COMMAND_NAME);
   ok(isDisabled, COMMAND_NAME + " should be disabled.");
 
+  outputNode.selectedItem.scrollIntoView();
   return waitForContextMenu(contextMenu, outputNode.selectedItem, () => {
     let isHidden = contextMenu.querySelector(CONTEXT_MENU_ID).hidden;
     ok(isHidden, CONTEXT_MENU_ID + " should be hidden.");
   });
 }
 
 function testOnNetActivity() {
   HUD.jsterm.clearOutput();
@@ -125,16 +126,17 @@ function onNetworkMessage(results) {
   return deferred.promise;
 }
 
 function testOnNetActivityContextMenu(msg) {
   let deferred = promise.defer();
 
   outputNode.focus();
   HUD.ui.output.selectMessage(msg);
+  msg.scrollIntoView();
 
   info("net activity context menu");
 
   waitForContextMenu(contextMenu, msg, () => {
     let isShown = !contextMenu.querySelector(CONTEXT_MENU_ID).hidden;
     ok(isShown, CONTEXT_MENU_ID + " should be shown.");
   }).then(deferred.resolve);
 
--- a/devtools/client/webconsole/test/head.js
+++ b/devtools/client/webconsole/test/head.js
@@ -237,16 +237,63 @@ var closeConsole = Task.async(function* 
   let target = TargetFactory.forTab(tab || gBrowser.selectedTab);
   let toolbox = gDevTools.getToolbox(target);
   if (toolbox) {
     yield toolbox.destroy();
   }
 });
 
 /**
+ * Wait for a context menu popup to open.
+ *
+ * @param nsIDOMElement popup
+ *        The XUL popup you expect to open.
+ * @param nsIDOMElement button
+ *        The button/element that receives the contextmenu event. This is
+ *        expected to open the popup.
+ * @param function onShown
+ *        Function to invoke on popupshown event.
+ * @param function onHidden
+ *        Function to invoke on popuphidden event.
+ * @return object
+ *         A Promise object that is resolved after the popuphidden event
+ *         callback is invoked.
+ */
+function waitForContextMenu(popup, button, onShown, onHidden) {
+  let deferred = promise.defer();
+
+  function onPopupShown() {
+    info("onPopupShown");
+    popup.removeEventListener("popupshown", onPopupShown);
+
+    onShown && onShown();
+
+    // Use executeSoon() to get out of the popupshown event.
+    popup.addEventListener("popuphidden", onPopupHidden);
+    executeSoon(() => popup.hidePopup());
+  }
+  function onPopupHidden() {
+    info("onPopupHidden");
+    popup.removeEventListener("popuphidden", onPopupHidden);
+
+    onHidden && onHidden();
+
+    deferred.resolve(popup);
+  }
+
+  popup.addEventListener("popupshown", onPopupShown);
+
+  info("wait for the context menu to open");
+  let eventDetails = {type: "contextmenu", button: 2};
+  EventUtils.synthesizeMouse(button, 2, 2, eventDetails,
+                             button.ownerDocument.defaultView);
+  return deferred.promise;
+}
+
+/**
  * Listen for a new tab to open and return a promise that resolves when one
  * does and completes the load event.
  * @return a promise that resolves to the tab object
  */
 var waitForTab = Task.async(function*() {
   info("Waiting for a tab to open");
   yield once(gBrowser.tabContainer, "TabOpen");
   let tab = gBrowser.selectedTab;