Bug 834165 - Implement BlobEvent. r=smaug
authorRandy Lin <rlin@mozilla.com>
Mon, 18 Feb 2013 14:06:27 +0800
changeset 122214 5474b831ece7011e78cba505d992b11cdd5b2ff4
parent 122213 08fb57d88c011695df9e2eb5c35fc454767b2798
child 122215 b093ba2c7ff9d5ec10ae4e70686f28eef08c3bab
push id23167
push userryanvm@gmail.com
push dateMon, 18 Feb 2013 07:57:50 +0000
treeherdermozilla-inbound@b093ba2c7ff9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs834165
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 834165 - Implement BlobEvent. r=smaug
content/events/test/test_eventctors.html
dom/interfaces/events/Makefile.in
dom/interfaces/events/nsIDOMBlobEvent.idl
dom/tests/mochitest/general/test_interfaces.html
js/xpconnect/src/dictionary_helper_gen.conf
js/xpconnect/src/event_impl_gen.conf.in
--- a/content/events/test/test_eventctors.html
+++ b/content/events/test/test_eventctors.html
@@ -157,16 +157,57 @@ var dict = { get detail() { throw "foo";
 try {
   e = new CustomEvent("hello", dict);
 } catch (exp) {
   ex = true;
 }
 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 {
   e = new CloseEvent();
 } catch(exp) {
   ex = true;
 }
 ok(ex, "First parameter is required!");
--- a/dom/interfaces/events/Makefile.in
+++ b/dom/interfaces/events/Makefile.in
@@ -53,15 +53,16 @@ XPIDLSRCS =					\
 	nsIDOMAnimationEvent.idl		\
 	nsIDOMPopStateEvent.idl			\
 	nsIDOMCloseEvent.idl			\
 	nsIDOMTouchEvent.idl			\
 	nsIDOMHashChangeEvent.idl		\
 	nsIDOMCustomEvent.idl			\
 	nsIDOMCompositionEvent.idl		\
 	nsIDOMWheelEvent.idl			\
+	nsIDOMBlobEvent.idl			\
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 XPIDL_FLAGS += \
   -I$(topsrcdir)/dom/interfaces/base \
   $(NULL)
new file mode 100644
--- /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;
+};
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -527,17 +527,18 @@ var interfaceNamesInGlobalScope =
     "RTCSessionDescription",
     "RTCIceCandidate",
     "RTCPeerConnection",
     "LocalMediaStream",
     "CSSConditionRule",
     "CSSGroupingRule",
     "AsyncScrollEventDetail",
     "MozSmsSegmentInfo",
-    "DOMCursor"
+    "DOMCursor",
+    "BlobEvent"
   ]
 
 for (var i in SpecialPowers.Components.interfaces) {
   var s = i.toString();
   var name = null;
   if (s.indexOf("nsIDOM") == 0) {
     name = s.substring("nsIDOM".length);
   } else if (s.indexOf("nsI") == 0) {
--- a/js/xpconnect/src/dictionary_helper_gen.conf
+++ b/js/xpconnect/src/dictionary_helper_gen.conf
@@ -23,16 +23,18 @@ dictionaries = [
      [ 'ArchiveReaderOptions', 'nsIDOMArchiveReader.idl' ],
      [ 'SmsThreadListItem', 'nsISmsRequest.idl' ]
    ]
 
 # include file names
 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'
   ]
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -36,23 +36,26 @@ simple_events = [
     'MozWifiStatusChangeEvent',
     'MozWifiConnectionInfoEvent',
     'MozCellBroadcastEvent',
     'MozVoicemailEvent',
     'USSDReceivedEvent',
 #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'
   ]