Bug 1087730: Make JS callers of ios.newChannel call ios.newChannel2 in extensions/ (r=mmc)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Fri, 24 Oct 2014 14:51:41 -0700
changeset 221527 cf04310e7cba4d6e96336b5d703186cb3def9de1
parent 221526 685c246ce3e0f2112fcedf21c74072f997f0668e
child 221528 24997b35fe64d2125c6193ccb134786c02e3cba8
push id28032
push userkwierso@gmail.com
push dateTue, 30 Dec 2014 01:28:14 +0000
treeherdermozilla-central@67872ce17918 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmc
bugs1087730
milestone37.0a1
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
Bug 1087730: Make JS callers of ios.newChannel call ios.newChannel2 in extensions/ (r=mmc)
extensions/cookie/test/test_app_uninstall_cookies.html
extensions/cookie/test/unit/test_cookies_persistence.js
extensions/cookie/test/unit/test_cookies_privatebrowsing.js
extensions/cookie/test/unit/test_cookies_thirdparty.js
extensions/cookie/test/unit/test_cookies_thirdparty_session.js
--- a/extensions/cookie/test/test_app_uninstall_cookies.html
+++ b/extensions/cookie/test/test_app_uninstall_cookies.html
@@ -23,16 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
 
 SimpleTest.waitForExplicitFinish();
 
 Cu.import("resource://testing-common/httpd.js");
+Cu.import("resource://gre/modules/Services.jsm");
 var httpserver = new HttpServer();
 
 var cookieSetPath = "/setcookie";
 var cookieCheckPath = "/checkcookie";
 
 var permManager = Cc["@mozilla.org/permissionmanager;1"]
                     .getService(Ci.nsIPermissionManager);
 var cookieMng = Cc["@mozilla.org/cookiemanager;1"]
@@ -89,17 +90,24 @@ function cookieCheckHandler(metadata, re
   response.setStatusLine(metadata.httpVersion, 200, "Ok");
   response.setHeader("foo-saw-cookies", cookies, false);
   response.setHeader("Content-Type", "text/plain");
   response.bodyOutputStream.write("Ok", "Ok".length);
 }
 
 function setupChannel(path) {
   var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-  var chan = ios.newChannel("http://localhost:4444" + path, "", null);
+  var chan = ios.newChannel2("http://localhost:4444" + path,
+                             "",
+                             null,
+                             null,      // aLoadingNode
+                             Services.scriptSecurityManager.getSystemPrincipal(),
+                             null,      // aTriggeringPrincipal
+                             Ci.nsILoadInfo.SEC_NORMAL,
+                             Ci.nsIContentPolicy.TYPE_OTHER);
   chan.notificationCallbacks = cookies[counter].loadContext;
   chan.QueryInterface(Ci.nsIHttpChannel);
   return chan;
 }
 
 function setCookie() {
   var channel = setupChannel(cookieSetPath);
   channel.setRequestHeader("foo-set-cookie", cookies[counter].cookieName, false);
--- a/extensions/cookie/test/unit/test_cookies_persistence.js
+++ b/extensions/cookie/test/unit/test_cookies_persistence.js
@@ -24,18 +24,32 @@ function do_run_test() {
   let profile = do_get_profile();
 
   // Create URIs and channels pointing to foo.com and bar.com.
   // We will use these to put foo.com into first and third party contexts.
   var spec1 = "http://foo.com/foo.html";
   var spec2 = "http://bar.com/bar.html";
   var uri1 = NetUtil.newURI(spec1);
   var uri2 = NetUtil.newURI(spec2);
-  var channel1 = NetUtil.newChannel(uri1);
-  var channel2 = NetUtil.newChannel(uri2);
+  var channel1 = NetUtil.newChannel2(uri1,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
+  var channel2 = NetUtil.newChannel2(uri2,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
 
   // Force the channel URI to be used when determining the originating URI of
   // the channel.
   var httpchannel1 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
   var httpchannel2 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
   httpchannel1.forceAllowThirdPartyCookie = true;
   httpchannel2.forceAllowThirdPartyCookie = true;
 
--- a/extensions/cookie/test/unit/test_cookies_privatebrowsing.js
+++ b/extensions/cookie/test/unit/test_cookies_privatebrowsing.js
@@ -14,17 +14,24 @@ function finish_test() {
   do_execute_soon(function() {
     test_generator.close();
     do_test_finished();
   });
 }
 
 function make_channel(url) {
   var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-  var chan = ios.newChannel(url, null, null).QueryInterface(Ci.nsIHttpChannel);
+  var chan = ios.newChannel2(url,
+                             null,
+                             null,
+                             null,      // aLoadingNode
+                             Services.scriptSecurityManager.getSystemPrincipal(),
+                             null,      // aTriggeringPrincipal
+                             Ci.nsILoadInfo.SEC_NORMAL,
+                             Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
   return chan;
 }
 
 function do_run_test() {
   // Set up a profile.
   let profile = do_get_profile();
 
   // Test with cookies enabled.
--- a/extensions/cookie/test/unit/test_cookies_thirdparty.js
+++ b/extensions/cookie/test/unit/test_cookies_thirdparty.js
@@ -7,18 +7,32 @@
 
 function run_test() {
   // Create URIs and channels pointing to foo.com and bar.com.
   // We will use these to put foo.com into first and third party contexts.
   var spec1 = "http://foo.com/foo.html";
   var spec2 = "http://bar.com/bar.html";
   var uri1 = NetUtil.newURI(spec1);
   var uri2 = NetUtil.newURI(spec2);
-  var channel1 = NetUtil.newChannel(uri1);
-  var channel2 = NetUtil.newChannel(uri2);
+  var channel1 = NetUtil.newChannel2(uri1,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
+  var channel2 = NetUtil.newChannel2(uri2,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
 
   // test with cookies enabled
   Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
   do_set_cookies(uri1, channel1, true, [1, 2, 3, 4]);
   Services.cookies.removeAll();
   do_set_cookies(uri1, channel2, true, [1, 2, 3, 4]);
   Services.cookies.removeAll();
 
--- a/extensions/cookie/test/unit/test_cookies_thirdparty_session.js
+++ b/extensions/cookie/test/unit/test_cookies_thirdparty_session.js
@@ -24,18 +24,32 @@ function do_run_test() {
   let profile = do_get_profile();
 
   // Create URIs and channels pointing to foo.com and bar.com.
   // We will use these to put foo.com into first and third party contexts.
   var spec1 = "http://foo.com/foo.html";
   var spec2 = "http://bar.com/bar.html";
   var uri1 = NetUtil.newURI(spec1);
   var uri2 = NetUtil.newURI(spec2);
-  var channel1 = NetUtil.newChannel(uri1);
-  var channel2 = NetUtil.newChannel(uri2);
+  var channel1 = NetUtil.newChannel2(uri1,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
+  var channel2 = NetUtil.newChannel2(uri2,
+                                     null,
+                                     null,
+                                     null,      // aLoadingNode
+                                     Services.scriptSecurityManager.getSystemPrincipal(),
+                                     null,      // aTriggeringPrincipal
+                                     Ci.nsILoadInfo.SEC_NORMAL,
+                                     Ci.nsIContentPolicy.TYPE_OTHER);
 
   // Force the channel URI to be used when determining the originating URI of
   // the channel.
   var httpchannel1 = channel1.QueryInterface(Ci.nsIHttpChannelInternal);
   var httpchannel2 = channel2.QueryInterface(Ci.nsIHttpChannelInternal);
   httpchannel1.forceAllowThirdPartyCookie = true;
   httpchannel2.forceAllowThirdPartyCookie = true;