blob: 32698f090bfad77d0e08ee1a9f33eb209e40c359 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("This tests the constructor for the ErrorEvent DOM class.");
// No initializer is passed.
shouldBe("new ErrorEvent('eventType').bubbles", "false");
shouldBe("new ErrorEvent('eventType').cancelable", "false");
shouldBeEqualToString("new ErrorEvent('eventType').message", "");
shouldBeEqualToString("new ErrorEvent('eventType').filename", "");
shouldBe("new ErrorEvent('eventType').lineno", "0");
// bubbles is passed.
shouldBe("new ErrorEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new ErrorEvent('eventType', { bubbles: true }).bubbles", "true");
// cancelable is passed.
shouldBe("new ErrorEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new ErrorEvent('eventType', { cancelable: true }).cancelable", "true");
// message or filename is passed.
["message", "filename"].forEach(function (attr) {
// Strings.
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": 'melancholy' })." + attr, "melancholy");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": '' })." + attr, "");
// Non-strings.
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": undefined })." + attr, "undefined");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": null })." + attr, "null");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": false })." + attr, "false");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": true })." + attr, "true");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": 12345 })." + attr, "12345");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "18446744073709552000");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": NaN })." + attr, "NaN");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": [] })." + attr, "");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": [1, 2, 3] })." + attr, "1,2,3");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": {melancholy: 12345} })." + attr, "[object Object]");
shouldBeEqualToString("new ErrorEvent('eventType', { " + attr + ": {valueOf: function () { return 'melancholy'; } } })." + attr, "[object Object]");
});
// lineno is passed.
// numbers within the unsigned long range.
shouldBe("new ErrorEvent('eventType', { lineno: 0 }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: 1 }).lineno", "1");
shouldBe("new ErrorEvent('eventType', { lineno: 4294967294 }).lineno", "4294967294");
shouldBe("new ErrorEvent('eventType', { lineno: 4294967295 }).lineno", "4294967295");
// numbers out of the unsigned long range.
// 2^{53}-1, the largest number that can be exactly represented by double.
shouldBe("new ErrorEvent('eventType', { lineno: 9007199254740991 }).lineno", "4294967295");
// 2^{64}-1
shouldBe("new ErrorEvent('eventType', { lineno: 18446744073709551615 }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: 12345678901234567890 }).lineno", "3944679424");
shouldBe("new ErrorEvent('eventType', { lineno: -1 }).lineno", "4294967295");
shouldBe("new ErrorEvent('eventType', { lineno: 123.45 }).lineno", "123");
shouldBe("new ErrorEvent('eventType', { lineno: NaN }).lineno", "0");
// Non-numeric values.
shouldBe("new ErrorEvent('eventType', { lineno: undefined }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: null }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: '' }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: '12345' }).lineno", "12345");
shouldBe("new ErrorEvent('eventType', { lineno: '12345a' }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: 'abc' }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: [] }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: [12345] }).lineno", "12345");
shouldBe("new ErrorEvent('eventType', { lineno: [12345, 67890] }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: {} }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: {moemoe: 12345} }).lineno", "0");
shouldBe("new ErrorEvent('eventType', { lineno: {valueOf: function () { return 12345; }} }).lineno", "12345");
// All initializers are passed.
shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345 }).bubbles", "true");
shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345 }).cancelable", "true");
shouldBeEqualToString("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345 }).message", "sakuranbo");
shouldBeEqualToString("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345 }).filename", "amaenbo");
shouldBe("new ErrorEvent('eventType', { bubbles: true, cancelable: true, message: 'sakuranbo', filename: 'amaenbo', lineno: 12345 }).lineno", "12345");
var successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>