Update to use assert_throws_* functions for mozilla tests

This commit is contained in:
CYBAI 2020-02-18 19:57:10 +09:00
parent 7e7c8873e4
commit 8f9e7166a2
11 changed files with 87 additions and 79 deletions

View file

@ -11028,7 +11028,7 @@
[] []
], ],
"http-cache.js": [ "http-cache.js": [
"34aaacf536f31e4d9ae003cb0891ede965201f08", "e418f928839aec5f093819d97afda38c33d503eb",
[] []
], ],
"iframe_contentDocument_inner.html": [ "iframe_contentDocument_inner.html": [
@ -12066,7 +12066,7 @@
] ]
}, },
"idl-BluetoothUUID.html": [ "idl-BluetoothUUID.html": [
"27f8f846384687e2b7453f80f7ae325b14233d93", "445cafe07edeaf13663af653cabb40ffe365f3e9",
[ [
null, null,
{} {}
@ -13134,14 +13134,14 @@
] ]
], ],
"activation.html": [ "activation.html": [
"abc1f58275c1a87e04aef221d337a4bd0dbf0f35", "c5f556d14578c415114c435f8b1245fd0168ceba",
[ [
null, null,
{} {}
] ]
], ],
"adopted_node_is_same_origin_domain.html": [ "adopted_node_is_same_origin_domain.html": [
"81de5b389c922067c61effe03208ea740ba8e067", "f050835771e841026c5132938a6239eb75a47e1b",
[ [
null, null,
{} {}
@ -13249,7 +13249,7 @@
], ],
"cross-origin-objects": { "cross-origin-objects": {
"cross-origin-objects.html": [ "cross-origin-objects.html": [
"d7b0e0da1acfe773a19301e8bdebeeee6539fb5e", "2ad24df66cfa8d2571c1ab25a2dd2dfcb2c1ae4e",
[ [
null, null,
{ {
@ -13462,7 +13462,7 @@
] ]
], ],
"element_attribute.html": [ "element_attribute.html": [
"87eff09bf542402fadc577bccce6e0fa67737dcf", "3ec766e133fea343ac645619a500c46e0e4af64c",
[ [
null, null,
{} {}
@ -13877,7 +13877,7 @@
] ]
], ],
"invalid-this.html": [ "invalid-this.html": [
"bc1e350522670523144a5dc8a9ad4e0398078301", "2dcc7eeae58b33515417de4e92935e80fac5df62",
[ [
null, null,
{} {}
@ -14252,7 +14252,7 @@
] ]
}, },
"sequence-hole.html": [ "sequence-hole.html": [
"0021769859417ffeb4d656f7130370b628bfac7d", "f56b006038956faf31287c2e336fb0f02123d550",
[ [
null, null,
{} {}
@ -14391,7 +14391,7 @@
] ]
], ],
"union.html": [ "union.html": [
"dec25d03b8e46791c8044c67bca93036c3e8bdeb", "89d28fbcbc37060e30827cabcce7adc0bfaf9688",
[ [
null, null,
{} {}
@ -14500,7 +14500,7 @@
] ]
], ],
"window-postmessage-sameorigin.html": [ "window-postmessage-sameorigin.html": [
"a3ec80929b784c6d5c766fe4cf9d99996cb8850b", "6a1d00fd1c37fcf1492ecb48a02fe358ac2cbacf",
[ [
null, null,
{} {}

View file

@ -83,23 +83,23 @@ test(() => {
test(() => { test(() => {
let all_caps_uuid = '1A2B3C4D-5E6F-7A8B-9C0D-1E2F3A4B5C6D'; let all_caps_uuid = '1A2B3C4D-5E6F-7A8B-9C0D-1E2F3A4B5C6D';
assert_throws(new TypeError(), () => BluetoothUUID.getService(all_caps_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getService(all_caps_uuid));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(all_caps_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(all_caps_uuid));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(all_caps_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(all_caps_uuid));
}, 'A UUID String with uppercase letters is an invalid UUID.'); }, 'A UUID String with uppercase letters is an invalid UUID.');
test(() => { test(() => {
let string_alias = 'deadbeef'; let string_alias = 'deadbeef';
assert_throws(new TypeError(), () => BluetoothUUID.getService(string_alias)); assert_throws_js(TypeError, () => BluetoothUUID.getService(string_alias));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(string_alias)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(string_alias));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(string_alias)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(string_alias));
}, 'A 32bit *String* alias is invalid.'); }, 'A 32bit *String* alias is invalid.');
test(() => { test(() => {
let invalid_character_uuid = '0000000g-0000-1000-8000-00805f9b34fb'; let invalid_character_uuid = '0000000g-0000-1000-8000-00805f9b34fb';
assert_throws(new TypeError(), () => BluetoothUUID.getService(invalid_character_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getService(invalid_character_uuid));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(invalid_character_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(invalid_character_uuid));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(invalid_character_uuid)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(invalid_character_uuid));
}, 'A UUID with invalid characters is an invalid UUID.'); }, 'A UUID with invalid characters is an invalid UUID.');
test(() => { test(() => {
@ -112,31 +112,31 @@ test(() => {
}, 'A valid UUID from a name.'); }, 'A valid UUID from a name.');
test(() => { test(() => {
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getService(aerobic_heart_rate_lower_limit.name); BluetoothUUID.getService(aerobic_heart_rate_lower_limit.name);
}); });
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getService(characteristic_extended_properties.name); BluetoothUUID.getService(characteristic_extended_properties.name);
}); });
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getCharacteristic(alert_notification.name); BluetoothUUID.getCharacteristic(alert_notification.name);
}); });
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getCharacteristic(characteristic_extended_properties.name); BluetoothUUID.getCharacteristic(characteristic_extended_properties.name);
}); });
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getDescriptor(alert_notification.name); BluetoothUUID.getDescriptor(alert_notification.name);
}); });
assert_throws(new TypeError(), () => { assert_throws_js(TypeError, () => {
BluetoothUUID.getDescriptor(aerobic_heart_rate_lower_limit.name); BluetoothUUID.getDescriptor(aerobic_heart_rate_lower_limit.name);
}); });
}, 'Make sure attributes don\'t share a map'); }, 'Make sure attributes don\'t share a map');
test(() => { test(() => {
let wrong_name = 'wrong_name'; let wrong_name = 'wrong_name';
assert_throws(new TypeError(), () => BluetoothUUID.getService(wrong_name)); assert_throws_js(TypeError, () => BluetoothUUID.getService(wrong_name));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(wrong_name)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(wrong_name));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(wrong_name)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(wrong_name));
}, 'Invalid Descriptor name'); }, 'Invalid Descriptor name');
test(() => { test(() => {
@ -144,35 +144,35 @@ test(() => {
let array = []; let array = [];
let func = () => {}; let func = () => {};
// cannonicalUUID // cannonicalUUID
assert_throws(new TypeError, () => BluetoothUUID.canonicalUUID(object)); assert_throws_js(new TypeError, () => BluetoothUUID.canonicalUUID(object));
// [] converts to '', which converts to 0 before the range check. // [] converts to '', which converts to 0 before the range check.
assert_equals(BluetoothUUID.canonicalUUID(array), base_uuid); assert_equals(BluetoothUUID.canonicalUUID(array), base_uuid);
assert_throws(new TypeError, () => BluetoothUUID.canonicalUUID(func)); assert_throws_js(new TypeError, () => BluetoothUUID.canonicalUUID(func));
assert_throws(new TypeError, () => BluetoothUUID.canonicalUUID(undefined)); assert_throws_js(new TypeError, () => BluetoothUUID.canonicalUUID(undefined));
assert_equals(BluetoothUUID.canonicalUUID(null), base_uuid); assert_equals(BluetoothUUID.canonicalUUID(null), base_uuid);
assert_equals(BluetoothUUID.canonicalUUID(false), base_uuid); assert_equals(BluetoothUUID.canonicalUUID(false), base_uuid);
assert_equals(BluetoothUUID.canonicalUUID(true), BluetoothUUID.canonicalUUID(1)); assert_equals(BluetoothUUID.canonicalUUID(true), BluetoothUUID.canonicalUUID(1));
assert_throws(new TypeError, () => BluetoothUUID.canonicalUUID(NaN)); assert_throws_js(new TypeError, () => BluetoothUUID.canonicalUUID(NaN));
// getService // getService
assert_throws(new TypeError(), () => BluetoothUUID.getService(object)); assert_throws_js(TypeError, () => BluetoothUUID.getService(object));
assert_throws(new TypeError(), () => BluetoothUUID.getService(array)); assert_throws_js(TypeError, () => BluetoothUUID.getService(array));
assert_throws(new TypeError(), () => BluetoothUUID.getService(func)); assert_throws_js(TypeError, () => BluetoothUUID.getService(func));
assert_throws(new TypeError(), () => BluetoothUUID.getService(undefined)); assert_throws_js(TypeError, () => BluetoothUUID.getService(undefined));
assert_throws(new TypeError(), () => BluetoothUUID.getService(null)); assert_throws_js(TypeError, () => BluetoothUUID.getService(null));
assert_throws(new TypeError(), () => BluetoothUUID.getService(false)); assert_throws_js(TypeError, () => BluetoothUUID.getService(false));
// getCharacteristic // getCharacteristic
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(object)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(object));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(array)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(array));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(func)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(func));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(undefined)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(undefined));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(null)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(null));
assert_throws(new TypeError(), () => BluetoothUUID.getCharacteristic(false)); assert_throws_js(TypeError, () => BluetoothUUID.getCharacteristic(false));
// getDescriptor // getDescriptor
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(object)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(object));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(array)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(array));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(func)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(func));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(undefined)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(undefined));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(null)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(null));
assert_throws(new TypeError(), () => BluetoothUUID.getDescriptor(false)); assert_throws_js(TypeError, () => BluetoothUUID.getDescriptor(false));
}, 'Non-number and non-strings'); }, 'Non-number and non-strings');
</script> </script>

