diff options
author | Jack Moffitt <jack@metajack.im> | 2014-08-28 09:34:23 -0600 |
---|---|---|
committer | Jack Moffitt <jack@metajack.im> | 2014-09-08 20:21:42 -0600 |
commit | c6ab60dbfc6da7b4f800c9e40893c8b58413960c (patch) | |
tree | d1d74076cf7fa20e4f77ec7cb82cae98b67362cb /src/test/content/harness.js | |
parent | db2f642c32fc5bed445bb6f2e45b0f6f0b4342cf (diff) | |
download | servo-c6ab60dbfc6da7b4f800c9e40893c8b58413960c.tar.gz servo-c6ab60dbfc6da7b4f800c9e40893c8b58413960c.zip |
Cargoify servo
Diffstat (limited to 'src/test/content/harness.js')
-rw-r--r-- | src/test/content/harness.js | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/src/test/content/harness.js b/src/test/content/harness.js deleted file mode 100644 index 7dafac00b6e..00000000000 --- a/src/test/content/harness.js +++ /dev/null @@ -1,92 +0,0 @@ -function _oneline(x) { - var i = x.indexOf("\n"); - return (i == -1) ? x : (x.slice(0, i) + "..."); -} - -var _expectations = 0; -var _tests = 0; -function expect(num) { - _expectations = num; -} - -function _fail(s, m) { - _tests++; - // string split to avoid problems with tests that end up printing the value of window._fail. - window.alert(_oneline("TEST-UNEXPECTED" + "-FAIL | " + s + ": " + m)); -} - -function _pass(s, m) { - _tests++; - window.alert(_oneline("TEST-PASS | " + s + ": " + m)); -} - -function _printer(opstr, op) { - return function (a, b, msg) { - let f = op(a,b) ? _pass : _fail; - if (!msg) msg = ""; - f(a + " " + opstr + " " + b, msg); - }; -} - -var is = _printer("===", function (a,b) { return a === b; }); -var is_not = _printer("!==", function (a,b) { return a !== b; }); -var is_a = _printer("is a", function (a,b) { return a instanceof b; }); -var is_not_a = _printer("is not a", function (a,b) { return !(a instanceof b); }); -var is_in = _printer("is in", function (a,b) { return a in b; }); -var is_not_in = _printer("is not in", function (a,b) { return !(a in b); }); -var as_str_is = _printer("as string is", function (a,b) { return String(a) == b; }); -var lt = _printer("<", function (a,b) { return a < b; }); -var gt = _printer(">", function (a,b) { return a > b; }); -var leq = _printer("<=", function (a,b) { return a <= b; }); -var geq = _printer(">=", function (a,b) { return a >= b; }); -var starts_with = _printer("starts with", function (a,b) { return a.indexOf(b) == 0; }); - -function is_function(val, name) { - starts_with(String(val), "function " + name + "("); -} - -function should_throw(f) { - try { - f(); - _fail("operation should have thrown but did not"); - } catch (x) { - _pass("operation successfully threw an exception", x.toString()); - } -} - -function should_not_throw(f) { - try { - f(); - _pass("operation did not throw an exception"); - } catch (x) { - _fail("operation should have not thrown", x.toString()); - } -} - -function check_selector(elem, selector, matches) { - is(elem.matches(selector), matches); -} - -function check_disabled_selector(elem, disabled) { - check_selector(elem, ":disabled", disabled); - check_selector(elem, ":enabled", !disabled); -} - -var _test_complete = false; -var _test_timeout = 10000; //10 seconds -function finish() { - if (_expectations > _tests) { - _fail('expected ' + _expectations + ' tests, fullfilled ' + _tests); - } - _test_complete = true; - window.close(); -} - -function _test_timed_out() { - if (!_test_complete) { - _fail('test timed out (' + _test_timeout/1000 + 's)'); - finish(); - } -} - -setTimeout(_test_timed_out, _test_timeout); |