tor-browser

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

CustomEvent.html (1081B)


      1 <!doctype html>
      2 <title>CustomEvent</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <div id="log"></div>
      6 <script>
      7 test(function() {
      8  var type = "foo";
      9 
     10  var target = document.createElement("div");
     11  target.addEventListener(type, this.step_func(function(evt) {
     12    assert_equals(evt.type, type);
     13  }), true);
     14 
     15  var fooEvent = document.createEvent("CustomEvent");
     16  fooEvent.initEvent(type, true, true);
     17  target.dispatchEvent(fooEvent);
     18 }, "CustomEvent dispatching.");
     19 
     20 test(function() {
     21    var e = document.createEvent("CustomEvent");
     22    assert_throws_js(TypeError, function() {
     23        e.initCustomEvent();
     24    });
     25 }, "First parameter to initCustomEvent should be mandatory.");
     26 
     27 test(function() {
     28    var e = document.createEvent("CustomEvent");
     29    e.initCustomEvent("foo");
     30    assert_equals(e.type, "foo", "type");
     31    assert_false(e.bubbles, "bubbles");
     32    assert_false(e.cancelable, "cancelable");
     33    assert_equals(e.detail, null, "detail");
     34 }, "initCustomEvent's default parameter values.");
     35 </script>