View file

@ -42,7 +42,7 @@
"Activate input"); "Activate input");
test(function () { test(function () {
assert_throws("NotSupportedError", function () { assert_throws_dom("NotSupportedError", function () {
var foo = document.getElementById("foo"); var foo = document.getElementById("foo");
foo.enterFormalActivationState(); foo.enterFormalActivationState();
}); });

View file

@ -22,7 +22,7 @@ async_test(function(t) {
// We can still access the adopted node, since it is still same-origin-domain, // We can still access the adopted node, since it is still same-origin-domain,
// but accessing the unadopted node throws a security exception. // but accessing the unadopted node throws a security exception.
assert_equals(nodeToAdopt.ownerDocument, document); assert_equals(nodeToAdopt.ownerDocument, document);
assert_throws(null, function() { nodeToLeaveUnadopted.ownerDocument; }); assert_throws_exactly(null, function() { nodeToLeaveUnadopted.ownerDocument; });
t.done(); t.done();
}); });
document.body.appendChild(iframe); document.body.appendChild(iframe);

View file

@ -83,14 +83,14 @@ async_test(function(t) {
Object.getOwnPropertyDescriptor(C, prop); // Shouldn't throw. Object.getOwnPropertyDescriptor(C, prop); // Shouldn't throw.
assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop)); assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop));
} else { } else {
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window"); assert_throws_dom("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, assert_throws_dom("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
"Should throw when accessing property descriptor for " + prop + " on Window"); "Should throw when accessing property descriptor for " + prop + " on Window");
assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, assert_throws_dom("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
"Should throw when invoking hasOwnProperty for " + prop + " on Window"); "Should throw when invoking hasOwnProperty for " + prop + " on Window");
} }
if (prop != 'location') if (prop != 'location')
assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window"); assert_throws_dom("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window");
} }
for (var prop in location) { for (var prop in location) {
if (prop == 'replace') { if (prop == 'replace') {
@ -99,14 +99,14 @@ async_test(function(t) {
assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop); assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop);
} }
else { else {
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location"); assert_throws_dom("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location");
assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, assert_throws_dom("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
"Should throw when accessing property descriptor for " + prop + " on Location"); "Should throw when accessing property descriptor for " + prop + " on Location");
assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, assert_throws_dom("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
"Should throw when invoking hasOwnProperty for " + prop + " on Location"); "Should throw when invoking hasOwnProperty for " + prop + " on Location");
} }
if (prop != 'href') if (prop != 'href')
assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location"); assert_throws_dom("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location");
} }
t.done(); t.done();
} }

