Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / constructors / hash-change-event-constructor.html
blobd235acc31575123ce13a4db69e2c6b9c90ad4e35
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 HashChangeEvent DOM class.");
11 // No initializer is passed.
12 shouldBe("new HashChangeEvent('eventType').bubbles", "false");
13 shouldBe("new HashChangeEvent('eventType').cancelable", "false");
14 shouldBeEqualToString("new HashChangeEvent('eventType').oldURL", "");
15 shouldBeEqualToString("new HashChangeEvent('eventType').newURL", "");
17 // bubbles is passed.
18 shouldBe("new HashChangeEvent('eventType', { bubbles: false }).bubbles", "false");
19 shouldBe("new HashChangeEvent('eventType', { bubbles: true }).bubbles", "true");
21 // cancelable is passed.
22 shouldBe("new HashChangeEvent('eventType', { cancelable: false }).cancelable", "false");
23 shouldBe("new HashChangeEvent('eventType', { cancelable: true }).cancelable", "true");
25 // oldURL or newURL is passed.
26 ["oldURL", "newURL"].forEach(function (attr) {
27 // Strings.
28 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": 'doremi' })." + attr, "doremi");
29 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": '' })." + attr, "");
31 // Non-strings.
32 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": undefined })." + attr, "");
33 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": null })." + attr, "null");
34 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": false })." + attr, "false");
35 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": true })." + attr, "true");
36 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": 12345 })." + attr, "12345");
37 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "18446744073709552000");
38 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": NaN })." + attr, "NaN");
39 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": [] })." + attr, "");
40 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": [1, 2, 3] })." + attr, "1,2,3");
41 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": {doremi: 12345} })." + attr, "[object Object]");
42 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr + ": {valueOf: function () { return 'doremi'; } } })." + attr, "[object Object]");
43 });
45 // All initializers are passed.
46 shouldBe("new HashChangeEvent('eventType', { bubbles: true, cancelable: true, oldURL: 'doremi', newURL: 'andre' }).bubbles", "true");
47 shouldBe("new HashChangeEvent('eventType', { bubbles: true, cancelable: true, oldURL: 'doremi', newURL: 'andre' }).cancelable", "true");
48 shouldBeEqualToString("new HashChangeEvent('eventType', { bubbles: true, cancelable: true, oldURL: 'doremi', newURL: 'andre' }).oldURL", "doremi");
49 shouldBeEqualToString("new HashChangeEvent('eventType', { bubbles: true, cancelable: true, oldURL: 'doremi', newURL: 'andre' }).newURL", "andre");
50 </script>
51 </body>
52 </html>