JS Test Harness: Insert the stylesheet dynamically
[WebKit-https.git] / LayoutTests / fast / events / constructors / custom-event-constructor.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 constructor for the CustomEvent DOM class.");
10
11 // No initializer passed.
12 shouldBe("new CustomEvent('eventType').bubbles", "false");
13 shouldBe("new CustomEvent('eventType').cancelable", "false");
14 shouldBeNull("new CustomEvent('eventType').detail");
15
16 // Bubbles and cancelable true, details is missing.
17 shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles", "true");
18 shouldBe("new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable", "true");
19 shouldBeNull("new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail");
20
21 // Detail is a number
22 shouldBe("new CustomEvent('eventType', { detail: 10 }).detail", "10");
23
24 // Detail is a string
25 shouldBe("new CustomEvent('eventType', { detail: \'string\' }).detail", "'string'");
26
27 // Detail is an object
28 var detailObject = { };
29 shouldBe("new CustomEvent('eventType', { detail: detailObject }).detail", "detailObject");
30
31 // Detail is a DOM object
32 shouldBe("new CustomEvent('eventType', { detail: document }).detail", "document");
33
34 // Detail is a getter.
35 shouldBe("new CustomEvent('eventType', { get detail() { return true; } }).detail", "true");
36
37 // Detail throws an exeception.
38 shouldThrow("new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } })");
39
40 var successfullyParsed = true;
41 </script>
42 <script src="../../js/resources/js-test-post.js"></script>
43 </body>
44 </html>