blob: 63fd4979f8bef4cc316b0dd3e379b53b5b77e0ca [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script>
description("This tests the constructor for the ProgressEvent DOM class.");
// No initializer is passed.
shouldBe("new ProgressEvent('eventType').bubbles", "false");
shouldBe("new ProgressEvent('eventType').cancelable", "false");
shouldBe("new ProgressEvent('eventType').lengthComputable", "false");
shouldBe("new ProgressEvent('eventType').loaded", "0");
shouldBe("new ProgressEvent('eventType').total", "0");
// bubbles is passed.
shouldBe("new ProgressEvent('eventType', { bubbles: false }).bubbles", "false");
shouldBe("new ProgressEvent('eventType', { bubbles: true }).bubbles", "true");
// cancelable is passed.
shouldBe("new ProgressEvent('eventType', { cancelable: false }).cancelable", "false");
shouldBe("new ProgressEvent('eventType', { cancelable: true }).cancelable", "true");
// lengthComputable is passed.
shouldBe("new ProgressEvent('eventType', { lengthComputable: false }).lengthComputable", "false");
shouldBe("new ProgressEvent('eventType', { lengthComputable: true }).lengthComputable", "true");
// loaded or total is passed.
["loaded", "total"].forEach(function (attr) {
// [0, 2^53 - 1]. A value that is in the unsigned long long range and can be exactly represented as a double.
shouldBe("new ProgressEvent('eventType', { " + attr + ": 0 })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": 1 })." + attr, "1");
shouldBe("new ProgressEvent('eventType', { " + attr + ": 9007199254740990 })." + attr, "9007199254740990");
shouldBe("new ProgressEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, "9007199254740991");
// [2^53, 2^64 - 1]. A value that is in the unsigned long long range but cannot be represented as a double.
// Spec: http://www.w3.org/TR/WebIDL/#es-unsigned-long-long
shouldBe("new ProgressEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": 12345678901234567890 })." + attr, "12345678901234567890");
// A negative number.
shouldBe("new ProgressEvent('eventType', { " + attr + ": -1 })." + attr, "18446744073709551615");
// NaN.
shouldBe("new ProgressEvent('eventType', { " + attr + ": NaN })." + attr, "0");
// A double.
shouldBe("new ProgressEvent('eventType', { " + attr + ": 123.45 })." + attr, "123");
// Non-numeric values.
shouldBe("new ProgressEvent('eventType', { " + attr + ": undefined })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": null })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": '' })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": '12345' })." + attr, "12345");
shouldBe("new ProgressEvent('eventType', { " + attr + ": '12345a' })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": 'abc' })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": [] })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": [12345] })." + attr, "12345");
shouldBe("new ProgressEvent('eventType', { " + attr + ": [12345, 67890] })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": {} })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": {moe: 12345} })." + attr, "0");
shouldBe("new ProgressEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345");
});
// All initializers are passed.
shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).bubbles", "true");
shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).cancelable", "true");
shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).lengthComputable", "true");
shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).loaded", "12345");
shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).total", "12345");
</script>
</body>
</html>