Bug 1094761 - Fix browser_contextSearchTabPosition.js to not hit the network. r=Florian a=lizzard
authorFelipe Gomes <felipc@gmail.com>
Tue, 16 Feb 2016 13:28:40 -0200
changeset 304136 0f276504c5d03ccf322b30bf90537569f9d80984
parent 304135 8df107e96c86e98b7fa9ea21395b82790f2971b0
child 304137 af713dc414ddfb052c7727bc2520654abe26fc00
push id9104
push userkwierso@gmail.com
push dateFri, 19 Feb 2016 00:00:37 +0000
treeherdermozilla-aurora@4f651e16a039 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFlorian, lizzard
bugs1094761
milestone46.0a2
Bug 1094761 - Fix browser_contextSearchTabPosition.js to not hit the network. r=Florian a=lizzard MozReview-Commit-ID: 9VrFlhmWaXv
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_contextSearchTabPosition.js
browser/components/search/test/browser.ini
browser/components/search/test/browser_contextSearchTabPosition.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -280,18 +280,16 @@ tags = mcb
 skip-if = os == 'win' || e10s # Bug 1159268 - Need a content-process safe version of synthesizeWheel
 [browser_bug1064280_changeUrlInPinnedTab.js]
 [browser_bug1070778.js]
 [browser_accesskeys.js]
 [browser_canonizeURL.js]
 skip-if = e10s # Bug 1094510 - test hits the network in e10s mode only
 [browser_clipboard.js]
 [browser_contentAreaClick.js]
-[browser_contextSearchTabPosition.js]
-skip-if = os == "mac" || e10s # bug 967013; e10s: bug 1094761 - test hits the network in e10s, causing next test to crash
 [browser_ctrlTab.js]
 [browser_datachoices_notification.js]
 skip-if = !datareporting
 [browser_devedition.js]
 [browser_devices_get_user_media.js]
 skip-if = buildapp == 'mulet' || (os == "linux" && debug) # linux: bug 976544
 [browser_devices_get_user_media_about_urls.js]
 skip-if = e10s # Bug 1071623
--- a/browser/components/search/test/browser.ini
+++ b/browser/components/search/test/browser.ini
@@ -16,16 +16,18 @@ support-files =
 [browser_426329.js]
 [browser_483086.js]
 [browser_addEngine.js]
 [browser_amazon.js]
 [browser_amazon_behavior.js]
 [browser_bing.js]
 [browser_bing_behavior.js]
 [browser_contextmenu.js]
+[browser_contextSearchTabPosition.js]
+skip-if = os == "mac" # bug 967013
 [browser_eBay.js]
 [browser_eBay_behavior.js]
 [browser_google.js]
 [browser_google_behavior.js]
 [browser_healthreport.js]
 [browser_hiddenOneOffs_cleanup.js]
 [browser_hiddenOneOffs_diacritics.js]
 [browser_oneOffHeader.js]
rename from browser/base/content/test/general/browser_contextSearchTabPosition.js
rename to browser/components/search/test/browser_contextSearchTabPosition.js
--- a/browser/base/content/test/general/browser_contextSearchTabPosition.js
+++ b/browser/components/search/test/browser_contextSearchTabPosition.js
@@ -1,30 +1,28 @@
 /* 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/. */
 
 add_task(function* test() {
+  let engine = yield promiseNewEngine("testEngine.xml");
+  let histogramKey = "other-" + engine.name + ".contextmenu";
+  let numSearchesBefore = 0;
 
-  // Will need to be changed if Google isn't the default search engine.
-  // Note: geoSpecificDefaults are disabled for mochitests, so this is the
-  // non-US en-US default.
-  let histogramKey = "google.contextmenu";
-  let numSearchesBefore = 0;
   try {
     let hs = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").snapshot();
     if (histogramKey in hs) {
       numSearchesBefore = hs[histogramKey].sum;
     }
   } catch (ex) {
     // No searches performed yet, not a problem, |numSearchesBefore| is 0.
   }
 
   let tabs = [];
-  let tabsLoadedDeferred = Promise.defer();
+  let tabsLoadedDeferred = new Deferred();
 
   function tabAdded(event) {
     let tab = event.target;
     tabs.push(tab);
 
     // We wait for the blank tab and the two context searches tabs to open.
     if (tabs.length == 3) {
       tabsLoadedDeferred.resolve();
@@ -49,8 +47,15 @@ add_task(function* test() {
   tabs.forEach(gBrowser.removeTab, gBrowser);
 
   // Make sure that the context searches are correctly recorded.
   let hs = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").snapshot();
   Assert.ok(histogramKey in hs, "The histogram must contain the correct key");
   Assert.equal(hs[histogramKey].sum, numSearchesBefore + 2,
                "The histogram must contain the correct search count");
 });
+
+function Deferred() {
+  this.promise = new Promise((resolve, reject) => {
+    this.resolve = resolve;
+    this.reject = reject;
+  });
+}