4 <script src=
"../../../resources/js-test.js"></script>
9 description("This tests the constructor for the AutocompleteErrorEvent DOM class.");
11 if (!window
.AutocompleteErrorEvent
) {
12 testFailed('no AutocompleteErrorEvent');
15 // No initializer is passed.
16 shouldBe("new AutocompleteErrorEvent('eventType').bubbles", "false");
17 shouldBe("new AutocompleteErrorEvent('eventType').cancelable", "false");
18 shouldBeEqualToString("new AutocompleteErrorEvent('eventType').reason", "");
21 shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: false }).bubbles", "false");
22 shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true }).bubbles", "true");
24 // cancelable is passed.
25 shouldBe("new AutocompleteErrorEvent('eventType', { cancelable: false }).cancelable", "false");
26 shouldBe("new AutocompleteErrorEvent('eventType', { cancelable: true }).cancelable", "true");
29 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 'cancel' }).reason", "cancel");
30 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: '' }).reason", "");
31 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 'disabled' }).reason", "disabled");
32 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: 'invalid' }).reason", "invalid");
33 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { reason: undefined }).reason", "");
35 // Invalid reason throws exception
36 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: 'doremi' })");
37 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: null })");
38 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: false })");
39 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: true })");
40 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: 12345 })");
41 shouldThrow("new AutocompleteErrorEvent('eventType', { reason: NaN })");
43 // All initializers are passed.
44 shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: '' }).bubbles", "true");
45 shouldBe("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'cancel' }).cancelable", "true");
46 shouldBeEqualToString("new AutocompleteErrorEvent('eventType', { bubbles: true, cancelable: true, reason: 'disabled' }).reason", "disabled");