diff --git a/content/events/test/test_eventctors.html b/content/events/test/test_eventctors.html index a2250055ada5..3c653a03abce 100644 --- a/content/events/test/test_eventctors.html +++ b/content/events/test/test_eventctors.html @@ -162,6 +162,47 @@ try { ok(ex, "Should have thrown an exception!"); ex = false; +// BlobEvent + +try { + e = new BlobEvent(); +} catch(exp) { + ex = true; +} +ok(ex, "First parameter is required!"); +ex = false; + +e = new BlobEvent("hello"); +ok(e.type, "hello", "Wrong event type!"); +ok(!e.isTrusted, "Event shouldn't be trusted!"); +ok(!e.bubbles, "Event shouldn't bubble!"); +ok(!e.cancelable, "Event shouldn't be cancelable!"); +document.dispatchEvent(e); +is(receivedEvent, e, "Wrong event!"); + +var blob = Blob(); +e = new BlobEvent("hello", { bubbles: true, cancelable: true, data: blob }); +ok(e.type, "hello", "Wrong event type!"); +ok(!e.isTrusted, "Event shouldn't be trusted!"); +ok(e.bubbles, "Event should bubble!"); +ok(e.cancelable, "Event should be cancelable!"); +is(e.data, blob , "Wrong event.data!"); +document.dispatchEvent(e); +is(receivedEvent, e, "Wrong event!"); + + +e = new BlobEvent("hello", {data: blob}); +ok(e.type, "hello", "Wrong event type!"); +ok(!e.isTrusted, "Event shouldn't be trusted!"); +ok(!e.bubbles, "Event shouldn't bubble!"); +ok(!e.cancelable, "Event should be cancelable1!"); +is(e.data, blob , "Wrong event.data!"); + +e = new BlobEvent("hello", { data: null }); +is(e.data, null, "Wrong event.data!"); +ok(!e.bubbles, "Event shouldn't bubble!"); +ok(!e.cancelable, "Event shouldn't be cancelable!"); +blob = null; // CloseEvent try { diff --git a/dom/interfaces/events/Makefile.in b/dom/interfaces/events/Makefile.in index 950096a984c7..2d85f87c6f41 100644 --- a/dom/interfaces/events/Makefile.in +++ b/dom/interfaces/events/Makefile.in @@ -58,6 +58,7 @@ XPIDLSRCS = \ nsIDOMCustomEvent.idl \ nsIDOMCompositionEvent.idl \ nsIDOMWheelEvent.idl \ + nsIDOMBlobEvent.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/interfaces/events/nsIDOMBlobEvent.idl b/dom/interfaces/events/nsIDOMBlobEvent.idl new file mode 100644 index 000000000000..bd1b4216ecf9 --- /dev/null +++ b/dom/interfaces/events/nsIDOMBlobEvent.idl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsIDOMEvent.idl" +interface nsIDOMBlob; +/** + * The nsIDOMBlobEvent interface is used for server-sent events + * + * For more information on this interface, please see + * https://dvcs.w3.org/hg/dap/raw-file/tip/media-stream-capture/RecordingProposal.html + */ +[scriptable, builtinclass, uuid(84293ee0-68f5-11e2-9906-cf63ba8c6e43)] +interface nsIDOMBlobEvent : nsIDOMEvent +{ + /** + * Custom blob data associated with this event. + */ + readonly attribute nsIDOMBlob data; + + [noscript] + void initBlobEvent(in DOMString aType, + in boolean aCanBubble, + in boolean aCancelable, + in nsIDOMBlob aData); +}; + +dictionary BlobEventInit : EventInit { + nsIDOMBlob data; +}; diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 83f74799accb..5c89cd904380 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -532,7 +532,8 @@ var interfaceNamesInGlobalScope = "CSSGroupingRule", "AsyncScrollEventDetail", "MozSmsSegmentInfo", - "DOMCursor" + "DOMCursor", + "BlobEvent" ] for (var i in SpecialPowers.Components.interfaces) { diff --git a/js/xpconnect/src/dictionary_helper_gen.conf b/js/xpconnect/src/dictionary_helper_gen.conf index a1fa30d23a93..19a05b56e0ef 100644 --- a/js/xpconnect/src/dictionary_helper_gen.conf +++ b/js/xpconnect/src/dictionary_helper_gen.conf @@ -28,11 +28,13 @@ dictionaries = [ special_includes = [ 'nsContentUtils.h', 'XPCQuickStubs.h', - 'nsIDOMApplicationRegistry.h' + 'nsIDOMApplicationRegistry.h', + 'nsIDOMFile.h' ] # name of the type to not include using #include "typename.h" exclude_automatic_type_include = [ 'nsISupports', - 'mozIDOMApplication' + 'mozIDOMApplication', + 'nsIDOMBlob' ] diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index 2188e7b00951..19180f629ace 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -41,18 +41,21 @@ simple_events = [ #endif 'MozSmsEvent', 'DeviceStorageChangeEvent', - 'PopupBlockedEvent' + 'PopupBlockedEvent', + 'BlobEvent' ] """ include file names """ special_includes = [ 'DictionaryHelpers.h', 'nsContentUtils.h', - 'nsIDOMApplicationRegistry.h' + 'nsIDOMApplicationRegistry.h', + 'nsIDOMFile.h' ] """ name of the type to not include using #include "typename.h" """ exclude_automatic_type_include = [ 'nsISupports', - 'mozIDOMApplication' + 'mozIDOMApplication', + 'nsIDOMBlob' ]