From 38480a5e01121f7a61169708985f07fefb8ed732 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Wed, 13 Jan 2016 19:35:41 -0800 Subject: [PATCH] Bug 1232786 - Convert JS tests to use open2 within devtools/ (r=sicking) --- devtools/client/sourceeditor/test/head.js | 17 +++++++---------- .../test/browser_styleeditor_filesave.js | 17 +++++------------ .../browser_styleeditor_sourcemap_watching.js | 14 +++++--------- .../apps/tests/debugger-protocol-helper.js | 15 ++++++--------- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/devtools/client/sourceeditor/test/head.js b/devtools/client/sourceeditor/test/head.js index 67f5936bb9f..677bccf6ed5 100644 --- a/devtools/client/sourceeditor/test/head.js +++ b/devtools/client/sourceeditor/test/head.js @@ -4,6 +4,8 @@ "use strict"; +Cu.import("resource://gre/modules/NetUtil.jsm"); + const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const Editor = require("devtools/client/sourceeditor/editor"); const promise = require("promise"); @@ -139,16 +141,11 @@ function read(url) { let scriptableStream = Cc["@mozilla.org/scriptableinputstream;1"] .getService(Ci.nsIScriptableInputStream); - let channel = Services.io.newChannel2( - url, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let input = channel.open(); + let channel = NetUtil.newChannel({ + uri: url, + loadUsingSystemPrincipal: true + }); + let input = channel.open2(); scriptableStream.init(input); let data = ""; diff --git a/devtools/client/styleeditor/test/browser_styleeditor_filesave.js b/devtools/client/styleeditor/test/browser_styleeditor_filesave.js index 4d03e60c8f9..2ad76f9774d 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_filesave.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_filesave.js @@ -65,18 +65,11 @@ function read(srcChromeURL) { let scriptableStream = Cc["@mozilla.org/scriptableinputstream;1"] .getService(Ci.nsIScriptableInputStream); - let channel = Services.io.newChannel2(srcChromeURL, - null, - null, - // aLoadingNode - null, - Services.scriptSecurityManager - .getSystemPrincipal(), - // aTriggeringPrincipal - null, - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let input = channel.open(); + let channel = NetUtil.newChannel({ + uri: srcChromeURL, + loadUsingSystemPrincipal: true + }); + let input = channel.open2(); scriptableStream.init(input); let data = ""; diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js index 45b6c0eb378..b68275bc3d8 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sourcemap_watching.js @@ -127,15 +127,11 @@ function read(srcChromeURL) { .getService(Ci.nsIScriptableInputStream); let principal = Services.scriptSecurityManager.getSystemPrincipal(); - let channel = Services.io.newChannel2(srcChromeURL, - null, - null, - null, - principal, - null, - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let input = channel.open(); + let channel = NetUtil.newChannel({ + uri: srcChromeURL, + loadUsingSystemPrincipal: true + }); + let input = channel.open2(); scriptableStream.init(input); let data = ""; diff --git a/devtools/shared/apps/tests/debugger-protocol-helper.js b/devtools/shared/apps/tests/debugger-protocol-helper.js index b327dc2d138..2240dd7521c 100644 --- a/devtools/shared/apps/tests/debugger-protocol-helper.js +++ b/devtools/shared/apps/tests/debugger-protocol-helper.js @@ -10,6 +10,7 @@ const { DebuggerClient } = require("devtools/shared/client/main"); const { DebuggerServer } = require("devtools/server/main"); const { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm"); const { Services } = Cu.import("resource://gre/modules/Services.jsm"); +const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm"); var gClient, gActor; @@ -83,15 +84,11 @@ function webappActorRequest(request, onResponse) { function downloadURL(url, file) { - let channel = Services.io.newChannel2(url, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let istream = channel.open(); + let channel = NetUtil.newChannel({ + uri: url, + loadUsingSystemPrincipal: true + }); + let istream = channel.open2(); let bstream = Cc["@mozilla.org/binaryinputstream;1"] .createInstance(Ci.nsIBinaryInputStream); bstream.setInputStream(istream);