View file

@ -52,13 +52,13 @@
}); });
test(function() { test(function() {
assert_throws("NamespaceError", function () { assert_throws_dom("NamespaceError", function () {
element.setAttributeNS("http://example.com", "xmlns", "foo"); element.setAttributeNS("http://example.com", "xmlns", "foo");
}); });
assert_throws("NamespaceError", function () { assert_throws_dom("NamespaceError", function () {
element.setAttributeNS("http://www.w3.org/2000/xmlns/", "attr", "value"); element.setAttributeNS("http://www.w3.org/2000/xmlns/", "attr", "value");
}); });
assert_throws("NamespaceError", function () { assert_throws_dom("NamespaceError", function () {
element.setAttributeNS("http://www.w3.org/2000/xmlns/", "prefix:attr", "value"); element.setAttributeNS("http://www.w3.org/2000/xmlns/", "prefix:attr", "value");
}); });
}); });

View file

@ -5,9 +5,9 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>
test(function() { test(function() {
assert_throws(new TypeError(), function() { window.atob.call("", localStorage); }) assert_throws_js(TypeError, function() { window.atob.call("", localStorage); })
assert_throws(new TypeError(), function() { window.removeEventListener.call("", ""); }) assert_throws_js(TypeError, function() { window.removeEventListener.call("", ""); })
assert_throws(new TypeError(), function() { window.alert.call(""); }) assert_throws_js(TypeError, function() { window.alert.call(""); })
assert_throws(new TypeError(), function() { window.moveTo.call(128); }) assert_throws_js(TypeError, function() { window.moveTo.call(128); })
}) })
</script> </script>

View file

