From e3fa4c14bf2ece8a4805e9b05bb198699d7b2bdf Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Mon, 11 Jan 2016 12:16:15 -0800 Subject: [PATCH] Bug 1232782 - Convert JS callsites to use open2 within intl/ (r=sicking) --- intl/uconv/tests/unit/test_bug317216.js | 14 +++----------- intl/uconv/tests/unit/test_bug340714.js | 16 +++------------- intl/uconv/tests/unit/test_bug563618.js | 17 +++-------------- intl/uconv/tests/unit/test_utf8_illegals.js | 17 +++-------------- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/intl/uconv/tests/unit/test_bug317216.js b/intl/uconv/tests/unit/test_bug317216.js index 52a27f8bfe0f..c8aa50cbb752 100644 --- a/intl/uconv/tests/unit/test_bug317216.js +++ b/intl/uconv/tests/unit/test_bug317216.js @@ -12,7 +12,7 @@ var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const test = [ // 0: Valid surrogate pair @@ -75,16 +75,8 @@ const ios = new IOService(); function testCase(testText, expectedText, bufferLength, charset) { var dataURI = "data:text/plain;charset=" + charset + "," + testText; - - var channel = ios.newChannel2(dataURI, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var testInputStream = channel.open(); + var channel = NetUtil.newChannel({uri: dataURI, loadUsingSystemPrincipal: true}); + var testInputStream = channel.open2(); var testConverter = new ConverterInputStream(testInputStream, charset, bufferLength, diff --git a/intl/uconv/tests/unit/test_bug340714.js b/intl/uconv/tests/unit/test_bug340714.js index 1f2fae9da182..5c6b985ccd71 100644 --- a/intl/uconv/tests/unit/test_bug340714.js +++ b/intl/uconv/tests/unit/test_bug340714.js @@ -14,7 +14,7 @@ var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const beBOM="%FE%FF"; const leBOM="%FF%FE"; @@ -40,23 +40,13 @@ function testCase(withBOM, charset, charsetDec, decoder, bufferLength) var dataURI = "data:text/plain;charset=" + charsetDec + "," + makeText(withBOM, charset); - var IOService = Components.Constructor("@mozilla.org/network/io-service;1", - "nsIIOService"); var ConverterInputStream = Components.Constructor("@mozilla.org/intl/converter-input-stream;1", "nsIConverterInputStream", "init"); - var ios = new IOService(); - var channel = ios.newChannel2(dataURI, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var testInputStream = channel.open(); + var channel = NetUtil.newChannel({uri: dataURI, loadUsingSystemPrincipal: true}); + var testInputStream = channel.open2(); var testConverter = new ConverterInputStream(testInputStream, decoder, bufferLength, diff --git a/intl/uconv/tests/unit/test_bug563618.js b/intl/uconv/tests/unit/test_bug563618.js index 8bc52165e3db..a3052a9cb7a5 100644 --- a/intl/uconv/tests/unit/test_bug563618.js +++ b/intl/uconv/tests/unit/test_bug563618.js @@ -7,7 +7,7 @@ var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const test = [ // 0: 0x8e followed by hi byte, not valid JIS X 0201 @@ -27,27 +27,16 @@ const test = [ // expected: one replacement character, invalid byte not eaten "abcdefghijklmnopqrstuvwxyz12test03\uFFFDfoobar"]]; -const IOService = Components.Constructor("@mozilla.org/network/io-service;1", - "nsIIOService"); const ConverterInputStream = Components.Constructor("@mozilla.org/intl/converter-input-stream;1", "nsIConverterInputStream", "init"); -const ios = new IOService(); function testCase(testText, expectedText, bufferLength, charset) { var dataURI = "data:text/plain;charset=" + charset + "," + testText; - - var channel = ios.newChannel2(dataURI, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var testInputStream = channel.open(); + var channel = NetUtil.newChannel({uri: dataURI, loadUsingSystemPrincipal: true}); + var testInputStream = channel.open2(); var testConverter = new ConverterInputStream(testInputStream, charset, bufferLength, diff --git a/intl/uconv/tests/unit/test_utf8_illegals.js b/intl/uconv/tests/unit/test_utf8_illegals.js index 9a7d7a588933..9c9c19586f79 100644 --- a/intl/uconv/tests/unit/test_utf8_illegals.js +++ b/intl/uconv/tests/unit/test_utf8_illegals.js @@ -4,7 +4,7 @@ var Cc = Components.Constructor; var Ci = Components.interfaces; var Cu = Components.utils; -Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/NetUtil.jsm"); const tests = [ { inStrings: ["%80", // Illegal or incomplete sequences @@ -98,23 +98,12 @@ function testCaseInputStream(inStr, expected) var dataURI = "data:text/plain; charset=UTF-8,ABC" + inStr + "XYZ" dump(inStr + "==>"); - var IOService = Cc("@mozilla.org/network/io-service;1", - "nsIIOService"); var ConverterInputStream = Cc("@mozilla.org/intl/converter-input-stream;1", "nsIConverterInputStream", "init"); - - var ios = new IOService(); - var channel = ios.newChannel2(dataURI, - "", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var testInputStream = channel.open(); + var channel = NetUtil.newChannel({uri: dataURI, loadUsingSystemPrincipal: true}); + var testInputStream = channel.open2(); var testConverter = new ConverterInputStream(testInputStream, "UTF-8", 16,