2015-09-21 20:53:01 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
2018-12-15 01:54:56 +03:00
|
|
|
/* eslint-env worker */
|
|
|
|
|
|
|
|
// This file expects utils.js to be included in its scope
|
|
|
|
/* import-globals-from ./util.js */
|
2015-09-21 20:53:01 +03:00
|
|
|
importScripts("util.js");
|
|
|
|
importScripts("test-vectors.js");
|
|
|
|
|
|
|
|
var window = this;
|
|
|
|
|
|
|
|
function finish(result) {
|
|
|
|
postMessage(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
function complete(test, valid) {
|
|
|
|
return function(x) {
|
|
|
|
if (valid) {
|
|
|
|
finish(valid(x));
|
|
|
|
} else {
|
|
|
|
finish(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function memcmp_complete(test, value) {
|
2018-12-14 03:44:52 +03:00
|
|
|
return function(x) {
|
2015-09-21 20:53:01 +03:00
|
|
|
finish(util.memcmp(x, value));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function error(test) {
|
2018-12-14 03:44:52 +03:00
|
|
|
return function(x) {
|
2015-09-21 20:53:01 +03:00
|
|
|
throw x;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-12-14 03:44:52 +03:00
|
|
|
onmessage = function(msg) {
|
2018-12-15 01:54:56 +03:00
|
|
|
// eslint-disable-next-line no-eval
|
2015-09-21 20:53:01 +03:00
|
|
|
var test = eval("(" + msg.data + ")");
|
|
|
|
|
|
|
|
try {
|
|
|
|
test.call({ complete: finish });
|
|
|
|
} catch (err) {
|
|
|
|
error(`Failed to run worker test: ${err}\n`);
|
|
|
|
}
|
|
|
|
};
|