4 <script src=
"../../../resources/js-test.js"></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", "");
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
) {
28 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr
+ ": 'doremi' })." + attr
, "doremi");
29 shouldBeEqualToString("new HashChangeEvent('eventType', { " + attr
+ ": '' })." + attr
, "");
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]");
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");