Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / constructors / progress-event-constructor.html
blob63fd4979f8bef4cc316b0dd3e379b53b5b77e0ca
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
9 description("This tests the constructor for the ProgressEvent DOM class.");
11 // No initializer is passed.
12 shouldBe("new ProgressEvent('eventType').bubbles", "false");
13 shouldBe("new ProgressEvent('eventType').cancelable", "false");
14 shouldBe("new ProgressEvent('eventType').lengthComputable", "false");
15 shouldBe("new ProgressEvent('eventType').loaded", "0");
16 shouldBe("new ProgressEvent('eventType').total", "0");
18 // bubbles is passed.
19 shouldBe("new ProgressEvent('eventType', { bubbles: false }).bubbles", "false");
20 shouldBe("new ProgressEvent('eventType', { bubbles: true }).bubbles", "true");
22 // cancelable is passed.
23 shouldBe("new ProgressEvent('eventType', { cancelable: false }).cancelable", "false");
24 shouldBe("new ProgressEvent('eventType', { cancelable: true }).cancelable", "true");
26 // lengthComputable is passed.
27 shouldBe("new ProgressEvent('eventType', { lengthComputable: false }).lengthComputable", "false");
28 shouldBe("new ProgressEvent('eventType', { lengthComputable: true }).lengthComputable", "true");
30 // loaded or total is passed.
31 ["loaded", "total"].forEach(function (attr) {
32 // [0, 2^53 - 1]. A value that is in the unsigned long long range and can be exactly represented as a double.
33 shouldBe("new ProgressEvent('eventType', { " + attr + ": 0 })." + attr, "0");
34 shouldBe("new ProgressEvent('eventType', { " + attr + ": 1 })." + attr, "1");
35 shouldBe("new ProgressEvent('eventType', { " + attr + ": 9007199254740990 })." + attr, "9007199254740990");
36 shouldBe("new ProgressEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, "9007199254740991");
38 // [2^53, 2^64 - 1]. A value that is in the unsigned long long range but cannot be represented as a double.
39 // Spec: http://www.w3.org/TR/WebIDL/#es-unsigned-long-long
40 shouldBe("new ProgressEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "0");
41 shouldBe("new ProgressEvent('eventType', { " + attr + ": 12345678901234567890 })." + attr, "12345678901234567890");
43 // A negative number.
44 shouldBe("new ProgressEvent('eventType', { " + attr + ": -1 })." + attr, "18446744073709551615");
46 // NaN.
47 shouldBe("new ProgressEvent('eventType', { " + attr + ": NaN })." + attr, "0");
49 // A double.
50 shouldBe("new ProgressEvent('eventType', { " + attr + ": 123.45 })." + attr, "123");
52 // Non-numeric values.
53 shouldBe("new ProgressEvent('eventType', { " + attr + ": undefined })." + attr, "0");
54 shouldBe("new ProgressEvent('eventType', { " + attr + ": null })." + attr, "0");
55 shouldBe("new ProgressEvent('eventType', { " + attr + ": '' })." + attr, "0");
56 shouldBe("new ProgressEvent('eventType', { " + attr + ": '12345' })." + attr, "12345");
57 shouldBe("new ProgressEvent('eventType', { " + attr + ": '12345a' })." + attr, "0");
58 shouldBe("new ProgressEvent('eventType', { " + attr + ": 'abc' })." + attr, "0");
59 shouldBe("new ProgressEvent('eventType', { " + attr + ": [] })." + attr, "0");
60 shouldBe("new ProgressEvent('eventType', { " + attr + ": [12345] })." + attr, "12345");
61 shouldBe("new ProgressEvent('eventType', { " + attr + ": [12345, 67890] })." + attr, "0");
62 shouldBe("new ProgressEvent('eventType', { " + attr + ": {} })." + attr, "0");
63 shouldBe("new ProgressEvent('eventType', { " + attr + ": {moe: 12345} })." + attr, "0");
64 shouldBe("new ProgressEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345");
65 });
67 // All initializers are passed.
68 shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).bubbles", "true");
69 shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).cancelable", "true");
70 shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).lengthComputable", "true");
71 shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).loaded", "12345");
72 shouldBe("new ProgressEvent('eventType', { bubbles: true, cancelable: true, lengthComputable: true, loaded: 12345, total: 12345 }).total", "12345");
73 </script>
74 </body>
75 </html>