diff --git a/dom/events/CustomEvent.html b/dom/events/CustomEvent.html index c55d5924bd5fe3..abc6c370fd2e87 100644 --- a/dom/events/CustomEvent.html +++ b/dom/events/CustomEvent.html @@ -15,5 +15,21 @@ var fooEvent = document.createEvent("CustomEvent"); fooEvent.initEvent(type, true, true); target.dispatchEvent(fooEvent); -}); +}, "CustomEvent dispatching."); + +test(function() { + var e = document.createEvent("CustomEvent"); + assert_throws(new TypeError(), function() { + e.initCustomEvent(); + }); +}, "First parameter to initCustomEvent should be mandatory."); + +test(function() { + var e = document.createEvent("CustomEvent"); + e.initCustomEvent("foo"); + assert_equals(e.type, "foo", "type"); + assert_false(e.bubbles, "bubbles"); + assert_false(e.cancelable, "cancelable"); + assert_equals(e.detail, null, "detail"); +}, "initCustomEvent's default parameter values."); diff --git a/dom/events/Event-initEvent.html b/dom/events/Event-initEvent.html index 568232a53c1a64..c6b85648a2a457 100644 --- a/dom/events/Event-initEvent.html +++ b/dom/events/Event-initEvent.html @@ -116,4 +116,19 @@ this.done() }, "Calling initEvent during propagation.") + +test(function() { + var e = document.createEvent("Event") + assert_throws(new TypeError(), function() { + e.initEvent() + }) +}, "First parameter to initEvent should be mandatory.") + +test(function() { + var e = document.createEvent("Event") + e.initEvent("type") + assert_equals(e.type, "type", "type") + assert_false(e.bubbles, "bubbles") + assert_false(e.cancelable, "cancelable") +}, "Tests initEvent's default parameter values.") diff --git a/dom/interfaces.html b/dom/interfaces.html index 618eca1f9a1b3d..a8d827bde98a2a 100644 --- a/dom/interfaces.html +++ b/dom/interfaces.html @@ -34,7 +34,7 @@

DOM IDL tests

[Unforgeable] readonly attribute boolean isTrusted; readonly attribute DOMTimeStamp timeStamp; - void initEvent(DOMString type, boolean bubbles, boolean cancelable); + void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); }; dictionary EventInit { @@ -48,7 +48,7 @@

DOM IDL tests

interface CustomEvent : Event { readonly attribute any detail; - void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any detail); + void initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); }; dictionary CustomEventInit : EventInit {