tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug427537.html (1773B)


      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 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">
     15  
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 
     20 /** Test for Bug 427537 */
     21 
     22 var e = document.createEvent("CustomEvent");
     23 ok(e, "Should have custom event!");
     24 
     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);
     28 
     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);
     38 
     39 document.dispatchEvent(e);
     40 ok(didCallListener, "Should have called listener!");
     41 
     42 e = document.createEvent("CustomEvent");
     43 e.initEvent("foo", true, true);
     44 is(e.detail, null, "Default detail should be null.");
     45 
     46 e = document.createEvent("CustomEvent");
     47 e.initCustomEvent("foobar", true, true, 1);
     48 is(e.detail, 1, "Detail should be 1.");
     49 
     50 e = document.createEvent("CustomEvent");
     51 e.initCustomEvent("foobar", true, true, "test");
     52 is(e.detail, "test", "Detail should be 'test'.");
     53 
     54 e = document.createEvent("CustomEvent");
     55 e.initCustomEvent("foobar", true, true, true);
     56 is(e.detail, true, "Detail should be true.");
     57 
     58 </script>
     59 </pre>
     60 </body>
     61 </html>