Bug 1229889 - Convert JS callsites to use asyncOpen2 within image/ (r=sicking)
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Sun, 06 Dec 2015 20:57:08 -0800
changeset 309972 943ad6eba2c1780c06555eccbc699b158fed2fba
parent 309971 9bcd5408bd6030a22d9e51585b9d18b4671dbdf1
child 309973 af6a998f3d7e0001b092620b300e0269bcd37e56
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1229889
milestone45.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 1229889 - Convert JS callsites to use asyncOpen2 within image/ (r=sicking)
image/test/unit/async_load_tests.js
image/test/unit/test_private_channel.js
--- a/image/test/unit/async_load_tests.js
+++ b/image/test/unit/async_load_tests.js
@@ -7,17 +7,17 @@
  */
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cu = Components.utils;
 var Cr = Components.results;
 
 Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/NetUtil.jsm");
 
 var server = new HttpServer();
 server.registerDirectory("/", do_get_file(''));
 server.registerContentType("sjs", "sjs");
 server.start(-1);
 
 
 load('image_load_helpers.js');
@@ -120,26 +120,19 @@ function getChannelLoadImageStopCallback
   }
 }
 
 // Load the request a second time. This should come from the image cache, and
 // therefore would be at most risk of being served synchronously.
 function checkSecondChannelLoad()
 {
   do_test_pending();
-
-  var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);  
-  var channel = ioService.newChannelFromURI2(uri,
-                                             null,      // aLoadingNode
-                                             Services.scriptSecurityManager.getSystemPrincipal(),
-                                             null,      // aTriggeringPrincipal
-                                             Ci.nsILoadInfo.SEC_NORMAL,
-                                             Ci.nsIContentPolicy.TYPE_OTHER);
+  var channel = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
   var channellistener = new ChannelListener();
-  channel.asyncOpen(channellistener, null);
+  channel.asyncOpen2(channellistener);
 
   var listener = new ImageListener(null,
                                    getChannelLoadImageStopCallback(channellistener,
                                                                    all_done_callback));
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
   var outlistener = {};
   requests.push(gCurrentLoader.loadImageWithChannelXPCOM(channel, outer, null, outlistener));
@@ -149,26 +142,19 @@ function checkSecondChannelLoad()
 }
 
 function run_loadImageWithChannel_tests()
 {
   // To ensure we're testing what we expect to, create a new loader and cache.
   gCurrentLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoader);
 
   do_test_pending();
-
-  var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);  
-  var channel = ioService.newChannelFromURI2(uri,
-                                             null,      // aLoadingNode
-                                             Services.scriptSecurityManager.getSystemPrincipal(),
-                                             null,      // aTriggeringPrincipal
-                                             Ci.nsILoadInfo.SEC_NORMAL,
-                                             Ci.nsIContentPolicy.TYPE_OTHER);
+  var channel =  NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
   var channellistener = new ChannelListener();
-  channel.asyncOpen(channellistener, null);
+  channel.asyncOpen2(channellistener);
 
   var listener = new ImageListener(null,
                                    getChannelLoadImageStopCallback(channellistener,
                                                                    checkSecondChannelLoad));
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
   var outlistener = {};
   requests.push(gCurrentLoader.loadImageWithChannelXPCOM(channel, outer, null, outlistener));
--- a/image/test/unit/test_private_channel.js
+++ b/image/test/unit/test_private_channel.js
@@ -1,14 +1,15 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://testing-common/httpd.js");
 
 var server = new HttpServer();
 server.registerPathHandler('/image.png', imageHandler);
 server.start(-1);
 
 load('image_load_helpers.js');
 
@@ -48,26 +49,21 @@ NotificationCallbacks.prototype = {
     throw Cr.NS_ERROR_NO_INTERFACE;
   },
   originAttributes: {}
 };
 
 var gImgPath = 'http://localhost:' + server.identity.primaryPort + '/image.png';
 
 function setup_chan(path, isPrivate, callback) {
-  var uri = gIoService.newURI(gImgPath, null, null);
-  var chan = gIoService.newChannelFromURI2(uri,
-                                           null,      // aLoadingNode
-                                           Services.scriptSecurityManager.getSystemPrincipal(),
-                                           null,      // aTriggeringPrincipal
-                                           Ci.nsILoadInfo.SEC_NORMAL,
-                                           Ci.nsIContentPolicy.TYPE_OTHER);
+  var uri = NetUtil.newURI(gImgPath);
+  var chan =  NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
   chan.notificationCallbacks = new NotificationCallbacks(isPrivate);
   var channelListener = new ChannelListener();
-  chan.asyncOpen(channelListener, null);
+  chan.asyncOpen2(channelListener);
 
   var listener = new ImageListener(null, callback);
   var outlistener = {};
   var loader = isPrivate ? gPrivateLoader : gPublicLoader;
   var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                 .createScriptedObserver(listener);
   listeners.push(outer);
   requests.push(loader.loadImageWithChannelXPCOM(chan, outer, null, outlistener));