Bug 1409449 - Update test for bug 1409449. r=:ckerschb a=gchang
authorDragana Damjanovic <dd.mozilla@gmail.com>
Mon, 08 Jan 2018 16:58:18 +0200
changeset 443149 6130add50170cca8fccd472ada196c93f1ef8ecd
parent 443148 f75756056fc4274c57a074a6f1e6430e809a0d0b
child 443150 397ac8ff4faafdc6704121dd5d6f71209f330ff0
push id8499
push userarchaeopteryx@coole-files.de
push dateMon, 08 Jan 2018 14:59:48 +0000
treeherdermozilla-beta@397ac8ff4faa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgchang
bugs1409449
milestone58.0
Bug 1409449 - Update test for bug 1409449. r=:ckerschb a=gchang
browser/components/originattributes/test/browser/head.js
dom/browser-element/mochitest/browserElement_Auth.js
netwerk/test/unit/test_auth_proxy.js
testing/marionette/harness/marionette_harness/tests/unit/test_modal_dialogs.py
toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
toolkit/components/passwordmgr/test/pwmgr_common.js
toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
--- a/browser/components/originattributes/test/browser/head.js
+++ b/browser/components/originattributes/test/browser/head.js
@@ -210,16 +210,17 @@ this.IsolationTestTools = {
 
       // Before run this task, reset the preferences first.
       await SpecialPowers.flushPrefEnv();
 
       // Make sure preferences are set properly.
       await SpecialPowers.pushPrefEnv({"set": aPref});
 
       await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 1]]});
