import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
2

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,39 @@
// Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section.
var Cc = Components.classes;
var Ci = Components.interfaces;
const path = "data/test_bug333423.zip";
function test_relative_sub() {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
var base = ios.newURI(spec, null, null);
var uri = ios.newURI("../modules/libjar", null, base);
// This is the URI we expect to see.
var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
"!/modules/libjar";
do_check_eq(uri.spec, expected);
}
function test_relative_base() {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var base = ios.newFileURI(do_get_file("data/empty"));
var uri = ios.newURI("jar:../" + path + "!/", null, base);
// This is the URI we expect to see.
var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
"!/";
do_check_eq(uri.spec, expected);
}
function run_test() {
test_relative_sub();
test_relative_base();
}

View file

@ -0,0 +1,22 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Regression test for bug 333423 - crash enumerating entries of a
// closed nsIZipReader
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// the build script have created the zip we can test on in the current dir.
var file = do_get_file("data/test_bug333423.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
zipreader.close();
var entries = zipreader.findEntries('*.*');
do_check_true(!entries.hasMore()); // this shouldn't crash
}

View file

@ -0,0 +1,12 @@
// Regression test for bug 336691 - nsZipArchive::Test shouldn't try to ExtractFile on directories.
var Cc = Components.classes;
var Ci = Components.interfaces;
function run_test() {
var file = do_get_file("data/test_bug336691.zip");
var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipReader.open(file);
zipReader.test(null); // We shouldn't crash here.
zipReader.close();
}

View file

@ -0,0 +1,28 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
// Regression test for bug 370103 - crash when passing a null listener to
// nsIChannel.asyncOpen
function run_test() {
// Compose the jar: url
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var file = do_get_file("data/test_bug370103.jar");
var url = ioService.newFileURI(file).spec;
url = "jar:" + url + "!/test_bug370103";
// Try opening channel with null listener
var channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
var exception = false;
try {
channel.asyncOpen2(null);
}
catch(e) {
exception = true;
}
do_check_true(exception); // should throw exception instead of crashing
}

View file

@ -0,0 +1,23 @@
// Regression test for bug 379841 - nsIZipReader's last modified time ignores seconds
var Cc = Components.classes;
var Ci = Components.interfaces;
const path = "data/test_bug379841.zip";
// Retrieved time should be within 2 seconds of original file's time.
const MAX_TIME_DIFF = 2000000;
var ENTRY_NAME = "test";
// Actual time of file was 07 May 2007 13:35:49 UTC
var ENTRY_TIME = new Date(Date.UTC(2007, 4, 7, 13, 35, 49, 0));
function run_test() {
var file = do_get_file(path);
var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipReader.open(file);
var entry = zipReader.getEntry(ENTRY_NAME);
var diff = Math.abs(entry.lastModifiedTime - ENTRY_TIME.getTime()*1000);
zipReader.close();
if (diff >= MAX_TIME_DIFF)
do_throw(diff);
}

View file

@ -0,0 +1,42 @@
// Regression test for bug 407303 - A failed channel should not be checked
// for an unsafe content type.
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
// XXX: NS_ERROR_UNKNOWN_HOST is not in Components.results
const NS_ERROR_UNKNOWN_HOST = 0x804B001E;
var listener = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIRequestObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
onStartRequest: function(request, context) {
},
onDataAvailable: function(request, context, stream, offset, count) {
do_throw("shouldn't get data!");
},
onStopRequest: function(request, context, status) {
do_check_eq(status, NS_ERROR_UNKNOWN_HOST);
do_test_finished();
}
};
function run_test() {
Services.prefs.setBoolPref("network.jar.block-remote-files", false);
var channel = NetUtil.newChannel({
uri: "jar:http://test.invalid/test.jar!/index.html",
loadUsingSystemPrincipal: true}
);
channel.asyncOpen2(listener);
do_test_pending();
}

View file

@ -0,0 +1,12 @@
function run_test() {
const zipCache = Components.classes["@mozilla.org/libjar/zip-reader-cache;1"]
.createInstance(Components.interfaces.nsIZipReaderCache);
zipCache.init(1024);
try {
zipCache.getZip(null);
do_throw("Shouldn't get here!");
} catch (e if ((e instanceof Components.interfaces.nsIException) &&
(e.result == Components.results.NS_ERROR_INVALID_POINTER))) {
// do nothing, this test passes
}
}

View file

@ -0,0 +1,11 @@
function run_test() {
var zReader = Components.classes["@mozilla.org/libjar/zip-reader;1"]
.createInstance(Components.interfaces.nsIZipReader);
try {
zReader.open(null);
do_throw("Shouldn't get here!");
} catch (e if (e instanceof Components.interfaces.nsIException &&
e.result == Components.results.NS_ERROR_NULL_POINTER)) {
// do nothing, this test passes
}
}

View file

@ -0,0 +1,25 @@
// Make sure we behave appropriately when asking for content-disposition
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.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 = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
instr = channel.open2();
var val;
try {
val = channel.contentDisposition;
do_check_true(false, "The channel has content disposition?!");
} catch (e) {
// This is what we want to happen - there's no underlying channel, so no
// content-disposition header is available
do_check_true(true, "How are you reading this?!");
}
}

View file

@ -0,0 +1,35 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
// Check that reading non existant inner jars results in the right error
function run_test() {
var file = do_get_file("data/test_bug597702.zip");
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
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 = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
var badChannel = NetUtil.newChannel({uri: badSpec, loadUsingSystemPrincipal: true});
try {
instr = goodChannel.open2();
} catch (e) {
do_throw("Failed to open file in inner jar");
}
try {
instr = badChannel.open2();
do_throw("Failed to report that file doesn't exist");
} catch (e) {
do_check_true(e.name == "NS_ERROR_FILE_NOT_FOUND");
}
}

View file

@ -0,0 +1,29 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
// Check that the zip cache can expire entries from nested jars
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
function open_inner_zip(base, idx) {
var spec = "jar:" + base + "inner" + idx + ".zip!/foo";
var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
var stream = channel.open2();
}
function run_test() {
var file = do_get_file("data/test_bug637286.zip");
var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
for (var i = 0; i < 40; i++) {
open_inner_zip(outerJarBase, i);
gc();
}
}

View file

@ -0,0 +1,25 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
// Check that we don't crash on reading a directory entry signature
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
function run_test() {
var file = do_get_file("data/test_bug658093.zip");
var spec = "jar:" + ios.newFileURI(file).spec + "!/0000";
var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
var failed = false;
try {
var stream = channel.open2();
} catch (e) {
failed = true;
}
do_check_true(failed);
}

View file

@ -0,0 +1,34 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Regression test ensuring that that a STORED entry with differing compressed
// and uncompressed sizes is considered to be corrupt.
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
var file = do_get_file("data/test_corrupt3.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
var entries = zipreader.findEntries('*');
var failed = false;
while (entries.hasMore()) {
let entryPath = entries.getNext();
let entry = zipreader.getEntry(entryPath);
if (!entry.isDirectory) {
try {
let inputStream = zipreader.getInputStream(entryPath);
} catch (e) {
failed = true;
}
}
}
do_check_true(failed);
}

View file

@ -0,0 +1,36 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function wrapInputStream(input)
{
var nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
var factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
var wrapper = factory.createInstance(nsIScriptableInputStream);
wrapper.init(input);
return wrapper;
}
// Check that files can be read from after closing zipreader
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// the build script have created the zip we can test on in the current dir.
var file = do_get_file("data/test_corrupt.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
// var entries = zipreader.findEntries(null);
// the signature for file is corrupt, should not segfault
var failed = false;
try {
var stream = wrapInputStream(zipreader.getInputStream("file"));
stream.read(1024);
} catch (ex) {
failed = true;
}
do_check_true(failed);
}

View file

@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Check that files can be read from after closing zipreader
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// the build script have created the zip we can test on in the current dir.
var file = do_get_file("data/test_corrupt2.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
var failed = false;
try {
zipreader.open(file);
// corrupt files should trigger an exception
} catch (ex) {
failed = true;
}
do_check_true(failed);
}

View file

@ -0,0 +1,43 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function wrapInputStream(input)
{
let nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
let factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
let wrapper = factory.createInstance(nsIScriptableInputStream);
wrapper.init(input);
return wrapper;
}
// Make sure that we can read from CRX files as if they were ZIP files.
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// Note: test_crx_dummy.crx is a dummy crx file created for this test. The
// public key and signature fields in the header are both empty.
let file = do_get_file("data/test_crx_dummy.crx");
let zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
// do crc stuff
function check_archive_crc() {
zipreader.test(null);
return true;
}
Assert.ok(check_archive_crc())
let entries = zipreader.findEntries(null);
let stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"))
let dirstream= wrapInputStream(zipreader.getInputStream("modules/libjar/test/"))
zipreader.close();
zipreader = null;
Components.utils.forceGC();
Assert.ok(stream.read(1024).length > 0);
Assert.ok(dirstream.read(100).length > 0);
}

View file

@ -0,0 +1,25 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Check that we refuse to open weird files
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// open a bogus file
var file = do_get_file("/");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
var failed = false;
try {
zipreader.open(file);
} catch (e) {
failed = true;
}
do_check_true(failed);
zipreader = null;
}

View file

@ -0,0 +1,216 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Tests some basic jar channel functionality
*/
const {classes: Cc,
interfaces: Ci,
results: Cr,
utils: Cu,
Constructor: ctor
} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
const obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const nsIBinaryInputStream = ctor("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream"
);
const fileBase = "test_bug637286.zip";
const file = do_get_file("data/" + fileBase);
const jarBase = "jar:" + ios.newFileURI(file).spec + "!";
const tmpDir = dirSvc.get("TmpD", Ci.nsIFile);
function Listener(callback) {
this._callback = callback;
}
Listener.prototype = {
gotStartRequest: false,
available: -1,
gotStopRequest: false,
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIRequestObserver))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
onDataAvailable: function(request, ctx, stream, offset, count) {
try {
this.available = stream.available();
do_check_eq(this.available, count);
// Need to consume stream to avoid assertion
new nsIBinaryInputStream(stream).readBytes(count);
}
catch (ex) {
do_throw(ex);
}
},
onStartRequest: function(request, ctx) {
this.gotStartRequest = true;
},
onStopRequest: function(request, ctx, status) {
this.gotStopRequest = true;
do_check_eq(status, 0);
if (this._callback) {
this._callback.call(null, this);
}
}
};
/**
* Basic reading test for asynchronously opened jar channel
*/
function testAsync() {
var uri = jarBase + "/inner40.zip";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
do_check_true(chan.contentLength < 0);
chan.asyncOpen2(new Listener(function(l) {
do_check_true(chan.contentLength > 0);
do_check_true(l.gotStartRequest);
do_check_true(l.gotStopRequest);
do_check_eq(l.available, chan.contentLength);
run_next_test();
}));
}
add_test(testAsync);
// Run same test again so we test the codepath for a zipcache hit
add_test(testAsync);
/**
* Basic test for nsIZipReader.
*/
function testZipEntry() {
var uri = jarBase + "/inner40.zip";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true})
.QueryInterface(Ci.nsIJARChannel);
var entry = chan.zipEntry;
do_check_true(entry.CRC32 == 0x8b635486);
do_check_true(entry.realSize == 184);
run_next_test();
}
add_test(testZipEntry);
/**
* Basic reading test for synchronously opened jar channels
*/
add_test(function testSync() {
var uri = jarBase + "/inner40.zip";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
var stream = chan.open2();
do_check_true(chan.contentLength > 0);
do_check_eq(stream.available(), chan.contentLength);
stream.close();
stream.close(); // should still not throw
run_next_test();
});
/**
* Basic reading test for synchronously opened, nested jar channels
*/
add_test(function testSyncNested() {
var uri = "jar:" + jarBase + "/inner40.zip!/foo";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
var stream = chan.open2();
do_check_true(chan.contentLength > 0);
do_check_eq(stream.available(), chan.contentLength);
stream.close();
stream.close(); // should still not throw
run_next_test();
});
/**
* Basic reading test for asynchronously opened, nested jar channels
*/
add_test(function testAsyncNested(next) {
var uri = "jar:" + jarBase + "/inner40.zip!/foo";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
chan.asyncOpen2(new Listener(function(l) {
do_check_true(chan.contentLength > 0);
do_check_true(l.gotStartRequest);
do_check_true(l.gotStopRequest);
do_check_eq(l.available, chan.contentLength);
run_next_test();
}));
});
/**
* Verify that file locks are released when closing a synchronously
* opened jar channel stream
*/
add_test(function testSyncCloseUnlocks() {
var copy = tmpDir.clone();
copy.append(fileBase);
file.copyTo(copy.parent, copy.leafName);
var uri = "jar:" + ios.newFileURI(copy).spec + "!/inner40.zip";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
var stream = chan.open2();
do_check_true(chan.contentLength > 0);
stream.close();
// Drop any jar caches
obs.notifyObservers(null, "chrome-flush-caches", null);
try {
copy.remove(false);
}
catch (ex) {
do_throw(ex);
}
run_next_test();
});
/**
* Verify that file locks are released when closing an asynchronously
* opened jar channel stream
*/
add_test(function testAsyncCloseUnlocks() {
var copy = tmpDir.clone();
copy.append(fileBase);
file.copyTo(copy.parent, copy.leafName);
var uri = "jar:" + ios.newFileURI(copy).spec + "!/inner40.zip";
var chan = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true});
chan.asyncOpen2(new Listener(function (l) {
do_check_true(chan.contentLength > 0);
// Drop any jar caches
obs.notifyObservers(null, "chrome-flush-caches", null);
try {
copy.remove(false);
}
catch (ex) {
do_throw(ex);
}
run_next_test();
}));
});
function run_test() {
return run_next_test();
}

View file

@ -0,0 +1,42 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function wrapInputStream(input)
{
var nsIScriptableInputStream = Components.interfaces.nsIScriptableInputStream;
var factory = Components.classes["@mozilla.org/scriptableinputstream;1"];
var wrapper = factory.createInstance(nsIScriptableInputStream);
wrapper.init(input);
return wrapper;
}
// Check that files can be read from after closing zipreader
function run_test() {
const Cc = Components.classes;
const Ci = Components.interfaces;
// the build script have created the zip we can test on in the current dir.
var file = do_get_file("data/test_bug333423.zip");
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipreader.open(file);
// do crc stuff
function check_archive_crc() {
zipreader.test(null);
return true;
}
do_check_true(check_archive_crc())
var entries = zipreader.findEntries(null);
var stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"))
var dirstream= wrapInputStream(zipreader.getInputStream("modules/libjar/test/"))
zipreader.close();
zipreader = null;
Components.utils.forceGC();
do_check_true(stream.read(1024).length > 0);
do_check_true(dirstream.read(100).length > 0);
}

View file

@ -0,0 +1,24 @@
// Should report file not found on non-existent files
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.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 = NetUtil.newChannel({
uri: spec + "file_that_isnt_in.archive",
loadUsingSystemPrincipal: true
});
try {
instr = channel.open2();
do_throw("Failed to report that file doesn't exist")
} catch (e) {
do_check_true(e.name == "NS_ERROR_FILE_NOT_FOUND")
}
}

View file

@ -0,0 +1,40 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
function run_test() {
var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
var tmpDir = dirService.get("TmpD", Ci.nsIFile);
var zipfile = do_get_file("data/test_umlaute.zip");
var testFile = tmpDir.clone();
testFile.append("test_\u00FC.txt");
if (testFile.exists()) {
testFile.remove(false);
}
var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(Ci.nsIZipReader);
zipreader.open(zipfile);
var entries = zipreader.findEntries(null);
do_check_true(entries.hasMore());
var entryName = entries.getNext();
do_check_eq(entryName, "test_\u00FC.txt");
do_check_true(zipreader.hasEntry(entryName));
var target = tmpDir.clone();
target.append(entryName);
target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0o640); // 0640
zipreader.extract(entryName, target);
var entry = zipreader.getEntry(entryName);
do_check_true(entry != null);
zipreader.test(entryName);
zipreader.close();
}

View file

@ -0,0 +1,12 @@
// Make sure uncompressed files pass crc
var Cc = Components.classes;
var Ci = Components.interfaces;
function run_test() {
var file = do_get_file("data/uncompressed.zip");
var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(Ci.nsIZipReader);
zipReader.open(file);
zipReader.test("hello");
zipReader.close();
}

View file

@ -0,0 +1,44 @@
[DEFAULT]
head =
tail =
skip-if = toolkit == 'android'
support-files =
data/empty
data/test_bug333423.zip
data/test_bug336691.zip
data/test_bug370103.jar
data/test_bug379841.zip
data/test_bug589292.zip
data/test_bug597702.zip
data/test_bug637286.zip
data/test_bug658093.zip
data/test_corrupt.zip
data/test_corrupt2.zip
data/test_corrupt3.zip
data/test_crx_dummy.crx
data/test_umlaute.zip
data/uncompressed.zip
[test_jarchannel.js]
skip-if = os == "mac"
[test_bug278262.js]
[test_bug333423.js]
[test_bug336691.js]
[test_bug370103.js]
[test_bug379841.js]
[test_bug407303.js]
[test_bug453254.js]
[test_bug458158.js]
[test_bug589292.js]
[test_bug597702.js]
[test_bug637286.js]
[test_bug658093.js]
[test_corrupt_536911.js]
[test_corrupt_541828.js]
[test_corrupt_1211262.js]
[test_crx.js]
[test_dirjar_bug525755.js]
[test_jarinput_stream_zipreader_reference.js]
[test_not_found.js]
[test_uncompressed.js]
[test_umlaute.js]