From a25cd31af006e0b8f2fdecdd955a1f316ea57193 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Tue, 12 Jan 2016 13:45:03 -0800 Subject: [PATCH] Bug 1225357 - Convert toolkit tests to use asyncOpen2 (r=sicking) --- .../test/unit/test_mediasniffer.js | 19 +++++++----------- .../test/unit/test_mediasniffer_ext.js | 20 +++++++------------ .../passwordmgr/test/test_prompt.html | 10 +++++----- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js index 5c538859f16a..b26d554a8e6a 100644 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js +++ b/toolkit/components/mediasniffer/test/unit/test_mediasniffer.js @@ -6,7 +6,7 @@ var Ci = Components.interfaces; var Cu = Components.utils; Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const PATH = "/file.meh"; var httpserver = new HttpServer(); @@ -69,18 +69,13 @@ var listener = { function setupChannel(url, flags) { - var ios = Components.classes["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); let uri = "http://localhost:" + httpserver.identity.primaryPort + url; - var chan = ios.newChannel2(uri, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_MEDIA); + var chan = NetUtil.newChannel({ + uri: uri, + loadUsingSystemPrincipal: true, + contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA + }); chan.loadFlags |= flags; var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel); return httpChan; @@ -96,7 +91,7 @@ function runNext() { response.setHeader("Content-Type", tests[testRan].contentType, false); response.bodyOutputStream.write(data, data.length); }); - channel.asyncOpen(listener, channel, null); + channel.asyncOpen2(listener); } function run_test() { diff --git a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js b/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js index 2f2693d449cd..a94f4b89eadc 100644 --- a/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js +++ b/toolkit/components/mediasniffer/test/unit/test_mediasniffer_ext.js @@ -12,7 +12,7 @@ var BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1", "setOutputStream"); Cu.import("resource://testing-common/httpd.js"); -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); var httpserver = new HttpServer(); @@ -69,17 +69,11 @@ var listener = { }; function setupChannel(url) { - var ios = Components.classes["@mozilla.org/network/io-service;1"]. - getService(Ci.nsIIOService); - var chan = ios.newChannel2("http://localhost:" + - httpserver.identity.primaryPort + url, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_MEDIA); + var chan = NetUtil.newChannel({ + uri: "http://localhost:" + httpserver.identity.primaryPort + url, + loadUsingSystemPrincipal: true, + contentPolicyType: Ci.nsIContentPolicy.TYPE_MEDIA + }); var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel); return httpChan; } @@ -90,7 +84,7 @@ function runNext() { return; } var channel = setupChannel("/"); - channel.asyncOpen(listener, channel, null); + channel.asyncOpen2(listener); } function getFileContents(aFile) { diff --git a/toolkit/components/passwordmgr/test/test_prompt.html b/toolkit/components/passwordmgr/test/test_prompt.html index f5cf3d64ee23..f4505cc8079c 100644 --- a/toolkit/components/passwordmgr/test/test_prompt.html +++ b/toolkit/components/passwordmgr/test/test_prompt.html @@ -167,9 +167,9 @@ var resolveCallback = SpecialPowers.wrapCallbackObject({ null, // aLoadingNode systemPrincipal, null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, + Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER); - proxyChannel.asyncOpen(SpecialPowers.wrapCallbackObject(new proxyChannelListener()), null); + proxyChannel.asyncOpen2(SpecialPowers.wrapCallbackObject(new proxyChannelListener())); } }); @@ -186,7 +186,7 @@ function startup() { null, // aLoadingNode systemPrincipal, null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, + Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER); pps.asyncResolve(channel, 0, resolveCallback); } @@ -914,7 +914,7 @@ function doTests() { SpecialPowers.Services. scriptSecurityManager.getSystemPrincipal(), null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, + Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER); var channel2 = ioService.newChannel2("http://example2.com", null, @@ -923,7 +923,7 @@ function doTests() { SpecialPowers.Services. scriptSecurityManager.getSystemPrincipal(), null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, + Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, Ci.nsIContentPolicy.TYPE_OTHER); var level = Ci.nsIAuthPrompt2.LEVEL_NONE;