зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1124951: Make JS callers of ios.newChannel call ios.newChannel2 in toolkit/devtools - tests (r=jryans)
This commit is contained in:
Родитель
86f44c7f9e
Коммит
3e805ca519
|
@ -86,7 +86,14 @@ function webappActorRequest(request, onResponse) {
|
|||
|
||||
|
||||
function downloadURL(url, file) {
|
||||
let channel = Services.io.newChannel(url, null, null);
|
||||
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 bstream = Cc["@mozilla.org/binaryinputstream;1"]
|
||||
.createInstance(Ci.nsIBinaryInputStream);
|
||||
|
|
|
@ -7,6 +7,7 @@ let { DebuggerClient } =
|
|||
Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
|
||||
let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
|
||||
let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
||||
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
let Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
|
||||
let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
|
||||
|
@ -61,11 +62,18 @@ TestBulkActor.prototype = {
|
|||
type: type,
|
||||
length: really_long().length
|
||||
}).then(({copyFrom}) => {
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-input"), input => {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-input"),
|
||||
input => {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -160,12 +168,19 @@ let test_bulk_request_cs = Task.async(function*(transportFactory, actorType, rep
|
|||
|
||||
// Send bulk data to server
|
||||
request.on("bulk-send-ready", ({copyFrom}) => {
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-input"), input => {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
bulkCopyDeferred.resolve();
|
||||
});
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-input"),
|
||||
input => {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
bulkCopyDeferred.resolve();
|
||||
});
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
});
|
||||
|
||||
// Set up reply handling for this type
|
||||
|
@ -242,13 +257,20 @@ function verify_files() {
|
|||
|
||||
// Ensure output file contents actually match
|
||||
let compareDeferred = promise.defer();
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-output"), input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-output"),
|
||||
input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
return compareDeferred.promise.then(cleanup_files);
|
||||
}
|
||||
|
|
|
@ -40,11 +40,18 @@ let test_transport = Task.async(function*(transportFactory) {
|
|||
|
||||
// Sending from client to server
|
||||
function write_data({copyFrom}) {
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-input"), function(input, status) {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-input"),
|
||||
function(input, status) {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
// Receiving on server from client
|
||||
|
@ -148,13 +155,20 @@ function verify() {
|
|||
|
||||
// Ensure output file contents actually match
|
||||
let compareDeferred = promise.defer();
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-output"), input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-output"),
|
||||
input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
return compareDeferred.promise.then(cleanup_files);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ let { DebuggerServer } =
|
|||
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
|
||||
let { FileUtils } = Cu.import("resource://gre/modules/FileUtils.jsm", {});
|
||||
let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
||||
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
|
||||
function run_test() {
|
||||
initTestDebuggerServer();
|
||||
|
@ -40,11 +41,18 @@ let test_bulk_transfer_transport = Task.async(function*(transportFactory) {
|
|||
|
||||
// Sending from client to server
|
||||
function write_data({copyFrom}) {
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-input"), function(input, status) {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-input"),
|
||||
function(input, status) {
|
||||
copyFrom(input).then(() => {
|
||||
input.close();
|
||||
});
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
// Receiving on server from client
|
||||
|
@ -119,13 +127,20 @@ function verify() {
|
|||
|
||||
// Ensure output file contents actually match
|
||||
let compareDeferred = promise.defer();
|
||||
NetUtil.asyncFetch(getTestTempFile("bulk-output"), input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
});
|
||||
NetUtil.asyncFetch2(
|
||||
getTestTempFile("bulk-output"),
|
||||
input => {
|
||||
let outputData = NetUtil.readInputStreamToString(input, reallyLong.length);
|
||||
// Avoid do_check_eq here so we don't log the contents
|
||||
do_check_true(outputData === reallyLong);
|
||||
input.close();
|
||||
compareDeferred.resolve();
|
||||
},
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
return compareDeferred.promise.then(cleanup_files);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче