diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /modules/libjar/test/chrome | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'modules/libjar/test/chrome')
-rw-r--r-- | modules/libjar/test/chrome/chrome.ini | 9 | ||||
-rw-r--r-- | modules/libjar/test/chrome/signed-added.zip | bin | 0 -> 2141 bytes | |||
-rw-r--r-- | modules/libjar/test/chrome/signed-badca.zip | bin | 0 -> 1964 bytes | |||
-rw-r--r-- | modules/libjar/test/chrome/signed-tampered.zip | bin | 0 -> 1979 bytes | |||
-rw-r--r-- | modules/libjar/test/chrome/signed.zip | bin | 0 -> 1957 bytes | |||
-rw-r--r-- | modules/libjar/test/chrome/test_bug386153.html | 97 | ||||
-rw-r--r-- | modules/libjar/test/chrome/unsigned.zip | bin | 0 -> 174 bytes |
7 files changed, 106 insertions, 0 deletions
diff --git a/modules/libjar/test/chrome/chrome.ini b/modules/libjar/test/chrome/chrome.ini new file mode 100644 index 000000000..b130cbc33 --- /dev/null +++ b/modules/libjar/test/chrome/chrome.ini @@ -0,0 +1,9 @@ +[DEFAULT] +support-files = + signed-added.zip + signed-badca.zip + signed-tampered.zip + signed.zip + unsigned.zip + +[test_bug386153.html] diff --git a/modules/libjar/test/chrome/signed-added.zip b/modules/libjar/test/chrome/signed-added.zip Binary files differnew file mode 100644 index 000000000..c90bc250a --- /dev/null +++ b/modules/libjar/test/chrome/signed-added.zip diff --git a/modules/libjar/test/chrome/signed-badca.zip b/modules/libjar/test/chrome/signed-badca.zip Binary files differnew file mode 100644 index 000000000..f493cbd1a --- /dev/null +++ b/modules/libjar/test/chrome/signed-badca.zip diff --git a/modules/libjar/test/chrome/signed-tampered.zip b/modules/libjar/test/chrome/signed-tampered.zip Binary files differnew file mode 100644 index 000000000..d3b9d16cc --- /dev/null +++ b/modules/libjar/test/chrome/signed-tampered.zip diff --git a/modules/libjar/test/chrome/signed.zip b/modules/libjar/test/chrome/signed.zip Binary files differnew file mode 100644 index 000000000..94e114783 --- /dev/null +++ b/modules/libjar/test/chrome/signed.zip diff --git a/modules/libjar/test/chrome/test_bug386153.html b/modules/libjar/test/chrome/test_bug386153.html new file mode 100644 index 000000000..3fe541a1a --- /dev/null +++ b/modules/libjar/test/chrome/test_bug386153.html @@ -0,0 +1,97 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=386153 +--> +<head> + <title>Test for Bug 386153</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=386153">Mozilla Bug 386153</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 386153 **/ + +const Cc = Components.classes; +const Ci = Components.interfaces; + +// Opens a zip file from the test directory. +function openZip(path) { + + var location = window.location.href; + location = getRootDirectory(location); + var jar = getJar(location); + if (jar != null) { + var resolved = extractJarToTmp(jar); + } else { + var resolvedURI = getResolvedURI(window.location.href); + var resolved = getChromeDir(resolvedURI); + } + resolved.append(path); + + var zip = Cc["@mozilla.org/libjar/zip-reader;1"]. + createInstance(Ci.nsIZipReader); + zip.open(resolved); + return zip; +} + +// Gets the pretty name from the signing cert or null if the zip is unsigned. +function getSigner(zip) { + var signingCert = zip.getSigningCert(null); + if (signingCert) { + return signingCert.organization; + } + return null; +} + +function verifySigning(zip) { + var signingCert = zip.getSigningCert(null); + var count = 0; + var entries = zip.findEntries(null); + while (entries.hasMore()) { + var entry = entries.getNext(); + // Nothing in META-INF is in the manifest. + if (entry.substr(0, 9) == "META-INF/") + continue; + // Directory entries aren't in the manifest. + if (entry.substr(-1) == "/") + continue; + count++; + var entryCert = zip.getSigningCert(entry); + if (!entryCert || !signingCert.equals(entryCert)) { + return false; + } + } + return zip.manifestEntriesCount == count; +} + +var zip = openZip("unsigned.zip"); +is(getSigner(zip), null, "Should not be signed"); + +zip = openZip("signed.zip"); +is(getSigner(zip), "Mozilla Testing", "Should be signed by the right cert"); +ok(verifySigning(zip), "Should be correctly signed"); + +zip = openZip("signed-added.zip"); +is(getSigner(zip), "Mozilla Testing", "Should be signed by the right cert"); +ok(!verifySigning(zip), "Should be incorrectly signed"); + +zip = openZip("signed-tampered.zip"); +is(getSigner(zip), "Mozilla Testing", "Should be signed by the right cert"); +ok(!verifySigning(zip), "Should be incorrectly signed"); + +zip = openZip("signed-badca.zip"); +is(getSigner(zip), null, "Should not appear to be signed"); + +</script> +</pre> +</body> +</html> diff --git a/modules/libjar/test/chrome/unsigned.zip b/modules/libjar/test/chrome/unsigned.zip Binary files differnew file mode 100644 index 000000000..f1e26b06a --- /dev/null +++ b/modules/libjar/test/chrome/unsigned.zip |