From b9e76daa73d791685761d9a09837ce1567b8e25c Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Thu, 21 May 2015 19:52:03 -0700 Subject: [PATCH] Bug 1167053 - Convert NetUtil.newChannel2 callsites to use new API - update newChannel2 (r=sicking,paolo) --- addon-sdk/source/lib/sdk/net/url.js | 22 ++++-------- addon-sdk/source/lib/toolkit/loader.js | 12 +++---- .../test/general/browser_blob-channelname.js | 9 +---- .../devtools/canvasdebugger/snapshotslist.js | 12 +++---- browser/devtools/performance/modules/io.js | 11 ++---- browser/devtools/profiler/ui-recordings.js | 12 +++---- browser/devtools/scratchpad/scratchpad.js | 12 +++---- .../test/browser_scratchpad_confirm_close.js | 11 ++---- .../test/browser_scratchpad_files.js | 11 ++---- browser/devtools/shared/theme.js | 12 +++---- .../pdfjs/content/PdfStreamConverter.jsm | 13 +++---- dom/apps/AppsUtils.jsm | 12 +++---- dom/apps/OfflineCacheInstaller.jsm | 12 +++---- dom/apps/TrustedHostedAppsUtils.jsm | 28 ++++++--------- dom/apps/Webapps.jsm | 28 ++++++--------- dom/base/test/unit/test_cspreports.js | 11 ++---- dom/base/test/unit/test_thirdpartyutil.js | 36 +++---------------- dom/contacts/fallback/ContactDB.jsm | 12 +++---- dom/settings/SettingsDB.jsm | 11 ++---- .../test/unit/test_cookies_persistence.js | 18 ++-------- .../test/unit/test_cookies_thirdparty.js | 18 ++-------- .../unit/test_cookies_thirdparty_session.js | 18 ++-------- .../robocop/testResourceSubstitutions.js | 10 ++---- netwerk/test/browser/browser_NetUtil.js | 11 ++---- .../addoncompat/RemoteAddonsParent.jsm | 9 +---- .../test_cancel_download_files_removed.js | 9 +---- .../test/unit/test_download_samename.js | 9 +---- toolkit/devtools/server/actors/settings.js | 11 ++---- toolkit/devtools/webconsole/network-helper.js | 9 +---- .../extensions/internal/XPIProvider.jsm | 11 ++---- toolkit/webapps/NativeApp.jsm | 12 +++---- 31 files changed, 108 insertions(+), 324 deletions(-) diff --git a/addon-sdk/source/lib/sdk/net/url.js b/addon-sdk/source/lib/sdk/net/url.js index 8bc8e3542c0..820850d745b 100644 --- a/addon-sdk/source/lib/sdk/net/url.js +++ b/addon-sdk/source/lib/sdk/net/url.js @@ -35,14 +35,9 @@ function readURI(uri, options) { options = options || {}; let charset = options.charset || 'UTF-8'; - let channel = NetUtil.newChannel2(uri, - charset, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(uri, charset), + loadUsingSystemPrincipal: true}); let { promise, resolve, reject } = defer(); @@ -83,14 +78,9 @@ exports.readURI = readURI; function readURISync(uri, charset) { charset = typeof charset === "string" ? charset : "UTF-8"; - let channel = NetUtil.newChannel2(uri, - charset, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(uri, charset), + loadUsingSystemPrincipal: true}); let stream = channel.open(); let count = stream.available(); diff --git a/addon-sdk/source/lib/toolkit/loader.js b/addon-sdk/source/lib/toolkit/loader.js index 2aec555d93b..53f3968d32c 100644 --- a/addon-sdk/source/lib/toolkit/loader.js +++ b/addon-sdk/source/lib/toolkit/loader.js @@ -178,14 +178,10 @@ function readURI(uri) { uri = proto.resolveURI(nsURI); } - let stream = NetUtil.newChannel2(uri, - 'UTF-8', - null, - null, // aLoadingNode - systemPrincipal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER).open(); + let stream = NetUtil.newChannel({ + uri: NetUtil.newURI(uri, 'UTF-8'), + loadUsingSystemPrincipal: true} + ).open(); let count = stream.available(); let data = NetUtil.readInputStreamToString(stream, count, { charset: 'UTF-8' diff --git a/browser/base/content/test/general/browser_blob-channelname.js b/browser/base/content/test/general/browser_blob-channelname.js index bd68dd98153..d87e4a8966a 100644 --- a/browser/base/content/test/general/browser_blob-channelname.js +++ b/browser/base/content/test/general/browser_blob-channelname.js @@ -5,14 +5,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm"); function test() { var file = new File([new Blob(['test'], {type: 'text/plain'})], "test-name"); var url = URL.createObjectURL(file); - var channel = NetUtil.newChannel2(url, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true}); is(channel.contentDispositionFilename, 'test-name', "filename matches"); } diff --git a/browser/devtools/canvasdebugger/snapshotslist.js b/browser/devtools/canvasdebugger/snapshotslist.js index 95923793092..799cae2fce0 100644 --- a/browser/devtools/canvasdebugger/snapshotslist.js +++ b/browser/devtools/canvasdebugger/snapshotslist.js @@ -359,14 +359,10 @@ let SnapshotsListView = Heritage.extend(WidgetMethods, { return; } - let channel = NetUtil.newChannel2(fp.file, - null, - null, - window.document, - null, // aLoadingPrincipal - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(fp.file), + loadingNode: window.document, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}); channel.contentType = "text/plain"; NetUtil.asyncFetch(channel, (inputStream, status) => { diff --git a/browser/devtools/performance/modules/io.js b/browser/devtools/performance/modules/io.js index cd2202bebd0..cd51ad568d9 100644 --- a/browser/devtools/performance/modules/io.js +++ b/browser/devtools/performance/modules/io.js @@ -76,14 +76,9 @@ let PerformanceIO = { loadRecordingFromFile: function(file) { let deferred = promise.defer(); - let channel = NetUtil.newChannel2(file, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(file), + loadUsingSystemPrincipal: true}); channel.contentType = "text/plain"; diff --git a/browser/devtools/profiler/ui-recordings.js b/browser/devtools/profiler/ui-recordings.js index 6d1cff4bd2d..3e00d3074a0 100644 --- a/browser/devtools/profiler/ui-recordings.js +++ b/browser/devtools/profiler/ui-recordings.js @@ -326,14 +326,10 @@ function saveRecordingToFile(recordingItem, file) { function loadRecordingFromFile(file) { let deferred = promise.defer(); - let channel = NetUtil.newChannel2(file, - null, - null, - window.document, - null, // aLoadingPrincipal - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(file), + loadingNode: window.document, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}); channel.contentType = "text/plain"; NetUtil.asyncFetch(channel, (inputStream, status) => { diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 5b512ce6c65..a39cbe5b118 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -1154,14 +1154,10 @@ var Scratchpad = { importFromFile: function SP_importFromFile(aFile, aSilentError, aCallback) { // Prevent file type detection. - let channel = NetUtil.newChannel2(aFile, - null, - null, - window.document, - null, // aLoadingPrincipal - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(aFile), + loadingNode: window.document, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}); channel.contentType = "application/javascript"; this.notificationBox.removeAllNotifications(false); diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_confirm_close.js b/browser/devtools/scratchpad/test/browser_scratchpad_confirm_close.js index 4093b9a0eba..d9f48888b21 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_confirm_close.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_confirm_close.js @@ -214,14 +214,9 @@ function writeFile(file, content, callback) function readFile(file, callback) { - let channel = NetUtil.newChannel2(file, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(file), + loadUsingSystemPrincipal: true}); channel.contentType = "application/javascript"; NetUtil.asyncFetch(channel, function(inputStream, status) { diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_files.js b/browser/devtools/scratchpad/test/browser_scratchpad_files.js index 11b18c686c4..5ea5b9ccb10 100644 --- a/browser/devtools/scratchpad/test/browser_scratchpad_files.js +++ b/browser/devtools/scratchpad/test/browser_scratchpad_files.js @@ -91,14 +91,9 @@ function fileExported(aStatus) gFileContent = oldContent; - let channel = NetUtil.newChannel2(gFile, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(gFile), + loadUsingSystemPrincipal: true}); channel.contentType = "application/javascript"; // Read back the temporary file. diff --git a/browser/devtools/shared/theme.js b/browser/devtools/shared/theme.js index 411b01ba7b5..bbb2b7fa409 100644 --- a/browser/devtools/shared/theme.js +++ b/browser/devtools/shared/theme.js @@ -25,14 +25,10 @@ const cachedThemes = {}; * Returns a string of the file found at URI */ function readURI (uri) { - let stream = NetUtil.newChannel2(uri, - "UTF-8", - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER).open(); + let stream = NetUtil.newChannel({ + uri: NetUtil.newURI(uri, "UTF-8"), + loadUsingSystemPrincipal: true} + ).open(); let count = stream.available(); let data = NetUtil.readInputStreamToString(stream, count, { charset: "UTF-8" }); diff --git a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm index 9ad749460c8..0847240e1dc 100644 --- a/browser/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/browser/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -157,14 +157,11 @@ function makeContentReadable(obj, window) { } function createNewChannel(uri, node, principal) { - return NetUtil.newChannel2(uri, - null, - null, - node, // aLoadingNode - principal, // aLoadingPrincipal - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + return NetUtil.newChannel({ + uri: uri, + loadingNode: node, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}); } function asyncFetchChannel(channel, callback) { diff --git a/dom/apps/AppsUtils.jsm b/dom/apps/AppsUtils.jsm index 9ee6ea4bbb7..fd7d718e5f1 100644 --- a/dom/apps/AppsUtils.jsm +++ b/dom/apps/AppsUtils.jsm @@ -696,14 +696,10 @@ this.AppsUtils = { let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); file.initWithPath(aPath); - let channel = NetUtil.newChannel2(file, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(file), + loadUsingSystemPrincipal: true}); + channel.contentType = "application/json"; NetUtil.asyncFetch(channel, function(aStream, aResult) { diff --git a/dom/apps/OfflineCacheInstaller.jsm b/dom/apps/OfflineCacheInstaller.jsm index 12dfb98819e..7f81ffd369c 100644 --- a/dom/apps/OfflineCacheInstaller.jsm +++ b/dom/apps/OfflineCacheInstaller.jsm @@ -91,14 +91,10 @@ function storeCache(applicationCache, url, file, itemType, metadata) { function readFile(aFile, aPrincipal, aCallback) { - let channel = NetUtil.newChannel2(aFile, - null, - null, - null, // aLoadingNode - aPrincipal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: NetUtil.newURI(aFile), + loadingPrincipal: aPrincipal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}); channel.contentType = "plain/text"; NetUtil.asyncFetch(channel, function(aStream, aResult) { if (!Components.isSuccessCode(aResult)) { diff --git a/dom/apps/TrustedHostedAppsUtils.jsm b/dom/apps/TrustedHostedAppsUtils.jsm index fb42c6816b5..73b870508ac 100644 --- a/dom/apps/TrustedHostedAppsUtils.jsm +++ b/dom/apps/TrustedHostedAppsUtils.jsm @@ -203,15 +203,11 @@ this.TrustedHostedAppsUtils = { let principal = Services.scriptSecurityManager.getAppCodebasePrincipal( aApp.origin, aApp.localId, false); - let mRequestChannel = NetUtil.newChannel2(aApp.manifestURL, - null, - null, - null, // aLoadingNode - principal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER) - .QueryInterface(Ci.nsIHttpChannel); + let mRequestChannel = NetUtil.newChannel({ + uri: aApp.manifestURL, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER} + ).QueryInterface(Ci.nsIHttpChannel); mRequestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING; mRequestChannel.notificationCallbacks = AppsUtils.createLoadContext(aAppId, false); @@ -232,15 +228,11 @@ this.TrustedHostedAppsUtils = { return; } - let sRequestChannel = NetUtil.newChannel2(signatureURL, - null, - null, - null, // aLoadingNode - principal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER) - .QueryInterface(Ci.nsIHttpChannel); + let sRequestChannel = NetUtil.newChannel({ + uri: signatureURL, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER} + ).QueryInterface(Ci.nsIHttpChannel); sRequestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING; sRequestChannel.notificationCallbacks = AppsUtils.createLoadContext(aAppId, false); diff --git a/dom/apps/Webapps.jsm b/dom/apps/Webapps.jsm index b9f6e7ce19b..d94fc9b6dab 100644 --- a/dom/apps/Webapps.jsm +++ b/dom/apps/Webapps.jsm @@ -3527,25 +3527,17 @@ this.DOMApplicationRegistry = { appURI, aNewApp.localId, false); if (aIsLocalFileInstall) { - requestChannel = NetUtil.newChannel2(aFullPackagePath, - null, - null, - null, // aLoadingNode - principal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER) - .QueryInterface(Ci.nsIFileChannel); + requestChannel = NetUtil.newChannel({ + uri: aFullPackagePath, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER} + ).QueryInterface(Ci.nsIFileChannel); } else { - requestChannel = NetUtil.newChannel2(aFullPackagePath, - null, - null, - null, // aLoadingNode - principal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER) - .QueryInterface(Ci.nsIHttpChannel); + requestChannel = NetUtil.newChannel({ + uri: aFullPackagePath, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER} + ).QueryInterface(Ci.nsIHttpChannel); requestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING; } diff --git a/dom/base/test/unit/test_cspreports.js b/dom/base/test/unit/test_cspreports.js index 4b3e2e0ea88..54e42d00dc6 100644 --- a/dom/base/test/unit/test_cspreports.js +++ b/dom/base/test/unit/test_cspreports.js @@ -71,14 +71,9 @@ function makeTest(id, expectedJSON, useReportOnlyPolicy, callback) { var selfuri = NetUtil.newURI(REPORT_SERVER_URI + ":" + REPORT_SERVER_PORT + "/foo/self"); - var selfchan = NetUtil.newChannel2(selfuri, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var selfchan = NetUtil.newChannel({ + uri: selfuri, + loadUsingSystemPrincipal: true}); dump("Created test " + id + " : " + policy + "\n\n"); diff --git a/dom/base/test/unit/test_thirdpartyutil.js b/dom/base/test/unit/test_thirdpartyutil.js index 3547ff67304..029809ebaec 100644 --- a/dom/base/test/unit/test_thirdpartyutil.js +++ b/dom/base/test/unit/test_thirdpartyutil.js @@ -41,44 +41,16 @@ function run_test() { let spec2 = "http://bar.com/bar.html"; let uri1 = NetUtil.newURI(spec1); let uri2 = NetUtil.newURI(spec2); - let channel1 = NetUtil.newChannel2(uri1, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let channel2 = NetUtil.newChannel2(uri2, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true}); + let channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true}); // Create some file:// URIs. let filespec1 = "file://foo.txt"; let filespec2 = "file://bar.txt"; let fileuri1 = NetUtil.newURI(filespec1); let fileuri2 = NetUtil.newURI(filespec2); - let filechannel1 = NetUtil.newChannel2(fileuri1, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - let filechannel2 = NetUtil.newChannel2(fileuri2, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let filechannel1 = NetUtil.newChannel({uri: fileuri1, loadUsingSystemPrincipal: true}); + let filechannel2 = NetUtil.newChannel({uri: fileuri2, loadUsingSystemPrincipal: true}); // Test isThirdPartyURI. do_check_false(util.isThirdPartyURI(uri1, uri1)); diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm index 5d3799b28ee..11ab1d2cab4 100644 --- a/dom/contacts/fallback/ContactDB.jsm +++ b/dom/contacts/fallback/ContactDB.jsm @@ -124,14 +124,10 @@ ContactDB.prototype = { } } - let chan = jsm.NetUtil.newChannel2(contactsFile, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let chan = jsm.NetUtil.newChannel({ + uri: NetUtil.newURI(contactsFile), + loadUsingSystemPrincipal: true}); + let stream = chan.open(); // Obtain a converter to read from a UTF-8 encoded input stream. let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] diff --git a/dom/settings/SettingsDB.jsm b/dom/settings/SettingsDB.jsm index 492bff72bf4..0268ef10782 100644 --- a/dom/settings/SettingsDB.jsm +++ b/dom/settings/SettingsDB.jsm @@ -80,14 +80,9 @@ SettingsDB.prototype = { } } - let chan = NetUtil.newChannel2(settingsFile, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let chan = NetUtil.newChannel({ + uri: NetUtil.newURI(settingsFile), + loadUsingSystemPrincipal: true}); let stream = chan.open(); // Obtain a converter to read from a UTF-8 encoded input stream. let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] diff --git a/extensions/cookie/test/unit/test_cookies_persistence.js b/extensions/cookie/test/unit/test_cookies_persistence.js index 622491574d5..a965442b62d 100644 --- a/extensions/cookie/test/unit/test_cookies_persistence.js +++ b/extensions/cookie/test/unit/test_cookies_persistence.js @@ -29,22 +29,8 @@ function do_run_test() { var spec2 = "http://bar.com/bar.html"; var uri1 = NetUtil.newURI(spec1); var uri2 = NetUtil.newURI(spec2); - var channel1 = NetUtil.newChannel2(uri1, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var channel2 = NetUtil.newChannel2(uri2, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true}); + var channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true}); // Force the channel URI to be used when determining the originating URI of // the channel. diff --git a/extensions/cookie/test/unit/test_cookies_thirdparty.js b/extensions/cookie/test/unit/test_cookies_thirdparty.js index 944cda3df55..a39f807f225 100644 --- a/extensions/cookie/test/unit/test_cookies_thirdparty.js +++ b/extensions/cookie/test/unit/test_cookies_thirdparty.js @@ -12,22 +12,8 @@ function run_test() { var spec2 = "http://bar.com/bar.html"; var uri1 = NetUtil.newURI(spec1); var uri2 = NetUtil.newURI(spec2); - var channel1 = NetUtil.newChannel2(uri1, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var channel2 = NetUtil.newChannel2(uri2, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true}); + var channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true}); // test with cookies enabled Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); diff --git a/extensions/cookie/test/unit/test_cookies_thirdparty_session.js b/extensions/cookie/test/unit/test_cookies_thirdparty_session.js index ddae855a79b..7bf5c9d8b25 100644 --- a/extensions/cookie/test/unit/test_cookies_thirdparty_session.js +++ b/extensions/cookie/test/unit/test_cookies_thirdparty_session.js @@ -29,22 +29,8 @@ function do_run_test() { var spec2 = "http://bar.com/bar.html"; var uri1 = NetUtil.newURI(spec1); var uri2 = NetUtil.newURI(spec2); - var channel1 = NetUtil.newChannel2(uri1, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); - var channel2 = NetUtil.newChannel2(uri2, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + var channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true}); + var channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true}); // Force the channel URI to be used when determining the originating URI of // the channel. diff --git a/mobile/android/tests/browser/robocop/testResourceSubstitutions.js b/mobile/android/tests/browser/robocop/testResourceSubstitutions.js index a941f53f7af..5ce58da1029 100644 --- a/mobile/android/tests/browser/robocop/testResourceSubstitutions.js +++ b/mobile/android/tests/browser/robocop/testResourceSubstitutions.js @@ -12,14 +12,8 @@ Cu.import("resource://gre/modules/NetUtil.jsm"); /*global NetUtil */ function readChannel(url) { let deferred = Promise.defer(); - let channel = NetUtil.newChannel2(url, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true}); + channel.contentType = "text/plain"; NetUtil.asyncFetch(channel, function(inputStream, status) { diff --git a/netwerk/test/browser/browser_NetUtil.js b/netwerk/test/browser/browser_NetUtil.js index ea34b4e15d6..974a7e1feb6 100644 --- a/netwerk/test/browser/browser_NetUtil.js +++ b/netwerk/test/browser/browser_NetUtil.js @@ -36,14 +36,9 @@ function test_asyncFetchBadCert() { ok(aRequest instanceof Ci.nsIHttpChannel, "request is an nsIHttpChannel"); // Now try again with a channel whose notificationCallbacks doesn't suprress errors - let channel = NetUtil.newChannel2("https://untrusted.example.com", - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({ + uri: "https://untrusted.example.com", + loadUsingSystemPrincipal: true}); channel.notificationCallbacks = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIProgressEventSink, Ci.nsIInterfaceRequestor]), diff --git a/toolkit/components/addoncompat/RemoteAddonsParent.jsm b/toolkit/components/addoncompat/RemoteAddonsParent.jsm index ea303f8fab0..badfea8c95b 100644 --- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm @@ -259,14 +259,7 @@ let AboutProtocolParent = { let securityFlags = msg.data.securityFlags; let contentPolicyType = msg.data.contentPolicyType; try { - let channel = NetUtil.newChannel2(uri, - null, - null, - null, // aLoadingNode - loadingPrincipal, - null, // aTriggeringPrincipal - securityFlags, - contentPolicyType); + let channel = NetUtil.newChannel({uri, loadingPrincipal, securityFlags, contentPolicyType}); // We're not allowed to set channel.notificationCallbacks to a // CPOW, since the setter for notificationCallbacks is in C++, diff --git a/toolkit/components/downloads/test/unit/test_cancel_download_files_removed.js b/toolkit/components/downloads/test/unit/test_cancel_download_files_removed.js index d410b125637..3497ee8eaa2 100644 --- a/toolkit/components/downloads/test/unit/test_cancel_download_files_removed.js +++ b/toolkit/components/downloads/test/unit/test_cancel_download_files_removed.js @@ -90,14 +90,7 @@ function runNextTest() let uri = "http://localhost:" + httpserver.identity.primaryPort + set.serverPath; - let channel = NetUtil.newChannel2(uri, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true}); let uriloader = Cc["@mozilla.org/uriloader;1"].getService(Ci.nsIURILoader); uriloader.openURI(channel, Ci.nsIURILoader.IS_CONTENT_PREFERRED, new WindowContext()); diff --git a/toolkit/components/downloads/test/unit/test_download_samename.js b/toolkit/components/downloads/test/unit/test_download_samename.js index c609e22447a..e1288f9cb8d 100644 --- a/toolkit/components/downloads/test/unit/test_download_samename.js +++ b/toolkit/components/downloads/test/unit/test_download_samename.js @@ -112,14 +112,7 @@ function runNextTest() let uri = "http://localhost:" + httpserver.identity.primaryPort + set.serverURL; - let channel = NetUtil.newChannel2(uri, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true}); let uriloader = Cc["@mozilla.org/uriloader;1"].getService(Ci.nsIURILoader); uriloader.openURI(channel, Ci.nsIURILoader.IS_CONTENT_PREFERRED, new WindowContext()); diff --git a/toolkit/devtools/server/actors/settings.js b/toolkit/devtools/server/actors/settings.js index ebf49d25b3d..0b06aa542a6 100644 --- a/toolkit/devtools/server/actors/settings.js +++ b/toolkit/devtools/server/actors/settings.js @@ -23,14 +23,9 @@ exports.unregister = function(handle) { }; function getDefaultSettings() { - let chan = NetUtil.newChannel2(settingsFile, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let chan = NetUtil.newChannel({ + uri: NetUtil.newURI(settingsFile), + loadUsingSystemPrincipal: true}); let stream = chan.open(); // Obtain a converter to read from a UTF-8 encoded input stream. let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] diff --git a/toolkit/devtools/webconsole/network-helper.js b/toolkit/devtools/webconsole/network-helper.js index 26697c37963..91684e4c182 100644 --- a/toolkit/devtools/webconsole/network-helper.js +++ b/toolkit/devtools/webconsole/network-helper.js @@ -275,14 +275,7 @@ let NetworkHelper = { */ loadFromCache: function NH_loadFromCache(aUrl, aCharset, aCallback) { - let channel = NetUtil.newChannel2(aUrl, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + let channel = NetUtil.newChannel({uri: aUrl, loadUsingSystemPrincipal: true}); // Ensure that we only read from the cache and not the server. channel.loadFlags = Ci.nsIRequest.LOAD_FROM_CACHE | diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 52e176898a2..a142dee48da 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -5571,14 +5571,9 @@ AddonInstall.prototype = { let requireBuiltIn = Preferences.get(PREF_INSTALL_REQUIREBUILTINCERTS, true); this.badCertHandler = new CertUtils.BadCertHandler(!requireBuiltIn); - this.channel = NetUtil.newChannel2(this.sourceURI, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER); + this.channel = NetUtil.newChannel({ + uri: this.sourceURI, + loadUsingSystemPrincipal: true}); this.channel.notificationCallbacks = this; if (this.channel instanceof Ci.nsIHttpChannel) { this.channel.setRequestHeader("Moz-XPI-Update", "1", true); diff --git a/toolkit/webapps/NativeApp.jsm b/toolkit/webapps/NativeApp.jsm index 515b1bd0c89..618cc47154c 100644 --- a/toolkit/webapps/NativeApp.jsm +++ b/toolkit/webapps/NativeApp.jsm @@ -456,14 +456,10 @@ function downloadIcon(aIconURI) { : Services.scriptSecurityManager .getNoAppCodebasePrincipal(aIconURI); - let channel = NetUtil.newChannel2(aIconURI, - null, - null, - null, // aLoadingNode - principal, - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_IMAGE); + let channel = NetUtil.newChannel({ + uri: aIconURI, + loadingPrincipal: principal, + contentPolicyType: Ci.nsIContentPolicy.TYPE_IMAGE}); let { BadCertHandler } = Cu.import("resource://gre/modules/CertUtils.jsm", {}); // Pass true to avoid optional redirect-cert-checking behavior. channel.notificationCallbacks = new BadCertHandler(true);