mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1087738: Make JS callers of ios.newChannel call ios.newChannel2 in modules/ (r=mwu)
This commit is contained in:
parent
e62757c692
commit
cdf513de55
@ -1,5 +1,7 @@
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Regression test for bug 370103 - crash when passing a null listener to
|
||||
// nsIChannel.asyncOpen
|
||||
@ -12,7 +14,14 @@ function run_test() {
|
||||
url = "jar:" + url + "!/test_bug370103";
|
||||
|
||||
// Try opening channel with null listener
|
||||
var channel = ioService.newChannel(url, null, null);
|
||||
var channel = ioService.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
var exception = false;
|
||||
try {
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// XXX: NS_ERROR_UNKNOWN_HOST is not in Components.results
|
||||
const NS_ERROR_UNKNOWN_HOST = 0x804B001E;
|
||||
@ -32,8 +34,14 @@ function run_test() {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
|
||||
var channel = ios.newChannel("jar:http://test.invalid/test.jar!/index.html",
|
||||
null, null);
|
||||
var channel = ios.newChannel2("jar:http://test.invalid/test.jar!/index.html",
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
channel.asyncOpen(listener, null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -2,13 +2,23 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const path = "data/test_bug589292.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 + "!/foo.txt";
|
||||
var channel = ios.newChannel(spec, null, null);
|
||||
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 val;
|
||||
try {
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Check that reading non existant inner jars results in the right error
|
||||
|
||||
@ -14,8 +16,22 @@ 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.newChannel(goodSpec, null, null);
|
||||
var badChannel = ios.newChannel(badSpec, null, null);
|
||||
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);
|
||||
|
||||
try {
|
||||
instr = goodChannel.open();
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Check that the zip cache can expire entries from nested jars
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
@ -11,7 +13,14 @@ 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.newChannel(spec, null, null);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Check that we don't crash on reading a directory entry signature
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
@ -12,7 +14,14 @@ 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.newChannel(spec, null, null);
|
||||
var channel = ios.newChannel2(spec,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var failed = false;
|
||||
try {
|
||||
var stream = channel.open();
|
||||
|
@ -10,9 +10,12 @@
|
||||
const {classes: Cc,
|
||||
interfaces: Ci,
|
||||
results: Cr,
|
||||
utils: Cu,
|
||||
Constructor: ctor
|
||||
} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
@ -72,7 +75,14 @@ Listener.prototype = {
|
||||
*/
|
||||
function testAsync() {
|
||||
var uri = jarBase + "/inner40.zip";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
do_check_true(chan.contentLength < 0);
|
||||
chan.asyncOpen(new Listener(function(l) {
|
||||
do_check_true(chan.contentLength > 0);
|
||||
@ -94,7 +104,15 @@ add_test(testAsync);
|
||||
*/
|
||||
function testZipEntry() {
|
||||
var uri = jarBase + "/inner40.zip";
|
||||
var chan = ios.newChannel(uri, null, null).QueryInterface(Ci.nsIJARChannel);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIJARChannel);
|
||||
var entry = chan.zipEntry;
|
||||
do_check_true(entry.CRC32 == 0x8b635486);
|
||||
do_check_true(entry.realSize == 184);
|
||||
@ -114,7 +132,14 @@ if (!inChild) {
|
||||
*/
|
||||
add_test(function testSync() {
|
||||
var uri = jarBase + "/inner40.zip";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var stream = chan.open();
|
||||
do_check_true(chan.contentLength > 0);
|
||||
do_check_eq(stream.available(), chan.contentLength);
|
||||
@ -130,7 +155,14 @@ if (!inChild) {
|
||||
*/
|
||||
add_test(function testSyncNested() {
|
||||
var uri = "jar:" + jarBase + "/inner40.zip!/foo";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var stream = chan.open();
|
||||
do_check_true(chan.contentLength > 0);
|
||||
do_check_eq(stream.available(), chan.contentLength);
|
||||
@ -145,7 +177,14 @@ if (!inChild) {
|
||||
*/
|
||||
add_test(function testAsyncNested(next) {
|
||||
var uri = "jar:" + jarBase + "/inner40.zip!/foo";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(new Listener(function(l) {
|
||||
do_check_true(chan.contentLength > 0);
|
||||
do_check_true(l.gotStartRequest);
|
||||
@ -166,7 +205,14 @@ if (!inChild) {
|
||||
file.copyTo(copy.parent, copy.leafName);
|
||||
|
||||
var uri = "jar:" + ios.newFileURI(copy).spec + "!/inner40.zip";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var stream = chan.open();
|
||||
do_check_true(chan.contentLength > 0);
|
||||
stream.close();
|
||||
@ -194,7 +240,14 @@ if (!inChild) {
|
||||
file.copyTo(copy.parent, copy.leafName);
|
||||
|
||||
var uri = "jar:" + ios.newFileURI(copy).spec + "!/inner40.zip";
|
||||
var chan = ios.newChannel(uri, null, null);
|
||||
var chan = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(new Listener(function (l) {
|
||||
do_check_true(chan.contentLength > 0);
|
||||
|
||||
@ -225,7 +278,14 @@ if (inChild) {
|
||||
obs.notifyObservers(null, "chrome-flush-caches", null);
|
||||
|
||||
// Open the first channel without ensureChildFd()
|
||||
var chan_first = ios.newChannel(uri, null, null)
|
||||
var chan_first = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIJARChannel);
|
||||
chan_first.asyncOpen(new Listener(function(l) {
|
||||
}), null);
|
||||
@ -234,7 +294,14 @@ if (inChild) {
|
||||
var num = 10;
|
||||
var chan = [];
|
||||
for (var i = 0; i < num; i++) {
|
||||
chan[i] = ios.newChannel(uri, null, null)
|
||||
chan[i] = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIJARChannel);
|
||||
chan[i].ensureChildFd();
|
||||
chan[i].asyncOpen(new Listener(function(l) {
|
||||
@ -242,7 +309,14 @@ if (inChild) {
|
||||
}
|
||||
|
||||
// Open the last channel with ensureChildFd()
|
||||
var chan_last = ios.newChannel(uri, null, null)
|
||||
var chan_last = ios.newChannel2(uri,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIJARChannel);
|
||||
chan_last.ensureChildFd();
|
||||
chan_last.asyncOpen(new Listener(function(l) {
|
||||
|
@ -2,13 +2,23 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.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.newChannel(spec + "file_that_isnt_in.archive", null, null);
|
||||
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);
|
||||
try {
|
||||
instr = channel.open();
|
||||
do_throw("Failed to report that file doesn't exist")
|
||||
|
@ -3,6 +3,9 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Values taken from using zipinfo to list the test.zip contents
|
||||
var TESTS = [
|
||||
{
|
||||
@ -68,13 +71,23 @@ var methods = {
|
||||
{
|
||||
zipW.addEntryChannel(entry, source.lastModifiedTime * PR_MSEC_PER_SEC,
|
||||
Ci.nsIZipWriter.COMPRESSION_NONE,
|
||||
ioSvc.newChannelFromURI(ioSvc.newFileURI(source)), true);
|
||||
ioSvc.newChannelFromURI2(ioSvc.newFileURI(source),
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER), true);
|
||||
},
|
||||
stream: function method_stream(entry, source)
|
||||
{
|
||||
zipW.addEntryStream(entry, source.lastModifiedTime * PR_MSEC_PER_SEC,
|
||||
Ci.nsIZipWriter.COMPRESSION_NONE,
|
||||
ioSvc.newChannelFromURI(ioSvc.newFileURI(source)).open(), true);
|
||||
ioSvc.newChannelFromURI2(ioSvc.newFileURI(source),
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER).open(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user