1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug427537.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=427537 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 427537</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=427537">Mozilla Bug 427537</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"> 1.22 + 1.23 +/** Test for Bug 427537 **/ 1.24 + 1.25 +var e = document.createEvent("CustomEvent"); 1.26 +ok(e, "Should have custom event!"); 1.27 + 1.28 +// Test initCustomEvent and also cycle collection handling by 1.29 +// passing reference to the event as 'detail' parameter. 1.30 +e.initCustomEvent("foobar", true, true, e); 1.31 + 1.32 +var didCallListener = false; 1.33 +document.addEventListener("foobar", 1.34 + function(evt) { 1.35 + didCallListener = true; 1.36 + is(evt.type, "foobar", "Should get 'foobar' event!"); 1.37 + is(evt.detail, evt, ".detail should point to the event itself."); 1.38 + ok(e.bubbles, "Event should bubble!"); 1.39 + ok(e.cancelable, "Event should be cancelable."); 1.40 + }, true); 1.41 + 1.42 +document.dispatchEvent(e); 1.43 +ok(didCallListener, "Should have called listener!"); 1.44 + 1.45 +e = document.createEvent("CustomEvent"); 1.46 +e.initCustomEvent("foobar", true, true, 1); 1.47 +is(e.detail, 1, "Detail should be 1."); 1.48 + 1.49 +e = document.createEvent("CustomEvent"); 1.50 +e.initCustomEvent("foobar", true, true, "test"); 1.51 +is(e.detail, "test", "Detail should be 'test'."); 1.52 + 1.53 +e = document.createEvent("CustomEvent"); 1.54 +e.initCustomEvent("foobar", true, true, true); 1.55 +is(e.detail, true, "Detail should be true."); 1.56 + 1.57 +</script> 1.58 +</pre> 1.59 +</body> 1.60 +</html>