tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / events / constructors / event-constructors.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8
9 description("This tests the constructors for all the event DOM classes that have them.");
10
11 function test(toEval, bubblesExpected, cancelableExpected)
12 {
13     if (bubblesExpected) {
14         shouldBe("(" + toEval + ").bubbles", "true");
15     } else {
16         shouldBe("(" + toEval + ").bubbles", "false");
17     }
18
19     if (cancelableExpected) {
20         shouldBe("(" + toEval + ").cancelable", "true");
21     } else {
22         shouldBe("(" + toEval + ").cancelable", "false");
23     }
24 }
25
26 // No initializer passed.
27 test("new Event('eventType')", false, false);
28
29 // Both true.
30 test("new Event('eventType', { bubbles: true, cancelable: true })", true, true);
31
32 // One true, one false.
33 test("new Event('eventType', { bubbles: true, cancelable: false })", true, false);
34
35 // One explicitly undefined.
36 test("new Event('eventType', { bubbles: true, cancelable: undefined })", true, false);
37
38 // One a numeric value.
39 test("new Event('eventType', { bubbles: true, cancelable: 0 })", true, false);
40
41 // One missing.
42 test("new Event('eventType', { bubbles: true })", true, false);
43
44 // Empty initalizer.
45 test("new Event('eventType', { })", false, false);
46
47 // null initializer.
48 test("new Event('eventType', null)", false, false);
49
50 // Explicitly undefined initializer.
51 test("new Event('eventType', undefined)", false, false);
52
53 // A number as the initializer.
54 // FIXME: Should this throw?
55 test("new Event('eventType', 0)", false, false);
56
57 // The window as the initializer.
58 test("new Event('eventType', window)", false, false);
59
60 // The window as the initializer, but with bubbles defined to true.
61 var bubbles = true;
62 test("new Event('eventType', window)", true, false);
63
64 // One value defined on the prototype chain of a host object.
65 Document.prototype.bubbles = true;
66 test("new Event('eventType', document)", true, false);
67
68 // One value defined on the prototype chain of a vanilla object.
69 var Constructible = function() { }
70 Constructible.prototype.bubbles = true;
71 var constructible = new Constructible;
72 test("new Event('eventType', constructible)", true, false);
73
74 // Additional properties on the initializer
75 test("new Event('eventType', { bubbles: true, cancelable: true, other: true })", true, true);
76
77 // One getter returning true.
78 test("new Event('eventType', { bubbles: true, get cancelable() { return true; } })", true, true);
79
80 // One getter returning false.
81 test("new Event('eventType', { bubbles: true, get cancelable() { return false; } })", true, false);
82
83 // One getter throws an exeception.
84 shouldThrow("new Event('eventType', { bubbles: true, get cancelable() { throw 'Custom Error'; } })")
85 </script>
86 <script src="../../js/resources/js-test-post.js"></script>
87 </body>
88 </html>