Bug 1093947: Make JS callers of ios.newChannel call ios.newChannel2 in uriloader/ (r=smaug,bz)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Thu, 08 Jan 2015 19:00:59 -0800
changeset 222881 70bc10b845afeee83d9fa20464b0f365c9e08094
parent 222880 8d838801a16de5e235bfe42235d451d02f5866fc
child 222882 e285881c00c50dd5b3cb2e8e8aff115d616f9c47
push id10731
push usercbook@mozilla.com
push dateFri, 09 Jan 2015 14:51:37 +0000
treeherderfx-team@e6756043d930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, bz
bugs1093947
milestone37.0a1
Bug 1093947: Make JS callers of ios.newChannel call ios.newChannel2 in uriloader/ (r=smaug,bz)
uriloader/exthandler/nsWebHandlerApp.js
uriloader/exthandler/tests/unit_ipc/test_encoding.js
--- a/uriloader/exthandler/nsWebHandlerApp.js
+++ b/uriloader/exthandler/nsWebHandlerApp.js
@@ -1,20 +1,22 @@
 /* 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/. */
 
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 ////////////////////////////////////////////////////////////////////////////////
 //// Constants
 
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cc = Components.classes;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsWebHandler class
 
 function nsWebHandlerApp() {}
 
 nsWebHandlerApp.prototype = {
   //////////////////////////////////////////////////////////////////////////////
@@ -75,17 +77,22 @@ nsWebHandlerApp.prototype = {
     var ioService = Cc["@mozilla.org/network/io-service;1"].
                     getService(Ci.nsIIOService);
     var uriToSend = ioService.newURI(uriSpecToSend, null, null);
     
     // if we have a window context, use the URI loader to load there
     if (aWindowContext) {
 
       // create a channel from this URI
-      var channel = ioService.newChannelFromURI(uriToSend);
+      var channel = ioService.newChannelFromURI2(uriToSend,
+                                                 null,      // aLoadingNode
+                                                 Services.scriptSecurityManager.getSystemPrincipal(),
+                                                 null,      // aTriggeringPrincipal
+                                                 Ci.nsILoadInfo.SEC_NORMAL,
+                                                 Ci.nsIContentPolicy.TYPE_OTHER);
       channel.loadFlags = Ci.nsIChannel.LOAD_DOCUMENT_URI;
 
       // load the channel
       var uriLoader = Cc["@mozilla.org/uriloader;1"].
                       getService(Ci.nsIURILoader);
       // XXX ideally, whether to pass the IS_CONTENT_PREFERRED flag should be
       // passed in from above.  Practically, the flag is probably a reasonable
       // default since browsers don't care much, and link click is likely to be
--- a/uriloader/exthandler/tests/unit_ipc/test_encoding.js
+++ b/uriloader/exthandler/tests/unit_ipc/test_encoding.js
@@ -143,19 +143,24 @@ function testFinisher(endFunc) {
     runNextTest();
   }
 }
 
 function runChildTestSet(set)
 {
   DownloadListener.onFinished = testFinisher(set[2]);
   sendCommand('\
-  let uri = ioservice.newURI("http://localhost:4444' + set[0] + '", null, null);\
-  let channel = ioservice.newChannelFromURI(uri);                              \
-  uriloader.openURI(channel, Ci.nsIURILoader.IS_CONTENT_PREFERRED, new WindowContext()); \
+  let uri = ioservice.newURI("http://localhost:4444' + set[0] + '", null, null);                  \
+  let channel = ioservice.newChannelFromURI2(uri,                                                 \
+                                             null, /* aLoadingNode */                             \
+                                             Services.scriptSecurityManager.getSystemPrincipal(), \
+                                             null, /* aTriggeringPrincipal */                     \
+                                             Ci.nsILoadInfo.SEC_NORMAL,                           \
+                                             Ci.nsIContentPolicy.TYPE_OTHER);                     \
+  uriloader.openURI(channel, Ci.nsIURILoader.IS_CONTENT_PREFERRED, new WindowContext());          \
   ');
 }
 
 var httpserver = null;
 let currentTest = 0;
 function runNextTest()
 {
   if (currentTest == tests.length) {