Bug 1048375 - browser_aboutHome.js intermittently causes external requests to snippets.mozilla.com. r=gavin, a=test-only
authorFlorian Quèze <florian@queze.net>
Tue, 05 Aug 2014 01:02:20 +0200
changeset 217508 781d772a1f14fdd7c40c351dc50673bb695f04ad
parent 217507 16df0245bd973fbe935bb55386a81179d3dddcfc
child 217509 cf5826029d5bee55137551b492b6120b63d31fe6
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, test-only
bugs1048375
milestone33.0a2
Bug 1048375 - browser_aboutHome.js intermittently causes external requests to snippets.mozilla.com. r=gavin, a=test-only
browser/base/content/test/general/browser_aboutHome.js
browser/base/content/test/social/browser_aboutHome_activation.js
testing/profiles/prefs_general.js
--- a/browser/base/content/test/general/browser_aboutHome.js
+++ b/browser/base/content/test/general/browser_aboutHome.js
@@ -13,17 +13,16 @@ const TEST_CONTENT_HELPER = "chrome://mo
 let gRightsVersion = Services.prefs.getIntPref("browser.rights.version");
 
 registerCleanupFunction(function() {
   // Ensure we don't pollute prefs for next tests.
   Services.prefs.clearUserPref("network.cookies.cookieBehavior");
   Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
   Services.prefs.clearUserPref("browser.rights.override");
   Services.prefs.clearUserPref("browser.rights." + gRightsVersion + ".shown");
-  Services.prefs.clearUserPref("browser.aboutHomeSnippets.updateUrl");
 });
 
 let gTests = [
 
 {
   desc: "Check that clearing cookies does not clear storage",
   setup: function ()
   {
@@ -209,17 +208,17 @@ let gTests = [
   {
     Services.prefs.setBoolPref("browser.rights.override", true);
   },
   setup: function () { },
   run: function (aSnippetsMap)
   {
     let doc = gBrowser.selectedTab.linkedBrowser.contentDocument;
     let rightsData = AboutHomeUtils.knowYourRightsData;
-    
+
     ok(!rightsData, "AboutHomeUtils.knowYourRightsData should be FALSE");
 
     let snippetsElt = doc.getElementById("snippets");
     ok(snippetsElt, "Found snippets element");
     ok(snippetsElt.getElementsByTagName("a")[0].href != "about:rights", "Snippet link should not point to about:rights.");
 
     Services.prefs.clearUserPref("browser.rights.override");
   }
@@ -379,19 +378,16 @@ function test()
   waitForExplicitFinish();
   requestLongerTimeout(2);
   ignoreAllUncaughtExceptions();
 
   Task.spawn(function () {
     for (let test of gTests) {
       info(test.desc);
 
-      // Make sure we don't try to load snippets from the network.
-      Services.prefs.setCharPref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
-
       if (test.beforeRun)
         yield test.beforeRun();
 
       // Create a tab to run the test.
       let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
 
       // Add an event handler to modify the snippets map once it's ready.
       let snippetsPromise = promiseSetupSnippetsMap(tab, test.setup);
@@ -462,17 +458,17 @@ function promiseSetupSnippetsMap(aTab, a
 function promiseBrowserAttributes(aTab)
 {
   let deferred = Promise.defer();
 
   let docElt = aTab.linkedBrowser.contentDocument.documentElement;
   let observer = new MutationObserver(function (mutations) {
     for (let mutation of mutations) {
       info("Got attribute mutation: " + mutation.attributeName +
-                                    " from " + mutation.oldValue); 
+                                    " from " + mutation.oldValue);
       // Now we just have to wait for the last attribute.
       if (mutation.attributeName == "searchEngineName") {
         info("Remove attributes observer");
         observer.disconnect();
         // Must be sure to continue after the page mutation observer.
         executeSoon(function() deferred.resolve());
         break;
       }
--- a/browser/base/content/test/social/browser_aboutHome_activation.js
+++ b/browser/base/content/test/social/browser_aboutHome_activation.js
@@ -6,21 +6,16 @@ let SocialService = Cu.import("resource:
 
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
   "resource://gre/modules/Promise.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
   "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
   "resource:///modules/AboutHome.jsm");
 
-registerCleanupFunction(function() {
-  // Ensure we don't pollute prefs for next tests.
-  Services.prefs.clearUserPref("browser.aboutHomeSnippets.updateUrl");
-});
-
 let snippet =
 '     <script>' +
 '       var manifest = {' +
 '         "name": "Demo Social Service",' +
 '         "origin": "https://example.com",' +
 '         "iconURL": "chrome://branding/content/icon16.png",' +
 '         "icon32URL": "chrome://branding/content/favicon32.png",' +
 '         "icon64URL": "chrome://branding/content/icon64.png",' +
@@ -132,19 +127,16 @@ function test()
   waitForExplicitFinish();
   requestLongerTimeout(2);
   ignoreAllUncaughtExceptions();
 
   Task.spawn(function () {
     for (let test of gTests) {
       info(test.desc);
 
-      // Make sure we don't try to load snippets from the network.
-      Services.prefs.setCharPref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
-
       // Create a tab to run the test.
       let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
 
       // Add an event handler to modify the snippets map once it's ready.
       let snippetsPromise = promiseSetupSnippetsMap(tab, test.setup);
 
       // Start loading about:home and wait for it to complete.
       yield promiseTabLoadEvent(tab, "about:home", "AboutHomeLoadSnippetsCompleted");
@@ -277,10 +269,8 @@ function waitForProviderLoad(cb) {
              sbrowser.docShellIsActive;
     }, function() {
       // executeSoon to let the browser UI observers run first
       executeSoon(cb);
     },
     "waitForProviderLoad: provider profile was not set");
   }, "social:provider-enabled", false);
 }
-
-
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -211,13 +211,16 @@ user_pref("identity.fxaccounts.settings.
 
 // Enable logging of APZ test data (see bug 961289).
 user_pref('apz.test.logging_enabled', true);
 
 // Make sure Translation won't hit the network.
 user_pref("browser.translation.bing.authURL", "http://%(server)s/browser/browser/components/translation/test/bing.sjs");
 user_pref("browser.translation.bing.translateArrayURL", "http://%(server)s/browser/browser/components/translation/test/bing.sjs");
 
+// Make sure we don't try to load snippets from the network.
+user_pref("browser.aboutHomeSnippets.updateUrl", "nonexistent://test");
+
 // Enable debug logging in the mozApps implementation.
 user_pref("dom.mozApps.debug", true);
 
 // Enable Loop
 user_pref("loop.enabled", true);