From 07093baa68af074120e271814a32e5eae8e28149 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Mon, 11 Jan 2016 12:16:35 -0800 Subject: [PATCH] Bug 1232783 - Convert JS callsites to use open2 within modules/ (r=sicking) --- modules/libjar/test/unit/test_bug589292.js | 13 +++--------- modules/libjar/test/unit/test_bug597702.js | 24 +++++----------------- modules/libjar/test/unit/test_bug637286.js | 13 +++--------- modules/libjar/test/unit/test_bug658093.js | 13 +++--------- modules/libjar/test/unit/test_not_found.js | 16 ++++++--------- 5 files changed, 20 insertions(+), 59 deletions(-) diff --git a/modules/libjar/test/unit/test_bug589292.js b/modules/libjar/test/unit/test_bug589292.js index 82fad34ea50..1fa103e3c8f 100644 --- a/modules/libjar/test/unit/test_bug589292.js +++ b/modules/libjar/test/unit/test_bug589292.js @@ -3,7 +3,7 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const path = "data/test_bug589292.zip"; @@ -11,15 +11,8 @@ function run_test() { var ios = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/foo.txt"; - var channel = ios.newChannel2(spec, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - instr = channel.open(); + var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true}); + instr = channel.open2(); var val; try { val = channel.contentDisposition; diff --git a/modules/libjar/test/unit/test_bug597702.js b/modules/libjar/test/unit/test_bug597702.js index e7dfd450336..3f32a89234a 100644 --- a/modules/libjar/test/unit/test_bug597702.js +++ b/modules/libjar/test/unit/test_bug597702.js @@ -5,7 +5,7 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); // Check that reading non existant inner jars results in the right error @@ -16,31 +16,17 @@ function run_test() { var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/"; var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello"; var badSpec = "jar:" + outerJarBase + "jar_that_isnt_in_the.jar!/hello"; - var goodChannel = ios.newChannel2(goodSpec, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var badChannel = ios.newChannel2(badSpec, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true}); + var badChannel = NetUtil.newChannel({uri: badSpec, loadUsingSystemPrincipal: true}); try { - instr = goodChannel.open(); + instr = goodChannel.open2(); } catch (e) { do_throw("Failed to open file in inner jar"); } try { - instr = badChannel.open(); + instr = badChannel.open2(); do_throw("Failed to report that file doesn't exist"); } catch (e) { do_check_true(e.name == "NS_ERROR_FILE_NOT_FOUND"); diff --git a/modules/libjar/test/unit/test_bug637286.js b/modules/libjar/test/unit/test_bug637286.js index 40083d63c86..d7609f78f11 100644 --- a/modules/libjar/test/unit/test_bug637286.js +++ b/modules/libjar/test/unit/test_bug637286.js @@ -5,7 +5,7 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); // Check that the zip cache can expire entries from nested jars var ios = Cc["@mozilla.org/network/io-service;1"]. @@ -13,15 +13,8 @@ var ios = Cc["@mozilla.org/network/io-service;1"]. function open_inner_zip(base, idx) { var spec = "jar:" + base + "inner" + idx + ".zip!/foo"; - var channel = ios.newChannel2(spec, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var stream = channel.open(); + var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true}); + var stream = channel.open2(); } function run_test() { diff --git a/modules/libjar/test/unit/test_bug658093.js b/modules/libjar/test/unit/test_bug658093.js index dfb15d103a9..52cf13b1d8f 100644 --- a/modules/libjar/test/unit/test_bug658093.js +++ b/modules/libjar/test/unit/test_bug658093.js @@ -5,7 +5,7 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); // Check that we don't crash on reading a directory entry signature var ios = Cc["@mozilla.org/network/io-service;1"]. @@ -14,17 +14,10 @@ var ios = Cc["@mozilla.org/network/io-service;1"]. function run_test() { var file = do_get_file("data/test_bug658093.zip"); var spec = "jar:" + ios.newFileURI(file).spec + "!/0000"; - var channel = ios.newChannel2(spec, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true}); var failed = false; try { - var stream = channel.open(); + var stream = channel.open2(); } catch (e) { failed = true; } diff --git a/modules/libjar/test/unit/test_not_found.js b/modules/libjar/test/unit/test_not_found.js index 2b5f1095a02..f7944cd47f6 100644 --- a/modules/libjar/test/unit/test_not_found.js +++ b/modules/libjar/test/unit/test_not_found.js @@ -4,23 +4,19 @@ var Cc = Components.classes; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const path = "data/test_bug333423.zip"; function run_test() { var ios = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/"; - var channel = ios.newChannel2(spec + "file_that_isnt_in.archive", - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel = NetUtil.newChannel({ + uri: spec + "file_that_isnt_in.archive", + loadUsingSystemPrincipal: true + }); try { - instr = channel.open(); + instr = channel.open2(); do_throw("Failed to report that file doesn't exist") } catch (e) { do_check_true(e.name == "NS_ERROR_FILE_NOT_FOUND")