Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=427537
5 -->
6 <head>
7 <title>Test for Bug 427537</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=427537">Mozilla Bug 427537</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 427537 **/
22 var e = document.createEvent("CustomEvent");
23 ok(e, "Should have custom event!");
25 // Test initCustomEvent and also cycle collection handling by
26 // passing reference to the event as 'detail' parameter.
27 e.initCustomEvent("foobar", true, true, e);
29 var didCallListener = false;
30 document.addEventListener("foobar",
31 function(evt) {
32 didCallListener = true;
33 is(evt.type, "foobar", "Should get 'foobar' event!");
34 is(evt.detail, evt, ".detail should point to the event itself.");
35 ok(e.bubbles, "Event should bubble!");
36 ok(e.cancelable, "Event should be cancelable.");
37 }, true);
39 document.dispatchEvent(e);
40 ok(didCallListener, "Should have called listener!");
42 e = document.createEvent("CustomEvent");
43 e.initCustomEvent("foobar", true, true, 1);
44 is(e.detail, 1, "Detail should be 1.");
46 e = document.createEvent("CustomEvent");
47 e.initCustomEvent("foobar", true, true, "test");
48 is(e.detail, "test", "Detail should be 'test'.");
50 e = document.createEvent("CustomEvent");
51 e.initCustomEvent("foobar", true, true, true);
52 is(e.detail, true, "Detail should be true.");
54 </script>
55 </pre>
56 </body>
57 </html>