summaryrefslogtreecommitdiffstats
path: root/toolkit/components/lz4/tests/xpcshell/data
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/lz4/tests/xpcshell/data
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/lz4/tests/xpcshell/data')
-rw-r--r--toolkit/components/lz4/tests/xpcshell/data/chrome.manifest1
-rw-r--r--toolkit/components/lz4/tests/xpcshell/data/compression.lzbin23 -> 0 bytes
-rw-r--r--toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js146
3 files changed, 0 insertions, 147 deletions
diff --git a/toolkit/components/lz4/tests/xpcshell/data/chrome.manifest b/toolkit/components/lz4/tests/xpcshell/data/chrome.manifest
deleted file mode 100644
index e2f9a9d8e..000000000
--- a/toolkit/components/lz4/tests/xpcshell/data/chrome.manifest
+++ /dev/null
@@ -1 +0,0 @@
-content test_lz4 ./
diff --git a/toolkit/components/lz4/tests/xpcshell/data/compression.lz b/toolkit/components/lz4/tests/xpcshell/data/compression.lz
deleted file mode 100644
index a354edc03..000000000
--- a/toolkit/components/lz4/tests/xpcshell/data/compression.lz
+++ /dev/null
Binary files differ
diff --git a/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js b/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js
deleted file mode 100644
index 47e3ea369..000000000
--- a/toolkit/components/lz4/tests/xpcshell/data/worker_lz4.js
+++ /dev/null
@@ -1,146 +0,0 @@
-importScripts("resource://gre/modules/workers/require.js");
-importScripts("resource://gre/modules/osfile.jsm");
-
-
-function do_print(x) {
- // self.postMessage({kind: "do_print", args: [x]});
- dump("TEST-INFO: " + x + "\n");
-}
-
-function do_check_true(x) {
- self.postMessage({kind: "do_check_true", args: [!!x]});
- if (x) {
- dump("TEST-PASS: " + x + "\n");
- } else {
- throw new Error("do_check_true failed");
- }
-}
-
-function do_check_eq(a, b) {
- let result = a == b;
- self.postMessage({kind: "do_check_true", args: [result]});
- if (!result) {
- throw new Error("do_check_eq failed " + a + " != " + b);
- }
-}
-
-function do_test_complete() {
- self.postMessage({kind: "do_test_complete", args:[]});
-}
-
-self.onmessage = function() {
- try {
- run_test();
- } catch (ex) {
- let {message, moduleStack, moduleName, lineNumber} = ex;
- let error = new Error(message, moduleName, lineNumber);
- error.stack = moduleStack;
- dump("Uncaught error: " + error + "\n");
- dump("Full stack: " + moduleStack + "\n");
- throw error;
- }
-};
-
-var Lz4;
-var Internals;
-function test_import() {
- Lz4 = require("resource://gre/modules/lz4.js");
- Internals = require("resource://gre/modules/lz4_internal.js");
-}
-
-function test_bound() {
- for (let k of ["compress", "decompress", "maxCompressedSize"]) {
- try {
- do_print("Checking the existence of " + k + "\n");
- do_check_true(!!Internals[k]);
- do_print(k + " exists");
- } catch (ex) {
- // Ignore errors
- do_print(k + " doesn't exist!");
- }
- }
-}
-
-function test_reference_file() {
- do_print("Decompress reference file");
- let path = OS.Path.join("data", "compression.lz");
- let data = OS.File.read(path);
- let decompressed = Lz4.decompressFileContent(data);
- let text = (new TextDecoder()).decode(decompressed);
- do_check_eq(text, "Hello, lz4");
-}
-
-function compare_arrays(a, b) {
- return Array.prototype.join.call(a) == Array.prototype.join.call(a);
-}
-
-function run_rawcompression(name, array) {
- do_print("Raw compression test " + name);
- let length = array.byteLength;
- let compressedArray = new Uint8Array(Internals.maxCompressedSize(length));
- let compressedBytes = Internals.compress(array, length, compressedArray);
- compressedArray = new Uint8Array(compressedArray.buffer, 0, compressedBytes);
- do_print("Raw compressed: " + length + " into " + compressedBytes);
-
- let decompressedArray = new Uint8Array(length);
- let decompressedBytes = new ctypes.size_t();
- let success = Internals.decompress(compressedArray, compressedBytes,
- decompressedArray, length,
- decompressedBytes.address());
- do_print("Raw decompression success? " + success);
- do_print("Raw decompression size: " + decompressedBytes.value);
- do_check_true(compare_arrays(array, decompressedArray));
-}
-
-function run_filecompression(name, array) {
- do_print("File compression test " + name);
- let compressed = Lz4.compressFileContent(array);
- do_print("Compressed " + array.byteLength + " bytes into " + compressed.byteLength);
-
- let decompressed = Lz4.decompressFileContent(compressed);
- do_print("Decompressed " + compressed.byteLength + " bytes into " + decompressed.byteLength);
- do_check_true(compare_arrays(array, decompressed));
-}
-
-function run_faileddecompression(name, array) {
- do_print("invalid decompression test " + name);
-
- // Ensure that raw decompression doesn't segfault
- let length = 1 << 14;
- let decompressedArray = new Uint8Array(length);
- let decompressedBytes = new ctypes.size_t();
- Internals.decompress(array, array.byteLength,
- decompressedArray, length,
- decompressedBytes.address());
-
- // File decompression should fail with an acceptable exception
- let exn = null;
- try {
- Lz4.decompressFileContent(array);
- } catch (ex) {
- exn = ex;
- }
- do_check_true(exn);
- if (array.byteLength < 10) {
- do_check_true(exn.becauseLZNoHeader);
- } else {
- do_check_true(exn.becauseLZWrongMagicNumber);
- }
-}
-
-function run_test() {
- test_import();
- test_bound();
- test_reference_file();
- for (let length of [0, 1, 1024]) {
- let array = new Uint8Array(length);
- for (let i = 0; i < length; ++i) {
- array[i] = i % 256;
- }
- let name = length + " bytes";
- run_rawcompression(name, array);
- run_filecompression(name, array);
- run_faileddecompression(name, array);
- }
- do_test_complete();
-}