summaryrefslogtreecommitdiffstats
path: root/toolkit/components/promiseworker
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/promiseworker
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/promiseworker')
-rw-r--r--toolkit/components/promiseworker/moz.build13
-rw-r--r--toolkit/components/promiseworker/tests/xpcshell/.eslintrc.js7
-rw-r--r--toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest1
-rw-r--r--toolkit/components/promiseworker/tests/xpcshell/data/worker.js34
-rw-r--r--toolkit/components/promiseworker/tests/xpcshell/test_Promise.js117
-rw-r--r--toolkit/components/promiseworker/tests/xpcshell/xpcshell.ini9
6 files changed, 2 insertions, 179 deletions
diff --git a/toolkit/components/promiseworker/moz.build b/toolkit/components/promiseworker/moz.build
index 44a90e679..1c771464d 100644
--- a/toolkit/components/promiseworker/moz.build
+++ b/toolkit/components/promiseworker/moz.build
@@ -4,15 +4,6 @@
# 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/.
-DIRS += [
- 'worker'
-]
+DIRS += ['worker']
-EXTRA_JS_MODULES += [
- 'PromiseWorker.jsm',
-]
-
-XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
-
-with Files('**'):
- BUG_COMPONENT = ('Toolkit', 'Async Tooling')
+EXTRA_JS_MODULES += ['PromiseWorker.jsm']
diff --git a/toolkit/components/promiseworker/tests/xpcshell/.eslintrc.js b/toolkit/components/promiseworker/tests/xpcshell/.eslintrc.js
deleted file mode 100644
index d35787cd2..000000000
--- a/toolkit/components/promiseworker/tests/xpcshell/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
- "extends": [
- "../../../../../testing/xpcshell/xpcshell.eslintrc.js"
- ]
-};
diff --git a/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest b/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest
deleted file mode 100644
index 9e5dd29b2..000000000
--- a/toolkit/components/promiseworker/tests/xpcshell/data/chrome.manifest
+++ /dev/null
@@ -1 +0,0 @@
-content promiseworker ./
diff --git a/toolkit/components/promiseworker/tests/xpcshell/data/worker.js b/toolkit/components/promiseworker/tests/xpcshell/data/worker.js
deleted file mode 100644
index b4750788b..000000000
--- a/toolkit/components/promiseworker/tests/xpcshell/data/worker.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-// Trivial worker definition
-
-importScripts("resource://gre/modules/workers/require.js");
-var PromiseWorker = require("resource://gre/modules/workers/PromiseWorker.js");
-
-var worker = new PromiseWorker.AbstractWorker();
-worker.dispatch = function(method, args = []) {
- return Agent[method](...args);
-},
-worker.postMessage = function(...args) {
- self.postMessage(...args);
-};
-worker.close = function() {
- self.close();
-};
-worker.log = function(...args) {
- dump("Worker: " + args.join(" ") + "\n");
-};
-self.addEventListener("message", msg => worker.handleMessage(msg));
-
-var Agent = {
- bounce: function(...args) {
- return args;
- },
-
- throwError: function(msg, ...args) {
- throw new Error(msg);
- },
-};
diff --git a/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js b/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
deleted file mode 100644
index 70f49e92e..000000000
--- a/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-var Cu = Components.utils;
-
-Cu.import("resource://gre/modules/PromiseWorker.jsm", this);
-Cu.import("resource://gre/modules/Timer.jsm", this);
-
-// Worker must be loaded from a chrome:// uri, not a file://
-// uri, so we first need to load it.
-
-var WORKER_SOURCE_URI = "chrome://promiseworker/content/worker.js";
-do_load_manifest("data/chrome.manifest");
-var worker = new BasePromiseWorker(WORKER_SOURCE_URI);
-worker.log = function(...args) {
- do_print("Controller: " + args.join(" "));
-};
-
-// Test that simple messages work
-add_task(function* test_simple_args() {
- let message = ["test_simple_args", Math.random()];
- let result = yield worker.post("bounce", message);
- Assert.equal(JSON.stringify(result), JSON.stringify(message));
-});
-
-// Test that it works when we don't provide a message
-add_task(function* test_no_args() {
- let result = yield worker.post("bounce");
- Assert.equal(JSON.stringify(result), JSON.stringify([]));
-});
-
-// Test that messages with promise work
-add_task(function* test_promise_args() {
- let message = ["test_promise_args", Promise.resolve(Math.random())];
- let stringified = JSON.stringify((yield Promise.resolve(Promise.all(message))));
- let result = yield worker.post("bounce", message);
- Assert.equal(JSON.stringify(result), stringified);
-});
-
-// Test that messages with delayed promise work
-add_task(function* test_delayed_promise_args() {
- let promise = new Promise(resolve => setTimeout(() => resolve(Math.random()), 10));
- let message = ["test_delayed_promise_args", promise];
- let stringified = JSON.stringify((yield Promise.resolve(Promise.all(message))));
- let result = yield worker.post("bounce", message);
- Assert.equal(JSON.stringify(result), stringified);
-});
-
-// Test that messages with rejected promise cause appropriate errors
-add_task(function* test_rejected_promise_args() {
- let error = new Error();
- let message = ["test_promise_args", Promise.reject(error)];
- try {
- yield worker.post("bounce", message);
- do_throw("I shound have thrown an error by now");
- } catch (ex) {
- if (ex != error)
- throw ex;
- do_print("I threw the right error");
- }
-});
-
-// Test that we can transfer to the worker using argument `transfer`
-add_task(function* test_transfer_args() {
- let array = new Uint8Array(4);
- for (let i = 0; i < 4; ++i) {
- array[i] = i;
- }
- Assert.equal(array.buffer.byteLength, 4, "The buffer is not detached yet");
-
- let result = (yield worker.post("bounce", [array.buffer], [], [array.buffer]))[0];
-
- // Check that the buffer has been sent
- Assert.equal(array.buffer.byteLength, 0, "The buffer has been detached");
-
- // Check that the result is correct
- Assert.equal(result.byteLength, 4, "The result has the right size");
- let array2 = new Uint8Array(result);
- for (let i = 0; i < 4; ++i) {
- Assert.equal(array2[i], i);
- }
-});
-
-// Test that we can transfer to the worker using an instance of `Meta`
-add_task(function* test_transfer_with_meta() {
- let array = new Uint8Array(4);
- for (let i = 0; i < 4; ++i) {
- array[i] = i;
- }
- Assert.equal(array.buffer.byteLength, 4, "The buffer is not detached yet");
-
- let message = new BasePromiseWorker.Meta(array, {transfers: [array.buffer]});
- let result = (yield worker.post("bounce", [message]))[0];
-
- // Check that the buffer has been sent
- Assert.equal(array.buffer.byteLength, 0, "The buffer has been detached");
-
- // Check that the result is correct
- Assert.equal(Object.prototype.toString.call(result), "[object Uint8Array]",
- "The result appears to be a Typed Array");
- Assert.equal(result.byteLength, 4, "The result has the right size");
-
- for (let i = 0; i < 4; ++i) {
- Assert.equal(result[i], i);
- }
-});
-
-add_task(function* test_throw_error() {
- try {
- yield worker.post("throwError", ["error message"]);
- Assert.ok(false, "should have thrown");
- } catch (ex) {
- Assert.equal(ex.message, "Error: error message");
- }
-});
diff --git a/toolkit/components/promiseworker/tests/xpcshell/xpcshell.ini b/toolkit/components/promiseworker/tests/xpcshell/xpcshell.ini
deleted file mode 100644
index 1efcd8c9e..000000000
--- a/toolkit/components/promiseworker/tests/xpcshell/xpcshell.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[DEFAULT]
-head=
-tail=
-skip-if = toolkit == 'android'
-support-files=
- data/worker.js
- data/chrome.manifest
-
-[test_Promise.js]