+      await SpecialPowers.pushPrefEnv({"set": [["network.auth.non-web-content-triggered-resources-http-auth-allow", true]]});
 
       await aTask(aMode);
     });
   },
 
   /**
    * Add a tab with the given tab setting, this will open different types of
    * tabs according to the given test mode. A tab setting means a isolation
--- a/dom/browser-element/mochitest/browserElement_Auth.js
+++ b/dom/browser-element/mochitest/browserElement_Auth.js
@@ -232,9 +232,13 @@ function testFinish() {
 
   var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
     .getService(SpecialPowers.Ci.nsILoginManager);
   pwmgr.removeAllLogins();
 
   SimpleTest.finish();
 }
 
-addEventListener('testready', runTest);
+addEventListener('testready', function() {
+  // Enable http authentiication.
+  SpecialPowers.pushPrefEnv({'set': [['network.auth.non-web-content-triggered-resources-http-auth-allow', true]]}, runTest);
+});
+
--- a/netwerk/test/unit/test_auth_proxy.js
+++ b/netwerk/test/unit/test_auth_proxy.js
@@ -7,16 +7,17 @@
  * This tests the automatic login to the proxy with password,
  * if the password is stored and the browser is restarted.
  *
  * <copied from="test_authentication.js"/>
  */
 
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://gre/modules/NetUtil.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 
 const FLAG_RETURN_FALSE   = 1 << 0;
 const FLAG_WRONG_PASSWORD = 1 << 1;
 const FLAG_PREVIOUS_FAILED = 1 << 2;
 
 function AuthPrompt2(proxyFlags, hostFlags) {
   this.proxyCred.flags = proxyFlags;
   this.hostCred.flags = hostFlags;
@@ -222,25 +223,33 @@ var current_test = 0;
 var httpserv = null;
 
 function run_test() {
   httpserv = new HttpServer();
   httpserv.registerPathHandler("/", proxyAuthHandler);
   httpserv.identity.add("http", "somesite", 80);
   httpserv.start(-1);
 
-  const prefs = Cc["@mozilla.org/preferences-service;1"]
-                         .getService(Ci.nsIPrefBranch);
-  prefs.setCharPref("network.proxy.http", "localhost");
-  prefs.setIntPref("network.proxy.http_port", httpserv.identity.primaryPort);
-  prefs.setCharPref("network.proxy.no_proxies_on", "");
-  prefs.setIntPref("network.proxy.type", 1);
+  Services.prefs.setCharPref("network.proxy.http", "localhost");
+  Services.prefs.setIntPref("network.proxy.http_port", httpserv.identity.primaryPort);
+  Services.prefs.setCharPref("network.proxy.no_proxies_on", "");
+  Services.prefs.setIntPref("network.proxy.type", 1);
 
   // Turn off the authentication dialog blocking for this test.
-  prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
+  Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
+  Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
+
+  do_register_cleanup(() => {
+    Services.prefs.clearUserPref("network.proxy.http");
+    Services.prefs.clearUserPref("network.proxy.http_port");
+    Services.prefs.clearUserPref("network.proxy.no_proxies_on");
+    Services.prefs.clearUserPref("network.proxy.type");
+    Services.prefs.clearUserPref("network.auth.subresource-http-auth-allow");
+    Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+  });
 
   tests[current_test]();
 }
 
 function test_proxy_returnfalse() {
   dump("\ntest: proxy returnfalse\n");
   var chan = makeChan();
   chan.notificationCallbacks = new Requestor(FLAG_RETURN_FALSE, 0);
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_modal_dialogs.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_modal_dialogs.py
@@ -204,20 +204,23 @@ class TestTabModalAlerts(BaseAlertTestCa
         with self.assertRaises(errors.UnexpectedAlertOpen):
             self.marionette.find_element(By.ID, "click-result")
 
 
 class TestModalAlerts(BaseAlertTestCase):
 
     def setUp(self):
         super(TestModalAlerts, self).setUp()
+        self.marionette.set_pref("network.auth.non-web-content-triggered-resources-http-auth-allow",
+                                 True)
 
     def tearDown(self):
         # Ensure to close a possible remaining modal dialog
         self.close_all_windows()
+        self.marionette.clear_pref("network.auth.non-web-content-triggered-resources-http-auth-allow")
 
         super(TestModalAlerts, self).tearDown()
 
     def test_http_auth_dismiss(self):
         self.marionette.navigate(self.marionette.absolute_url("http_auth"))
         self.wait_for_alert(timeout=self.marionette.timeout.page_load)
 
         alert = self.marionette.switch_to_alert()
--- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
@@ -1,12 +1,17 @@
 "use strict";
 
 const XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest");
 
+Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
+do_register_cleanup(() => {
+  Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+});
+
 const proxy = createHttpServer();
 
 // accept proxy connections for mozilla.org
 proxy.identity.add("http", "mozilla.org", 80);
 
 proxy.registerPathHandler("/", (request, response) => {
   if (request.hasHeader("Proxy-Authorization")) {
     response.setStatusLine(request.httpVersion, 200, "OK");
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -439,17 +439,18 @@ if (this.addMessageListener) {
   var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
   globalMM.addMessageListener("RemoteLogins:onFormSubmit", function onFormSubmit(message) {
     sendAsyncMessage("formSubmissionProcessed", message.data, message.objects);
   });
 } else {
   // Code to only run in the mochitest pages (not in the chrome script).
   SpecialPowers.pushPrefEnv({"set": [["signon.rememberSignons", true],
                                      ["signon.autofillForms.http", true],
-                                     ["security.insecure_field_warning.contextual.enabled", false]]
+                                     ["security.insecure_field_warning.contextual.enabled", false],
+                                     ["network.auth.non-web-content-triggered-resources-http-auth-allow", true]]
                            });
   SimpleTest.registerCleanupFunction(() => {
     SpecialPowers.popPrefEnv();
     runInParent(function cleanupParent() {
       const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
       Cu.import("resource://gre/modules/Services.jsm");
       Cu.import("resource://gre/modules/LoginManagerParent.jsm");
 
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
@@ -1,12 +1,15 @@
 // ----------------------------------------------------------------------------
 // Test whether an install succeeds when authentication is required
 // This verifies bug 312473
 function test() {
+  // Turn off the authentication dialog blocking for this test.
+  Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
+
   Harness.authenticationCallback = get_auth_info;
   Harness.downloadFailedCallback = download_failed;
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
   var prefs = Cc["@mozilla.org/preferences-service;1"].
                         getService(Ci.nsIPrefBranch);
@@ -37,11 +40,13 @@ function install_ended(install, addon) {
 function finish_test(count) {
   is(count, 1, "1 Add-on should have been successfully installed");
   var authMgr = Components.classes["@mozilla.org/network/http-auth-manager;1"]
                           .getService(Components.interfaces.nsIHttpAuthManager);
   authMgr.clearAll();
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
+  Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+
   gBrowser.removeCurrentTab();
   Harness.finish();
 }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth2.js
@@ -1,13 +1,16 @@
 // ----------------------------------------------------------------------------
 // Test whether an install fails when authentication is required and bad
 // credentials are given
 // This verifies bug 312473
 function test() {
+  // Turn off the authentication dialog blocking for this test.
+  Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
+
   requestLongerTimeout(2);
   Harness.authenticationCallback = get_auth_info;
   Harness.downloadFailedCallback = download_failed;
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
   var pm = Services.perms;
@@ -36,11 +39,13 @@ function install_ended(install, addon) {
 function finish_test(count) {
   is(count, 0, "No add-ons should have been installed");
   var authMgr = Components.classes["@mozilla.org/network/http-auth-manager;1"]
                           .getService(Components.interfaces.nsIHttpAuthManager);
   authMgr.clearAll();
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
+  Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+
   gBrowser.removeCurrentTab();
   Harness.finish();
 }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js
@@ -1,14 +1,16 @@
 // ----------------------------------------------------------------------------
 // Test whether an install fails when authentication is required and it is
 // canceled
 // This verifies bug 312473
+function test() {
+  // Turn off the authentication dialog blocking for this test.
+  Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
 
-function test() {
   Harness.authenticationCallback = get_auth_info;
   Harness.downloadFailedCallback = download_failed;
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
@@ -36,11 +38,13 @@ function install_ended(install, addon) {
 function finish_test(count) {
   is(count, 0, "No add-ons should have been installed");
   var authMgr = Components.classes["@mozilla.org/network/http-auth-manager;1"]
                           .getService(Components.interfaces.nsIHttpAuthManager);
   authMgr.clearAll();
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
+  Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+
   gBrowser.removeCurrentTab();
   Harness.finish();
 }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth4.js
@@ -1,12 +1,15 @@
 // Test whether a request for auth for an XPI switches to the appropriate tab
 var gNewTab;
 
 function test() {
+  // Turn off the authentication dialog blocking for this test.
+  Services.prefs.setBoolPref("network.auth.non-web-content-triggered-resources-http-auth-allow", true);
+
   Harness.authenticationCallback = get_auth_info;
   Harness.downloadFailedCallback = download_failed;
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
@@ -34,11 +37,13 @@ function install_ended(install, addon) {
 function finish_test(count) {
   is(count, 1, "1 Add-on should have been successfully installed");
   var authMgr = Components.classes["@mozilla.org/network/http-auth-manager;1"]
                           .getService(Components.interfaces.nsIHttpAuthManager);
   authMgr.clearAll();
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
+  Services.prefs.clearUserPref("network.auth.non-web-content-triggered-resources-http-auth-allow");
+
   gBrowser.removeTab(gNewTab);
   Harness.finish();
 }