mirror of
https://github.com/servo/servo.git
synced 2025-08-22 13:55:34 +01:00
Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317
This commit is contained in:
parent
aa199307c8
commit
2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions
|
@ -6,7 +6,7 @@ The test suite for the `testharness.js` testing framework.
|
|||
|
||||
Install the following dependencies:
|
||||
|
||||
- [Python 2.7](https://www.python.org/)
|
||||
- [Python 2.7.9+](https://www.python.org/)
|
||||
- [the tox Python package](https://tox.readthedocs.io/en/latest/)
|
||||
- [the Mozilla Firefox web browser](https://mozilla.org/firefox)
|
||||
- [the GeckoDriver server](https://github.com/mozilla/geckodriver)
|
||||
|
@ -64,4 +64,4 @@ string within a `<script>` tag with an `id` of `"expected"`, e.g.:
|
|||
</script>
|
||||
|
||||
This is useful to test, for example, whether asserations that should fail or
|
||||
throw actually do.
|
||||
throw actually do.
|
||||
|
|
|
@ -1,462 +1,462 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML5 API Tests</title>
|
||||
<meta name="timeout" content="6000">
|
||||
</head>
|
||||
<body onload="load_test_attr.done()">
|
||||
<h1>Sample HTML5 API Tests</h1>
|
||||
<div id="log"></div>
|
||||
<script src="../../testharness.js"></script>
|
||||
<script src="../../testharnessreport.js"></script>
|
||||
<script>
|
||||
setup_run = false;
|
||||
setup(function() {
|
||||
setup_run = true;
|
||||
});
|
||||
test(function() {assert_true(setup_run)}, "Setup function ran");
|
||||
|
||||
// Two examples for testing events from handler and attributes
|
||||
var load_test_event = async_test("window onload event fires when set from the handler");
|
||||
|
||||
function windowLoad()
|
||||
{
|
||||
load_test_event.done();
|
||||
}
|
||||
on_event(window, "load", windowLoad);
|
||||
|
||||
// see the body onload below
|
||||
var load_test_attr = async_test("body element fires the onload event set from the attribute");
|
||||
</script>
|
||||
<script>
|
||||
function bodyElement()
|
||||
{
|
||||
assert_equals(document.body, document.getElementsByTagName("body")[0]);
|
||||
}
|
||||
test(bodyElement, "document.body should be the first body element in the document");
|
||||
|
||||
test(function() {
|
||||
assert_equals(1,1);
|
||||
assert_equals(NaN, NaN, "NaN case");
|
||||
assert_equals(0, 0, "Zero case");
|
||||
}, "assert_equals tests")
|
||||
|
||||
test(function() {
|
||||
assert_equals(-0, 0, "Zero case");
|
||||
}, "assert_equals tests expected to fail")
|
||||
|
||||
test(function() {
|
||||
assert_not_equals({}, {}, "object case");
|
||||
assert_not_equals(-0, 0, "Zero case");
|
||||
}, "assert_not_equals tests")
|
||||
|
||||
function testAssertPass()
|
||||
{
|
||||
assert_true(true);
|
||||
}
|
||||
test(testAssertPass, "assert_true expected to pass");
|
||||
|
||||
function testAssertFalse()
|
||||
{
|
||||
assert_true(false, "false should not be true");
|
||||
}
|
||||
test(testAssertFalse, "assert_true expected to fail");
|
||||
|
||||
function basicAssertArrayEquals()
|
||||
{
|
||||
assert_array_equals([1, NaN], [1, NaN], "[1, NaN] is equal to [1, NaN]");
|
||||
}
|
||||
test(basicAssertArrayEquals, "basic assert_array_equals test");
|
||||
|
||||
function assertArrayEqualsUndefined()
|
||||
{
|
||||
assert_array_equals(undefined, [1], "undefined equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsUndefined, "assert_array_equals with first param undefined");
|
||||
|
||||
function assertArrayEqualsTrue()
|
||||
{
|
||||
assert_array_equals(true, [1], "true equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsTrue, "assert_array_equals with first param true");
|
||||
|
||||
function assertArrayEqualsFalse()
|
||||
{
|
||||
assert_array_equals(false, [1], "false equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsFalse, "assert_array_equals with first param false");
|
||||
|
||||
function assertArrayEqualsNull()
|
||||
{
|
||||
assert_array_equals(null, [1], "null equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsNull, "assert_array_equals with first param null");
|
||||
|
||||
function assertArrayEqualsNumeric()
|
||||
{
|
||||
assert_array_equals(1, [1], "1 equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsNumeric, "assert_array_equals with first param 1");
|
||||
|
||||
function basicAssertObjectEquals()
|
||||
{
|
||||
assert_object_equals([1, 2, [1, 2]], { 0: 1, 1: 2, 2: { 0: 1, 1: 2} }, "array is equal to object")
|
||||
}
|
||||
test(basicAssertObjectEquals, "basic assert_object_equals test");
|
||||
|
||||
function basicAssertArrayApproxEquals()
|
||||
{
|
||||
assert_array_approx_equals([10, 11], [11, 10], 1, "[10, 11] is approximately (+/- 1) [11, 10]")
|
||||
}
|
||||
test(basicAssertArrayApproxEquals, "basic assert_array_approx_equals test");
|
||||
|
||||
function basicAssertApproxEquals()
|
||||
{
|
||||
assert_approx_equals(10, 11, 1, "10 is approximately (+/- 1) 11")
|
||||
}
|
||||
test(basicAssertApproxEquals, "basic assert_approx_equals test");
|
||||
|
||||
function basicAssertLessThan()
|
||||
{
|
||||
assert_less_than(10, 11, "10 is less than 11")
|
||||
}
|
||||
test(basicAssertApproxEquals, "basic assert_less_than test");
|
||||
|
||||
function basicAssertGreaterThan()
|
||||
{
|
||||
assert_greater_than(10, 11, "10 is not greater than 11");
|
||||
}
|
||||
test(basicAssertGreaterThan, "assert_greater_than expected to fail");
|
||||
|
||||
function basicAssertGreaterThanEqual()
|
||||
{
|
||||
assert_greater_than_equal(10, 10, "10 is greater than or equal to 10")
|
||||
}
|
||||
test(basicAssertGreaterThanEqual, "basic assert_greater_than_equal test");
|
||||
|
||||
function basicAssertLessThanEqual()
|
||||
{
|
||||
assert_greater_than_equal('10', 10, "'10' is not a number")
|
||||
}
|
||||
test(basicAssertLessThanEqual, "assert_less_than_equal expected to fail");
|
||||
|
||||
function testAssertInherits() {
|
||||
var A = function(){this.a = "a"}
|
||||
A.prototype = {b:"b"}
|
||||
var a = new A();
|
||||
assert_exists(a, "a");
|
||||
assert_not_exists(a, "b");
|
||||
assert_inherits(a, "b");
|
||||
}
|
||||
test(testAssertInherits, "test for assert[_not]_exists and insert_inherits")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var a = document.createElement("a")
|
||||
var b = document.createElement("b")
|
||||
assert_throws("NOT_FOUND_ERR", function () {a.removeChild(b)});
|
||||
}, "Test throw DOM exception")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var a = document.createTextNode("a")
|
||||
var b = document.createElement("b")
|
||||
assert_throws("NOT_FOUND_ERR", function () {a.appendChild(b)});
|
||||
}, "Test throw DOM exception expected to fail")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var e = {code:0, name:"TEST_ERR", TEST_ERR:0}
|
||||
assert_throws("TEST_ERR", function() {throw e});
|
||||
}, "Test assert_throws with non-DOM-exception expected to Fail");
|
||||
|
||||
var t = async_test("Test step_func")
|
||||
setTimeout(
|
||||
t.step_func(
|
||||
function () {
|
||||
assert_true(true); t.done();
|
||||
}), 0);
|
||||
|
||||
async_test(function(t) {
|
||||
setTimeout(t.step_func(function (){assert_true(true); t.done();}), 0);
|
||||
}, "Test async test with callback");
|
||||
|
||||
async_test(function() {
|
||||
setTimeout(this.step_func(function (){assert_true(true); this.done();}), 0);
|
||||
}, "Test async test with callback and `this` obj.");
|
||||
|
||||
async_test("test should timeout (fail) with the default of 2 seconds").step(function(){});
|
||||
|
||||
async_test("test should timeout (fail) with a custom set timeout value of 1 second",
|
||||
{timeout:1000}).step(function(){});
|
||||
|
||||
async_test("async test that is never started, should have status Not Run", {timeout:1000});
|
||||
|
||||
|
||||
test(function(t) {
|
||||
window.global = 1;
|
||||
t.add_cleanup(function() {delete window.global});
|
||||
assert_equals(window.global, 1);
|
||||
},
|
||||
"Test that defines a global and cleans it up");
|
||||
|
||||
test(function() {assert_equals(window.global, undefined)},
|
||||
"Test that cleanup handlers from previous test ran");
|
||||
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
"summarized_status": {
|
||||
"status_string": "TIMEOUT",
|
||||
"message": null,
|
||||
"stack": null
|
||||
},
|
||||
"summarized_tests": [
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Setup function ran",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "Test assert_throws with non-DOM-exception expected to Fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "Test bug: unrecognized DOMException code \"TEST_ERR\" passed to assert_throws()",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test async test with callback",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test async test with callback and `this` obj.",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test step_func",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test that cleanup handlers from previous test ran",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test that defines a global and cleans it up",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test throw DOM exception",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "Test throw DOM exception expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_throws: function \"function () {a.appendChild(b)}\" threw object \"HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy\" that is not a DOMException NOT_FOUND_ERR: property \"code\" is equal to 3, expected 8",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param 1",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: 1 equals [1]? value is 1, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param false",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: false equals [1]? value is false, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param null",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: null equals [1]? value is null, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param true",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: true equals [1]? value is true, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param undefined",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: undefined equals [1]? value is undefined, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_equals tests",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_equals tests expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_equals: Zero case expected 0 but got -0",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_greater_than expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_greater_than: 10 is not greater than 11 expected a number greater than 11 but got 10",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_less_than_equal expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_greater_than_equal: '10' is not a number expected a number but got a \"string\"",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_not_equals tests",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_true expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_true: false should not be true expected true got false",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_true expected to pass",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "NOTRUN",
|
||||
"name": "async test that is never started, should have status Not Run",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {
|
||||
"timeout": 1000
|
||||
}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_approx_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_array_approx_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_array_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_greater_than_equal test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_less_than test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_object_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "body element fires the onload event set from the attribute",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "document.body should be the first body element in the document",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "test for assert[_not]_exists and insert_inherits",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "test should timeout (fail) with a custom set timeout value of 1 second",
|
||||
"stack": null,
|
||||
"message": "Test timed out",
|
||||
"properties": {
|
||||
"timeout": 1000
|
||||
}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "test should timeout (fail) with the default of 2 seconds",
|
||||
"stack": null,
|
||||
"message": "Test timed out",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "window onload event fires when set from the handler",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"type": "complete"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML5 API Tests</title>
|
||||
<meta name="timeout" content="6000">
|
||||
</head>
|
||||
<body onload="load_test_attr.done()">
|
||||
<h1>Sample HTML5 API Tests</h1>
|
||||
<div id="log"></div>
|
||||
<script src="../../testharness.js"></script>
|
||||
<script src="../../testharnessreport.js"></script>
|
||||
<script>
|
||||
setup_run = false;
|
||||
setup(function() {
|
||||
setup_run = true;
|
||||
});
|
||||
test(function() {assert_true(setup_run)}, "Setup function ran");
|
||||
|
||||
// Two examples for testing events from handler and attributes
|
||||
var load_test_event = async_test("window onload event fires when set from the handler");
|
||||
|
||||
function windowLoad()
|
||||
{
|
||||
load_test_event.done();
|
||||
}
|
||||
on_event(window, "load", windowLoad);
|
||||
|
||||
// see the body onload below
|
||||
var load_test_attr = async_test("body element fires the onload event set from the attribute");
|
||||
</script>
|
||||
<script>
|
||||
function bodyElement()
|
||||
{
|
||||
assert_equals(document.body, document.getElementsByTagName("body")[0]);
|
||||
}
|
||||
test(bodyElement, "document.body should be the first body element in the document");
|
||||
|
||||
test(function() {
|
||||
assert_equals(1,1);
|
||||
assert_equals(NaN, NaN, "NaN case");
|
||||
assert_equals(0, 0, "Zero case");
|
||||
}, "assert_equals tests")
|
||||
|
||||
test(function() {
|
||||
assert_equals(-0, 0, "Zero case");
|
||||
}, "assert_equals tests expected to fail")
|
||||
|
||||
test(function() {
|
||||
assert_not_equals({}, {}, "object case");
|
||||
assert_not_equals(-0, 0, "Zero case");
|
||||
}, "assert_not_equals tests")
|
||||
|
||||
function testAssertPass()
|
||||
{
|
||||
assert_true(true);
|
||||
}
|
||||
test(testAssertPass, "assert_true expected to pass");
|
||||
|
||||
function testAssertFalse()
|
||||
{
|
||||
assert_true(false, "false should not be true");
|
||||
}
|
||||
test(testAssertFalse, "assert_true expected to fail");
|
||||
|
||||
function basicAssertArrayEquals()
|
||||
{
|
||||
assert_array_equals([1, NaN], [1, NaN], "[1, NaN] is equal to [1, NaN]");
|
||||
}
|
||||
test(basicAssertArrayEquals, "basic assert_array_equals test");
|
||||
|
||||
function assertArrayEqualsUndefined()
|
||||
{
|
||||
assert_array_equals(undefined, [1], "undefined equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsUndefined, "assert_array_equals with first param undefined");
|
||||
|
||||
function assertArrayEqualsTrue()
|
||||
{
|
||||
assert_array_equals(true, [1], "true equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsTrue, "assert_array_equals with first param true");
|
||||
|
||||
function assertArrayEqualsFalse()
|
||||
{
|
||||
assert_array_equals(false, [1], "false equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsFalse, "assert_array_equals with first param false");
|
||||
|
||||
function assertArrayEqualsNull()
|
||||
{
|
||||
assert_array_equals(null, [1], "null equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsNull, "assert_array_equals with first param null");
|
||||
|
||||
function assertArrayEqualsNumeric()
|
||||
{
|
||||
assert_array_equals(1, [1], "1 equals [1]?");
|
||||
}
|
||||
test(assertArrayEqualsNumeric, "assert_array_equals with first param 1");
|
||||
|
||||
function basicAssertObjectEquals()
|
||||
{
|
||||
assert_object_equals([1, 2, [1, 2]], { 0: 1, 1: 2, 2: { 0: 1, 1: 2} }, "array is equal to object")
|
||||
}
|
||||
test(basicAssertObjectEquals, "basic assert_object_equals test");
|
||||
|
||||
function basicAssertArrayApproxEquals()
|
||||
{
|
||||
assert_array_approx_equals([10, 11], [11, 10], 1, "[10, 11] is approximately (+/- 1) [11, 10]")
|
||||
}
|
||||
test(basicAssertArrayApproxEquals, "basic assert_array_approx_equals test");
|
||||
|
||||
function basicAssertApproxEquals()
|
||||
{
|
||||
assert_approx_equals(10, 11, 1, "10 is approximately (+/- 1) 11")
|
||||
}
|
||||
test(basicAssertApproxEquals, "basic assert_approx_equals test");
|
||||
|
||||
function basicAssertLessThan()
|
||||
{
|
||||
assert_less_than(10, 11, "10 is less than 11")
|
||||
}
|
||||
test(basicAssertApproxEquals, "basic assert_less_than test");
|
||||
|
||||
function basicAssertGreaterThan()
|
||||
{
|
||||
assert_greater_than(10, 11, "10 is not greater than 11");
|
||||
}
|
||||
test(basicAssertGreaterThan, "assert_greater_than expected to fail");
|
||||
|
||||
function basicAssertGreaterThanEqual()
|
||||
{
|
||||
assert_greater_than_equal(10, 10, "10 is greater than or equal to 10")
|
||||
}
|
||||
test(basicAssertGreaterThanEqual, "basic assert_greater_than_equal test");
|
||||
|
||||
function basicAssertLessThanEqual()
|
||||
{
|
||||
assert_greater_than_equal('10', 10, "'10' is not a number")
|
||||
}
|
||||
test(basicAssertLessThanEqual, "assert_less_than_equal expected to fail");
|
||||
|
||||
function testAssertInherits() {
|
||||
var A = function(){this.a = "a"}
|
||||
A.prototype = {b:"b"}
|
||||
var a = new A();
|
||||
assert_exists(a, "a");
|
||||
assert_not_exists(a, "b");
|
||||
assert_inherits(a, "b");
|
||||
}
|
||||
test(testAssertInherits, "test for assert[_not]_exists and insert_inherits")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var a = document.createElement("a")
|
||||
var b = document.createElement("b")
|
||||
assert_throws("NOT_FOUND_ERR", function () {a.removeChild(b)});
|
||||
}, "Test throw DOM exception")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var a = document.createTextNode("a")
|
||||
var b = document.createElement("b")
|
||||
assert_throws("NOT_FOUND_ERR", function () {a.appendChild(b)});
|
||||
}, "Test throw DOM exception expected to fail")
|
||||
|
||||
test(function()
|
||||
{
|
||||
var e = {code:0, name:"TEST_ERR", TEST_ERR:0}
|
||||
assert_throws("TEST_ERR", function() {throw e});
|
||||
}, "Test assert_throws with non-DOM-exception expected to Fail");
|
||||
|
||||
var t = async_test("Test step_func")
|
||||
setTimeout(
|
||||
t.step_func(
|
||||
function () {
|
||||
assert_true(true); t.done();
|
||||
}), 0);
|
||||
|
||||
async_test(function(t) {
|
||||
setTimeout(t.step_func(function (){assert_true(true); t.done();}), 0);
|
||||
}, "Test async test with callback");
|
||||
|
||||
async_test(function() {
|
||||
setTimeout(this.step_func(function (){assert_true(true); this.done();}), 0);
|
||||
}, "Test async test with callback and `this` obj.");
|
||||
|
||||
async_test("test should timeout (fail) with the default of 2 seconds").step(function(){});
|
||||
|
||||
async_test("test should timeout (fail) with a custom set timeout value of 1 second",
|
||||
{timeout:1000}).step(function(){});
|
||||
|
||||
async_test("async test that is never started, should have status Not Run", {timeout:1000});
|
||||
|
||||
|
||||
test(function(t) {
|
||||
window.global = 1;
|
||||
t.add_cleanup(function() {delete window.global});
|
||||
assert_equals(window.global, 1);
|
||||
},
|
||||
"Test that defines a global and cleans it up");
|
||||
|
||||
test(function() {assert_equals(window.global, undefined)},
|
||||
"Test that cleanup handlers from previous test ran");
|
||||
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
"summarized_status": {
|
||||
"status_string": "TIMEOUT",
|
||||
"message": null,
|
||||
"stack": null
|
||||
},
|
||||
"summarized_tests": [
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Setup function ran",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "Test assert_throws with non-DOM-exception expected to Fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "Test bug: unrecognized DOMException code \"TEST_ERR\" passed to assert_throws()",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test async test with callback",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test async test with callback and `this` obj.",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test step_func",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test that cleanup handlers from previous test ran",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test that defines a global and cleans it up",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "Test throw DOM exception",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "Test throw DOM exception expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_throws: function \"function () {a.appendChild(b)}\" threw object \"HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy\" that is not a DOMException NOT_FOUND_ERR: property \"code\" is equal to 3, expected 8",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param 1",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: 1 equals [1]? value is 1, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param false",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: false equals [1]? value is false, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param null",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: null equals [1]? value is null, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param true",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: true equals [1]? value is true, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_array_equals with first param undefined",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_array_equals: undefined equals [1]? value is undefined, expected array",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_equals tests",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_equals tests expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_equals: Zero case expected 0 but got -0",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_greater_than expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_greater_than: 10 is not greater than 11 expected a number greater than 11 but got 10",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_less_than_equal expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_greater_than_equal: '10' is not a number expected a number but got a \"string\"",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_not_equals tests",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "FAIL",
|
||||
"name": "assert_true expected to fail",
|
||||
"stack": "(implementation-defined)",
|
||||
"message": "assert_true: false should not be true expected true got false",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "assert_true expected to pass",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "NOTRUN",
|
||||
"name": "async test that is never started, should have status Not Run",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {
|
||||
"timeout": 1000
|
||||
}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_approx_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_array_approx_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_array_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_greater_than_equal test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_less_than test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "basic assert_object_equals test",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "body element fires the onload event set from the attribute",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "document.body should be the first body element in the document",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "test for assert[_not]_exists and insert_inherits",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "test should timeout (fail) with a custom set timeout value of 1 second",
|
||||
"stack": null,
|
||||
"message": "Test timed out",
|
||||
"properties": {
|
||||
"timeout": 1000
|
||||
}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "test should timeout (fail) with the default of 2 seconds",
|
||||
"stack": null,
|
||||
"message": "Test timed out",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "PASS",
|
||||
"name": "window onload event fires when set from the handler",
|
||||
"stack": null,
|
||||
"message": null,
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"type": "complete"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<title>Sample HTML5 API Tests</title>
|
||||
</head>
|
||||
<body onload="load_test_attr.done()">
|
||||
<body>
|
||||
<h1>Sample HTML5 API Tests</h1>
|
||||
<p>There should be two results</p>
|
||||
<div id="log"></div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</head>
|
||||
<script src="../../testharness.js"></script>
|
||||
|
||||
<body onload="load_test_attr.done()">
|
||||
<body>
|
||||
<h1>Sample HTML5 API Tests</h1>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test#force_timeout</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test#force_timeout</h1>
|
||||
<div id="log"></div>
|
||||
<script src="../../testharness.js"></script>
|
||||
<script src="../../testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({ explicit_timeout: true });
|
||||
|
||||
test(function(t) {
|
||||
t.force_timeout();
|
||||
}, 'test (synchronous)');
|
||||
|
||||
async_test(function(t) {
|
||||
t.step_timeout(function() {
|
||||
t.force_timeout();
|
||||
}, 0);
|
||||
}, 'async_test');
|
||||
|
||||
promise_test(function(t) {
|
||||
t.force_timeout();
|
||||
|
||||
return new Promise(function() {});
|
||||
}, 'promise_test');
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
"summarized_status": {
|
||||
"status_string": "OK",
|
||||
"message": null,
|
||||
"stack": null
|
||||
},
|
||||
"summarized_tests": [
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "async_test",
|
||||
"message": "Test timed out",
|
||||
"stack": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "promise_test",
|
||||
"message": "Test timed out",
|
||||
"stack": null,
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"status_string": "TIMEOUT",
|
||||
"name": "test (synchronous)",
|
||||
"message": "Test timed out",
|
||||
"stack": null,
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"type": "complete"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -10,34 +10,34 @@
|
|||
// generate_tests takes an array of arrays that define tests
|
||||
// but lets pass it an empty array and verify it does nothing.
|
||||
function null_callback() {
|
||||
throw "null_callback should not be called.";
|
||||
throw "null_callback should not be called.";
|
||||
}
|
||||
generate_tests(null_callback, []);
|
||||
|
||||
// Generate 3 tests specifying the name and one parameter
|
||||
function validate_arguments(arg1) {
|
||||
assert_equals(arg1, 1, "Ensure that we get our expected argument");
|
||||
assert_equals(arg1, 1, "Ensure that we get our expected argument");
|
||||
}
|
||||
generate_tests(validate_arguments, [
|
||||
["first test", 1],
|
||||
["second test", 1],
|
||||
["third test", 1],
|
||||
["first test", 1],
|
||||
["second test", 1],
|
||||
["third test", 1],
|
||||
]);
|
||||
|
||||
// Generate a test passing in a properties object that is shared across tests.
|
||||
function validate_properties() {
|
||||
assert_true(this.properties.sentinel, "Ensure that we got the right properties object.");
|
||||
assert_true(this.properties.sentinel, "Ensure that we got the right properties object.");
|
||||
}
|
||||
generate_tests(validate_properties, [["sentinel check 1"], ["sentinel check 2"]], {sentinel: true});
|
||||
|
||||
// Generate a test passing in a properties object that is shared across tests.
|
||||
function validate_separate_properties() {
|
||||
if (this.name === "sentinel check 1 unique properties") {
|
||||
assert_true(this.properties.sentinel, "Ensure that we got the right properties object. Expect sentinel: true.");
|
||||
}
|
||||
else {
|
||||
assert_false(this.properties.sentinel, "Ensure that we got the right properties object. Expect sentinel: false.");
|
||||
}
|
||||
if (this.name === "sentinel check 1 unique properties") {
|
||||
assert_true(this.properties.sentinel, "Ensure that we got the right properties object. Expect sentinel: true.");
|
||||
}
|
||||
else {
|
||||
assert_false(this.properties.sentinel, "Ensure that we got the right properties object. Expect sentinel: false.");
|
||||
}
|
||||
}
|
||||
generate_tests(validate_separate_properties, [["sentinel check 1 unique properties"], ["sentinel check 2 unique properties"]], [{sentinel: true}, {sentinel: false}]);
|
||||
|
||||
|
@ -45,10 +45,10 @@ generate_tests(validate_separate_properties, [["sentinel check 1 unique properti
|
|||
var letters = ["a", "b", "c", "d", "e", "f"];
|
||||
var numbers = [0, 1, 2, 3, 4, 5];
|
||||
function validate_related_arguments(arg1, arg2) {
|
||||
assert_equals(arg1.charCodeAt(0) - "a".charCodeAt(0), arg2, "Ensure that we can map letters to numbers.");
|
||||
assert_equals(arg1.charCodeAt(0) - "a".charCodeAt(0), arg2, "Ensure that we can map letters to numbers.");
|
||||
}
|
||||
function format_as_test(letter, index, letters) {
|
||||
return ["Test to map " + letter + " to " + numbers[index], letter, numbers[index]];
|
||||
return ["Test to map " + letter + " to " + numbers[index], letter, numbers[index]];
|
||||
}
|
||||
generate_tests(validate_related_arguments, letters.map(format_as_test));
|
||||
</script>
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
assert_false(idl.is_json_type(typeFrom("sequence<DOMException>")));
|
||||
assert_true(idl.is_json_type(typeFrom("sequence<DOMString>")));
|
||||
}, 'should handle sequences according to their inner types');
|
||||
|
||||
|
||||
test(function() {
|
||||
var idl = new IdlArray();
|
||||
assert_false(idl.is_json_type(typeFrom("FrozenArray<DOMException>")));
|
||||
|
@ -192,4 +192,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
var stack = dictionaryFrom('dictionary A { };').get_inheritance_stack();
|
||||
assert_array_equals(stack.map(d => d.name), ["A"]);
|
||||
}, 'should return an array that includes itself.');
|
||||
|
||||
|
||||
test(function() {
|
||||
var d = dictionaryFrom('dictionary A : B { };');
|
||||
assert_throws(new Error(), _ => d.get_inheritance_stack());
|
||||
}, "should throw for dictionaries which inherit from another dictionary which wasn't added to the IdlArray");
|
||||
|
||||
|
||||
test(function() {
|
||||
var idl = new IdlArray();
|
||||
idl.add_idls('dictionary A : B { };');
|
||||
|
@ -32,4 +32,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
var stack = interfaceFrom('interface A { };').get_inheritance_stack();
|
||||
assert_array_equals(stack.map(i => i.name), ["A"]);
|
||||
}, 'should return an array that includes itself.');
|
||||
|
||||
|
||||
test(function() {
|
||||
var i = interfaceFrom('interface A : B { };');
|
||||
assert_throws(new Error(), _ => i.get_inheritance_stack());
|
||||
}, "should throw for interfaces which inherit from another interface which wasn't added to the IdlArray");
|
||||
|
||||
|
||||
test(function() {
|
||||
var idl = new IdlArray();
|
||||
idl.add_idls('interface A : B { };');
|
||||
|
@ -32,4 +32,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
var i = interfaceFrom('interface A { };');
|
||||
assert_false(i.has_to_json_regular_operation());
|
||||
}, 'should return false when the interface declares no toJSON operation.');
|
||||
|
||||
|
||||
test(function() {
|
||||
var i = interfaceFrom('interface A { static object toJSON(); };');
|
||||
assert_false(i.has_to_json_regular_operation());
|
||||
}, 'should return false when the interface declares a static toJSON operation.');
|
||||
|
||||
|
||||
test(function() {
|
||||
var i = interfaceFrom('interface A { object toJSON(); };');
|
||||
assert_true(i.has_to_json_regular_operation());
|
||||
|
@ -29,4 +29,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ idlArray.add_idls(
|
|||
"interface Window : EventTarget {};\n" +
|
||||
|
||||
"[Global=Window, Exposed=Window, Constructor()]\n" +
|
||||
"interface Foo {};"
|
||||
"interface Foo {};"
|
||||
);
|
||||
idlArray.add_objects({
|
||||
Foo: ["new Foo()"],
|
||||
|
|
|
@ -176,7 +176,7 @@
|
|||
"status_string": "FAIL"
|
||||
},
|
||||
{
|
||||
"message": "assert_true: {\"sequence\":false,\"generic\":null,\"nullable\":false,\"array\":false,\"union\":false,\"idlType\":\"DOMException\"} is not an appropriate return value for the toJSON operation of N expected true got false",
|
||||
"message": "assert_true: {\"sequence\":false,\"generic\":null,\"nullable\":false,\"union\":false,\"idlType\":\"DOMException\"} is not an appropriate return value for the toJSON operation of N expected true got false",
|
||||
"name": "Test toJSON operation of N",
|
||||
"properties": {},
|
||||
"stack": "(implementation-defined)",
|
||||
|
@ -187,4 +187,4 @@
|
|||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
});
|
||||
assert_array_equals(interfaces, ["A"]);
|
||||
}, 'should return an array that includes itself.');
|
||||
|
||||
|
||||
test(function() {
|
||||
var context = new IdlArray();
|
||||
context.add_idls("interface A { }; A implements B;");
|
||||
|
@ -49,7 +49,7 @@
|
|||
context.add_idls("interface A { };");
|
||||
assert_throws(new TypeError(), _ => context.members["A"].traverse_inherited_and_consequential_interfaces());
|
||||
}, "should throw if not passed a callback");
|
||||
|
||||
|
||||
test(function() {
|
||||
var context = new IdlArray();
|
||||
context.add_idls(document.getElementById('fragments').textContent);
|
||||
|
@ -62,4 +62,3 @@
|
|||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ child context.</p>
|
|||
<!-- apisample4.html is a failing suite due to an unhandled Error. -->
|
||||
|
||||
<script>
|
||||
var childContext = document.getElementById("childContext");
|
||||
fetch_tests_from_window(childContext.contentWindow);
|
||||
var childContext = document.getElementById("childContext");
|
||||
fetch_tests_from_window(childContext.contentWindow);
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
|
|
|
@ -20,8 +20,8 @@ executing</p>
|
|||
<!-- promise-async.html has async tests with promises -->
|
||||
|
||||
<script>
|
||||
var childContext = document.getElementById("childContext");
|
||||
fetch_tests_from_window(childContext.contentWindow);
|
||||
var childContext = document.getElementById("childContext");
|
||||
fetch_tests_from_window(childContext.contentWindow);
|
||||
</script>
|
||||
<script type="text/json" id="expected">
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue