11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<title>CustomEvent</title> 31cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 41cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 51cb0ef41Sopenharmony_ci<div id="log"></div> 61cb0ef41Sopenharmony_ci<script> 71cb0ef41Sopenharmony_citest(function() { 81cb0ef41Sopenharmony_ci var type = "foo"; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci var target = document.createElement("div"); 111cb0ef41Sopenharmony_ci target.addEventListener(type, this.step_func(function(evt) { 121cb0ef41Sopenharmony_ci assert_equals(evt.type, type); 131cb0ef41Sopenharmony_ci }), true); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci var fooEvent = document.createEvent("CustomEvent"); 161cb0ef41Sopenharmony_ci fooEvent.initEvent(type, true, true); 171cb0ef41Sopenharmony_ci target.dispatchEvent(fooEvent); 181cb0ef41Sopenharmony_ci}, "CustomEvent dispatching."); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_citest(function() { 211cb0ef41Sopenharmony_ci var e = document.createEvent("CustomEvent"); 221cb0ef41Sopenharmony_ci assert_throws_js(TypeError, function() { 231cb0ef41Sopenharmony_ci e.initCustomEvent(); 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci}, "First parameter to initCustomEvent should be mandatory."); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_citest(function() { 281cb0ef41Sopenharmony_ci var e = document.createEvent("CustomEvent"); 291cb0ef41Sopenharmony_ci e.initCustomEvent("foo"); 301cb0ef41Sopenharmony_ci assert_equals(e.type, "foo", "type"); 311cb0ef41Sopenharmony_ci assert_false(e.bubbles, "bubbles"); 321cb0ef41Sopenharmony_ci assert_false(e.cancelable, "cancelable"); 331cb0ef41Sopenharmony_ci assert_equals(e.detail, null, "detail"); 341cb0ef41Sopenharmony_ci}, "initCustomEvent's default parameter values."); 351cb0ef41Sopenharmony_ci</script> 36