@ -186,7 +186,7 @@ function make_test(raw_requests) {
} }
}, function(reason) { }, function(reason) {
if ("expected_type" in config && config.expected_type === "error") { if ("expected_type" in config && config.expected_type === "error") {
assert_throws(new TypeError(), function() { throw reason; }); assert_throws_js(TypeError, function() { throw reason; });
} else { } else {
throw reason; throw reason;
} }

View file

@ -8,20 +8,20 @@ test(function() {
var t = new TestBinding; var t = new TestBinding;
t.passSequence([1,, 3]); t.passSequence([1,, 3]);
t.passStringSequence(["camembert",, "comté"]); t.passStringSequence(["camembert",, "comté"]);
assert_throws(new TypeError, function () { t.passInterfaceSequence([new Blob,, new Blob]) }); assert_throws_js(TypeError, function () { t.passInterfaceSequence([new Blob,, new Blob]) });
}, "Sequences with holes are correctly handled"); }, "Sequences with holes are correctly handled");
test(function() { test(function() {
var test_error = { name: "test" }; var test_error = { name: "test" };
Object.defineProperty(Array.prototype, 1, { get: function() { throw test_error; } }); Object.defineProperty(Array.prototype, 1, { get: function() { throw test_error; } });
var t = new TestBinding; var t = new TestBinding;
assert_throws(test_error, function() { assert_throws_exactly(test_error, function() {
t.passSequence([1,, 3]); t.passSequence([1,, 3]);
}); });
assert_throws(test_error, function() { assert_throws_exactly(test_error, function() {
t.passStringSequence(["camembert",, "comté"]); t.passStringSequence(["camembert",, "comté"]);
}); });
assert_throws(test_error, function() { assert_throws_exactly(test_error, function() {
t.passInterfaceSequence([new Blob,, new Blob]); t.passInterfaceSequence([new Blob,, new Blob]);
}); });
}, "Sequences with holes and a getter on the prototype are correctly handled"); }, "Sequences with holes and a getter on the prototype are correctly handled");

View file

@ -14,13 +14,13 @@ test(function() {
var opt = document.createElement('option'); var opt = document.createElement('option');
sel.add(opt); sel.add(opt);
sel.add(optgroup); sel.add(optgroup);
assert_throws("NotFoundError", function() { sel.add(opt, div); }); assert_throws_dom("NotFoundError", function() { sel.add(opt, div); });
assert_throws("NotFoundError", function() { sel.add(optgroup, div); }); assert_throws_dom("NotFoundError", function() { sel.add(optgroup, div); });
sel.add(opt, div2); sel.add(opt, div2);
sel.add(optgroup, div2); sel.add(optgroup, div2);
sel.add(opt, 5); sel.add(opt, 5);
sel.add(optgroup, 5); sel.add(optgroup, 5);
assert_throws(new TypeError(), function() { sel.add(div) }); assert_throws_js(TypeError, function() { sel.add(div) });
sel.add(optgroup, function() {}) sel.add(optgroup, function() {})
}); });
</script> </script>

View file

@ -9,10 +9,18 @@ setup({
explicit_done: true explicit_done: true
}); });
function expect_error(error, message, origin, description) { function expect_error_js(error, message, origin, description) {
return function(setlistener, removelistener, type) { return function(setlistener, removelistener, type) {
test(function(t) { test(function(t) {
assert_throws(error, function() { postMessage(message, origin) }); assert_throws_js(error, function() { postMessage(message, origin) });
}, description + ' (' + type + ')');
}
}
function expect_error_dom(error, message, origin, description) {
return function(setlistener, removelistener, type) {
test(function(t) {
assert_throws_dom(error, function() { postMessage(message, origin) });
}, description + ' (' + type + ')'); }, description + ' (' + type + ')');
} }
} }
@ -48,8 +56,8 @@ var base_tests = [
function() { return expect_message('basic', '/', 'same origin, cloneable string message') }, function() { return expect_message('basic', '/', 'same origin, cloneable string message') },
function() { return expect_message('basic', HTTP_ORIGIN, 'explicit same origin, cloneable string message') }, function() { return expect_message('basic', HTTP_ORIGIN, 'explicit same origin, cloneable string message') },
function() { return expect_no_message('basic', HTTPS_ORIGIN, 'explicit cross origin, cloneable string message') }, function() { return expect_no_message('basic', HTTPS_ORIGIN, 'explicit cross origin, cloneable string message') },
function() { return expect_error(new SyntaxError(), 'basic', 'not-a-url', 'explicit invalid url, cloneable string message') }, function() { return expect_error_js(SyntaxError, 'basic', 'not-a-url', 'explicit invalid url, cloneable string message') },
function() { return expect_error('DATA_CLONE_ERR', window, '*', 'any origin, non-cloneable message') }, function() { return expect_error_dom('DATA_CLONE_ERR', window, '*', 'any origin, non-cloneable message') },
]; ];
var tests = []; var tests = [];