Bug 847611 - Paris bindings for autogenerated events, r=peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 18 Jun 2013 21:48:45 +0300
changeset 146985 3e48ae462b0d93a4d275dff10981b1505f0d1160
parent 146983 dd9245e218125a081c46d35dede11d13f704866f
child 146986 169e58567f28aec5dafcf0392fb062f11fc4b80b
push idunknown
push userunknown
push dateunknown
reviewerspeterv
bugs847611
milestone24.0a1
Bug 847611 - Paris bindings for autogenerated events, r=peterv
dom/base/nsWrapperCache.h
dom/bindings/Bindings.conf
dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json
dom/interfaces/events/nsIDOMCloseEvent.idl
dom/interfaces/events/nsIDOMDeviceLightEvent.idl
dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
dom/webidl/BlobEvent.webidl
dom/webidl/BluetoothDeviceEvent.webidl
dom/webidl/CFStateChangeEvent.webidl
dom/webidl/CallEvent.webidl
dom/webidl/CloseEvent.webidl
dom/webidl/CustomEvent.webidl
dom/webidl/DOMTransactionEvent.webidl
dom/webidl/DataErrorEvent.webidl
dom/webidl/DeviceLightEvent.webidl
dom/webidl/DeviceOrientationEvent.webidl
dom/webidl/DeviceProximityEvent.webidl
dom/webidl/DeviceStorageChangeEvent.webidl
dom/webidl/DummyBinding.webidl
dom/webidl/ElementReplaceEvent.webidl
dom/webidl/GamepadAxisMoveEvent.webidl
dom/webidl/GamepadButtonEvent.webidl
dom/webidl/GamepadEvent.webidl
dom/webidl/HashChangeEvent.webidl
dom/webidl/IccCardLockErrorEvent.webidl
dom/webidl/MozApplicationEvent.webidl
dom/webidl/MozCellBroadcastEvent.webidl
dom/webidl/MozContactChangeEvent.webidl
dom/webidl/MozMmsEvent.webidl
dom/webidl/MozSettingsEvent.webidl
dom/webidl/MozSmsEvent.webidl
dom/webidl/MozVoicemailEvent.webidl
dom/webidl/MozWifiConnectionInfoEvent.webidl
dom/webidl/MozWifiStatusChangeEvent.webidl
dom/webidl/PageTransitionEvent.webidl
dom/webidl/PopStateEvent.webidl
dom/webidl/PopupBlockedEvent.webidl
dom/webidl/ProgressEvent.webidl
dom/webidl/SmartCardEvent.webidl
dom/webidl/SpeechRecognitionError.webidl
dom/webidl/SpeechRecognitionEvent.webidl
dom/webidl/SpeechSynthesisEvent.webidl
dom/webidl/StorageEvent.webidl
dom/webidl/StyleRuleChangeEvent.webidl
dom/webidl/StyleSheetApplicableStateChangeEvent.webidl
dom/webidl/StyleSheetChangeEvent.webidl
dom/webidl/USSDReceivedEvent.webidl
dom/webidl/UserProximityEvent.webidl
dom/webidl/WebIDL.mk
js/xpconnect/src/Makefile.in
js/xpconnect/src/event_impl_gen.conf.in
js/xpconnect/src/event_impl_gen.py
--- a/dom/base/nsWrapperCache.h
+++ b/dom/base/nsWrapperCache.h
@@ -118,17 +118,17 @@ public:
 
   bool PreservingWrapper()
   {
     return HasWrapperFlag(WRAPPER_BIT_PRESERVED);
   }
 
   void SetIsDOMBinding()
   {
-    MOZ_ASSERT(!mWrapper && !GetWrapperFlags(),
+    MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_DOM_BINDING),
                "This flag should be set before creating any wrappers.");
     SetWrapperFlags(WRAPPER_IS_DOM_BINDING);
   }
 
   bool IsDOMBinding() const
   {
     return HasWrapperFlag(WRAPPER_IS_DOM_BINDING);
   }
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1615,16 +1615,17 @@ def addExternalHTMLElement(element):
 
 addExternalHTMLElement('HTMLFormElement')
 addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
                  headerFile='nsIDOMActivityOptions.h')
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
 addExternalIface('DeviceRotationRate', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
+addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
 addExternalIface('CSSRuleList')
 addExternalIface('DOMStringList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('FileCallback', nativeType='nsIFileCallback',
                  headerFile='nsIDOMHTMLCanvasElement.h')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
--- a/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
+++ b/dom/imptests/failures/webapps/DOMCore/tests/approved/test_interfaces.html.json
@@ -29,22 +29,16 @@
   "DOMException exception: constant INVALID_NODE_TYPE_ERR on exception interface prototype object": true,
   "DOMException exception: constant DATA_CLONE_ERR on exception interface prototype object": true,
   "DOMException exception: field code on exception interface prototype object": true,
   "Event interface: document.createEvent(\"Event\") must have own property \"isTrusted\"": true,
   "Event interface: document.createEvent(\"Event\") must inherit property \"timeStamp\" with the proper type (15)": true,
   "Event interface: new Event(\"foo\") must have own property \"isTrusted\"": true,
   "Event interface: new Event(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
   "CustomEvent interface: existence and properties of interface object": true,
-  "CustomEvent interface constructor": true,
-  "CustomEvent interface: existence and properties of interface prototype object": true,
-  "CustomEvent interface: existence and properties of interface prototype object's \"constructor\" property": true,
-  "CustomEvent interface: attribute detail": true,
-  "Stringification of new CustomEvent(\"foo\")": "debug",
-  "CustomEvent interface: calling initCustomEvent(DOMString,boolean,boolean,any) on new CustomEvent(\"foo\") with too few arguments must throw TypeError": true,
   "Event interface: new CustomEvent(\"foo\") must have own property \"isTrusted\"": true,
   "Event interface: new CustomEvent(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
   "MutationObserver interface: operation observe(Node,MutationObserverInit)": true,
   "Document interface: attribute children": true,
   "Document interface: attribute firstElementChild": true,
   "Document interface: attribute lastElementChild": true,
   "Document interface: attribute childElementCount": true,
   "Document interface: operation prepend(union)": true,
--- a/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json
+++ b/dom/imptests/failures/webapps/WebStorage/tests/submissions/Ms2ger/test_missing_arguments.html.json
@@ -3,11 +3,10 @@
   "Should throw TypeError for function \"function () { localStorage.getItem(); }\".": true,
   "Should throw TypeError for function \"function () { localStorage.setItem(); }\".": true,
   "Should throw TypeError for function \"function () { localStorage.setItem(\"a\"); }\".": true,
   "Should throw TypeError for function \"function () { localStorage.removeItem(); }\".": true,
   "Should throw TypeError for function \"function () { sessionStorage.key(); }\".": true,
   "Should throw TypeError for function \"function () { sessionStorage.getItem(); }\".": true,
   "Should throw TypeError for function \"function () { sessionStorage.setItem(); }\".": true,
   "Should throw TypeError for function \"function () { sessionStorage.setItem(\"a\"); }\".": true,
-  "Should throw TypeError for function \"function () { sessionStorage.removeItem(); }\".": true,
-  "Should throw TypeError for function \"function () { new StorageEvent(); }\".": true
+  "Should throw TypeError for function \"function () { sessionStorage.removeItem(); }\".": true
 }
--- a/dom/interfaces/events/nsIDOMCloseEvent.idl
+++ b/dom/interfaces/events/nsIDOMCloseEvent.idl
@@ -1,17 +1,17 @@
 /* -*- 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"
 
 /**
- * The nsIDOMCloseEvent interface is the interface to the event
+ * The CloseEvent interface is the interface to the event
  * close on a WebSocket object.
  *
  * For more information on this interface, please see
  * http://dev.w3.org/html5/websockets/#closeevent
  */
 [scriptable, builtinclass, uuid(0b85dc61-2436-4786-b153-097f5c3a33b6)]
 interface nsIDOMCloseEvent : nsIDOMEvent
 {
--- a/dom/interfaces/events/nsIDOMDeviceLightEvent.idl
+++ b/dom/interfaces/events/nsIDOMDeviceLightEvent.idl
@@ -12,10 +12,10 @@ interface nsIDOMDeviceLightEvent : nsIDO
                                        in boolean cancelableArg,
                                        in double value);
 
   readonly attribute double value;
 };
 
 dictionary DeviceLightEventInit : EventInit
 {
-   double value;
+   double value = Infinity;
 };
--- a/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
+++ b/dom/network/interfaces/nsIDOMCFStateChangeEvent.idl
@@ -5,17 +5,17 @@
 #include "nsIDOMEvent.idl"
 
 [scriptable, builtinclass, uuid(905348f1-3d06-443c-8762-567e7e4b6696)]
 interface nsIDOMCFStateChangeEvent : nsIDOMEvent
 {
   /**
    * Indicates about errors while setting up the Call forwarding rule.
    */
-  readonly attribute bool success;
+  readonly attribute boolean success;
 
   /**
    * Indicates what to do with the rule.
    *
    * One of the CALL_FORWARD_ACTION_* constants. It will be either disable (0),
    * enable (1), query status (2), registration (3), or erasure (4).
    *
    * @see 3GPP nsIDOMMozMobileCFInfo.CALL_FORWARD_ACTION_* values.
--- a/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
+++ b/dom/network/interfaces/nsIDOMUSSDReceivedEvent.idl
@@ -14,11 +14,11 @@ interface nsIDOMUSSDReceivedEvent : nsID
                                         in boolean aCanBubble,
                                         in boolean aCancelable,
                                         in DOMString aMessage,
                                         in boolean aSessionEnded);
 };
 
 dictionary USSDReceivedEventInit : EventInit
 {
-  DOMString message;
+  DOMString? message;
   boolean sessionEnded;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/BlobEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface Blob;
+
+[Constructor(DOMString type, optional BlobEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface BlobEvent : Event
+{
+  readonly attribute Blob? data;
+};
+
+dictionary BlobEventInit : EventInit
+{
+  Blob? data = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/BluetoothDeviceEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface BluetoothDevice;
+
+[Constructor(DOMString type, optional BluetoothDeviceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface BluetoothDeviceEvent : Event
+{
+  readonly attribute BluetoothDevice? device;
+};
+
+dictionary BluetoothDeviceEventInit : EventInit
+{
+  BluetoothDevice? device = null;
+};
--- a/dom/webidl/CFStateChangeEvent.webidl
+++ b/dom/webidl/CFStateChangeEvent.webidl
@@ -1,12 +1,26 @@
+/* -*- 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/. */
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
 
-dictionary CFStateChangeEventDict {
+[Constructor(DOMString type, optional CFStateChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface CFStateChangeEvent : Event
+{
+  readonly attribute boolean success;
+  readonly attribute unsigned short action;
+  readonly attribute unsigned short reason;
+  readonly attribute DOMString? number;
+  readonly attribute unsigned short timeSeconds;
+  readonly attribute unsigned short serviceClass;
+};
+
+dictionary CFStateChangeEventInit : EventInit
+{
   boolean success = false;
-  short action = -1;
-  short reason = -1;
-  DOMString? number = null;
-  short timeSeconds = -1;
-  short serviceClass = -1;
+  unsigned short action = 0;
+  unsigned short reason = 0;
+  DOMString number = "";
+  unsigned short timeSeconds = 0;
+  unsigned short serviceClass = 0;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/CallEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface TelephonyCall;
+
+[Constructor(DOMString type, optional CallEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface CallEvent : Event
+{
+  readonly attribute TelephonyCall? call;
+};
+
+dictionary CallEventInit : EventInit
+{
+  TelephonyCall? call = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/CloseEvent.webidl
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ *
+ * The nsIDOMCloseEvent interface is the interface to the event
+ * close on a WebSocket object.
+ *
+ * For more information on this interface, please see
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#closeevent
+ */
+
+[Constructor(DOMString type, optional CloseEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface CloseEvent : Event
+{
+  readonly attribute boolean wasClean;
+  readonly attribute unsigned short code;
+  readonly attribute DOMString? reason;
+
+  // initCloseEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initCloseEvent(DOMString type,
+                      boolean canBubble,
+                      boolean cancelable,
+                      boolean wasClean,
+                      unsigned short code,
+                      DOMString? reason);
+};
+
+dictionary CloseEventInit : EventInit
+{
+  boolean wasClean = false;
+  unsigned short code = 0;
+  DOMString reason = "";
+};
--- a/dom/webidl/CustomEvent.webidl
+++ b/dom/webidl/CustomEvent.webidl
@@ -1,20 +1,30 @@
 /* -*- 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/.
  *
  * The origin of this IDL file is
  * http://www.w3.org/TR/2012/WD-dom-20120105/
  *
- * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
+ * Copyright  2012 W3C (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Constructor(DOMString type, optional CustomEventInit eventInitDict)]
-interface CustomEvent : Event {
+[Constructor(DOMString type, optional CustomEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface CustomEvent : Event
+{
+  [Throws]
   readonly attribute any detail;
+
+  // initCustomEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initCustomEvent(DOMString type,
+                       boolean canBubble,
+                       boolean cancelable,
+                       any detail);
 };
 
-dictionary CustomEventInit : EventInit {
-  any detail;
+dictionary CustomEventInit : EventInit
+{
+  any detail = null;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DOMTransactionEvent.webidl
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DOMTransactionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DOMTransactionEvent : Event
+{
+  [Throws]
+  readonly attribute any transactions;
+
+  [Throws]
+  void initDOMTransactionEvent(DOMString type,
+                               boolean canBubble,
+                               boolean cancelable,
+                               any transactions);
+};
+
+dictionary DOMTransactionEventInit : EventInit
+{
+  any transactions = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DataErrorEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DataErrorEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DataErrorEvent : Event
+{
+  readonly attribute DOMString? message;
+};
+
+dictionary DataErrorEventInit : EventInit
+{
+  DOMString message = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DeviceLightEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DeviceLightEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DeviceLightEvent : Event
+{
+  readonly attribute double value;
+};
+
+dictionary DeviceLightEventInit : EventInit
+{
+  unrestricted double value = Infinity;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DeviceOrientationEvent.webidl
@@ -0,0 +1,32 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DeviceOrientationEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DeviceOrientationEvent : Event
+{
+  readonly attribute double alpha;
+  readonly attribute double beta;
+  readonly attribute double gamma;
+  readonly attribute boolean absolute;
+
+  // initDeviceOrientationEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initDeviceOrientationEvent(DOMString type,
+                                  boolean canBubble,
+                                  boolean cancelable,
+                                  double alpha,
+                                  double beta,
+                                  double gamma,
+                                  boolean absolute);
+};
+
+dictionary DeviceOrientationEventInit : EventInit
+{
+  double alpha = 0;
+  double beta = 0;
+  double gamma = 0;
+  boolean absolute = false;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DeviceProximityEvent.webidl
@@ -0,0 +1,20 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DeviceProximityEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DeviceProximityEvent : Event
+{
+  readonly attribute double value;
+  readonly attribute double min;
+  readonly attribute double max;
+};
+
+dictionary DeviceProximityEventInit : EventInit
+{
+  unrestricted double value = Infinity;
+  unrestricted double min = -Infinity;
+  unrestricted double max = Infinity;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/DeviceStorageChangeEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional DeviceStorageChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface DeviceStorageChangeEvent : Event
+{
+  readonly attribute DOMString? path;
+  readonly attribute DOMString? reason;
+};
+
+dictionary DeviceStorageChangeEventInit : EventInit
+{
+  DOMString path = "";
+  DOMString reason = "";
+};
--- a/dom/webidl/DummyBinding.webidl
+++ b/dom/webidl/DummyBinding.webidl
@@ -5,18 +5,16 @@
  */
 
 // Dummy bindings that we need to force generation of things that
 // aren't actually referenced anywhere in IDL yet but are used in C++.
 
 interface DummyInterface {
   readonly attribute OnErrorEventHandlerNonNull onErrorEventHandler;
   FilePropertyBag fileBag();
-  CFStateChangeEventDict cfstateChangeEvent();
-  USSDReceivedEventDict ussdReceivedEvent();
   InspectorRGBTriple rgbTriple();
   Function getFunction();
   void funcSocketsDict(optional SocketsDict arg);
   void funcHttpConnDict(optional HttpConnDict arg);
   void funcWebSocketDict(optional WebSocketDict arg);
   void funcDNSCacheDict(optional DNSCacheDict arg);
   void frameRequestCallback(FrameRequestCallback arg);
   void idbObjectStoreParams(optional IDBObjectStoreParameters arg);
new file mode 100644
--- /dev/null
+++ b/dom/webidl/ElementReplaceEvent.webidl
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional ElementReplaceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface ElementReplaceEvent : Event
+{
+  readonly attribute Element? upgrade;
+
+  // initElementReplaceEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initElementReplaceEvent(DOMString type,
+                               boolean canBubble,
+                               boolean cancelable,
+                               Element? upgrade);
+};
+
+dictionary ElementReplaceEventInit : EventInit
+{
+  Element? upgrade = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/GamepadAxisMoveEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface GamepadAxisMoveEvent : GamepadEvent
+{
+  readonly attribute unsigned long axis;
+  readonly attribute double value;
+};
+
+dictionary GamepadAxisMoveEventInit : GamepadEventInit
+{
+  unsigned long axis = 0;
+  double value = 0;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/GamepadButtonEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface GamepadButtonEvent : GamepadEvent
+{
+  readonly attribute unsigned long button;
+};
+
+dictionary GamepadButtonEventInit : GamepadEventInit
+{
+  unsigned long button = 0;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/GamepadEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional GamepadEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface GamepadEvent : Event
+{
+  readonly attribute Gamepad? gamepad;
+};
+
+dictionary GamepadEventInit : EventInit
+{
+  Gamepad? gamepad = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HashChangeEvent.webidl
@@ -0,0 +1,26 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface HashChangeEvent : Event
+{
+  readonly attribute DOMString? oldURL;
+  readonly attribute DOMString? newURL;
+
+  // initHashChangeEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initHashChangeEvent(DOMString type,
+                           boolean canBubble,
+                           boolean cancelable,
+                           DOMString? oldURL,
+                           DOMString? newURL);
+};
+
+dictionary HashChangeEventInit : EventInit
+{
+  DOMString oldURL = "";
+  DOMString newURL = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/IccCardLockErrorEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional IccCardLockErrorEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface IccCardLockErrorEvent : Event
+{
+  readonly attribute DOMString? lockType;
+  readonly attribute long retryCount;
+};
+
+dictionary IccCardLockErrorEventInit : EventInit
+{
+  DOMString lockType = "";
+  long retryCount = 0;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozApplicationEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface mozIDOMApplication;
+
+[Constructor(DOMString type, optional MozApplicationEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozApplicationEvent : Event
+{
+  readonly attribute mozIDOMApplication? application;
+};
+
+dictionary MozApplicationEventInit : EventInit
+{
+  mozIDOMApplication? application = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozCellBroadcastEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface MozCellBroadcastMessage;
+
+[Constructor(DOMString type, optional MozCellBroadcastEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozCellBroadcastEvent : Event
+{
+  readonly attribute MozCellBroadcastMessage? message;
+};
+
+dictionary MozCellBroadcastEventInit : EventInit
+{
+  MozCellBroadcastMessage? message = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozContactChangeEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional MozContactChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozContactChangeEvent : Event
+{
+  readonly attribute DOMString? contactID;
+  readonly attribute DOMString? reason;
+};
+
+dictionary MozContactChangeEventInit : EventInit
+{
+  DOMString contactID = "";
+  DOMString reason = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozMmsEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface MozMmsMessage;
+
+[Constructor(DOMString type, optional MozMmsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozMmsEvent : Event
+{
+  readonly attribute MozMmsMessage? message;
+};
+
+dictionary MozMmsEventInit : EventInit
+{
+  MozMmsMessage? message = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozSettingsEvent.webidl
@@ -0,0 +1,19 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional MozSettingsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozSettingsEvent : Event
+{
+  readonly attribute DOMString? settingName;
+  [Throws]
+  readonly attribute any settingValue;
+};
+
+dictionary MozSettingsEventInit : EventInit
+{
+  DOMString settingName = "";
+  any settingValue = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozSmsEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface MozSmsMessage;
+
+[Constructor(DOMString type, optional MozSmsEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozSmsEvent : Event
+{
+  readonly attribute MozSmsMessage? message;
+};
+
+dictionary MozSmsEventInit : EventInit
+{
+  MozSmsMessage? message = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozVoicemailEvent.webidl
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+interface MozVoicemailStatus;
+
+[Constructor(DOMString type, optional MozVoicemailEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozVoicemailEvent : Event
+{
+  readonly attribute MozVoicemailStatus? status;
+};
+
+dictionary MozVoicemailEventInit : EventInit
+{
+  MozVoicemailStatus? status = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozWifiConnectionInfoEvent.webidl
@@ -0,0 +1,25 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional MozWifiConnectionInfoEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozWifiConnectionInfoEvent : Event
+{
+  [Throws]
+  readonly attribute any network;
+  readonly attribute short signalStrength;
+  readonly attribute short relSignalStrength;
+  readonly attribute long linkSpeed;
+  readonly attribute DOMString? ipAddress;
+};
+
+dictionary MozWifiConnectionInfoEventInit : EventInit
+{
+  any network = null;
+  short signalStrength = 0;
+  short relSignalStrength = 0;
+  long linkSpeed = 0;
+  DOMString ipAddress = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MozWifiStatusChangeEvent.webidl
@@ -0,0 +1,19 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional MozWifiStatusChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface MozWifiStatusChangeEvent : Event
+{
+  [Throws]
+  readonly attribute any network;
+  readonly attribute DOMString? status;
+};
+
+dictionary MozWifiStatusChangeEventInit : EventInit
+{
+  any network = null;
+  DOMString status = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PageTransitionEvent.webidl
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional PageTransitionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface PageTransitionEvent : Event
+{
+  readonly attribute boolean persisted;
+
+  // initPageTransitionEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initPageTransitionEvent(DOMString type,
+                               boolean canBubble,
+                               boolean cancelable,
+                               boolean persisted);
+};
+
+dictionary PageTransitionEventInit : EventInit
+{
+  boolean persisted = false;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PopStateEvent.webidl
@@ -0,0 +1,24 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional PopStateEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface PopStateEvent : Event
+{
+  [Throws]
+  readonly attribute any state;
+
+  // initPopStateEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initPopStateEvent(DOMString type,
+                         boolean canBubble,
+                         boolean cancelable,
+                         any state);
+};
+
+dictionary PopStateEventInit : EventInit
+{
+  any state = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/PopupBlockedEvent.webidl
@@ -0,0 +1,33 @@
+/* -*- 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/.
+ */
+interface Window;
+interface URI;
+
+[Constructor(DOMString type, optional PopupBlockedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface PopupBlockedEvent : Event
+{
+  readonly attribute Window? requestingWindow;
+  readonly attribute URI? popupWindowURI;
+  readonly attribute DOMString? popupWindowName;
+  readonly attribute DOMString? popupWindowFeatures;
+
+  [Throws]
+  void initPopupBlockedEvent(DOMString type,
+                             boolean canBubble,
+                             boolean cancelable,
+                             Window? requestingWindow,
+                             URI? popupWindowURI,
+                             DOMString? popupWindowName,
+                             DOMString? popupWindowFeatures);
+};
+
+dictionary PopupBlockedEventInit : EventInit
+{
+  Window? requestingWindow = null;
+  URI? popupWindowURI = null;
+  DOMString popupWindowName = "";
+  DOMString popupWindowFeatures = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/ProgressEvent.webidl
@@ -0,0 +1,20 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional ProgressEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface ProgressEvent : Event
+{
+  readonly attribute boolean lengthComputable;
+  readonly attribute unsigned long long loaded;
+  readonly attribute unsigned long long total;
+};
+
+dictionary ProgressEventInit : EventInit
+{
+  boolean lengthComputable = false;
+  unsigned long long loaded = 0;
+  unsigned long long total = 0;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SmartCardEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional SmartCardEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface SmartCardEvent : Event
+{
+  readonly attribute DOMString? tokenName;
+};
+
+dictionary SmartCardEventInit : EventInit
+{
+  DOMString tokenName = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SpeechRecognitionError.webidl
@@ -0,0 +1,27 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional SpeechRecognitionErrorInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface SpeechRecognitionError : Event
+{
+  const unsigned long NO_SPEECH = 0;
+  const unsigned long ABORTED = 1;
+  const unsigned long AUDIO_CAPTURE = 2;
+  const unsigned long NETWORK = 3;
+  const unsigned long NOT_ALLOWED = 4;
+  const unsigned long SERVICE_NOT_ALLOWED = 5;
+  const unsigned long BAD_GRAMMAR = 6;
+  const unsigned long LANGUAGE_NOT_SUPPORTED = 7;
+
+  readonly attribute unsigned long error;
+  readonly attribute DOMString? message;
+};
+
+dictionary SpeechRecognitionErrorInit : EventInit
+{
+  unsigned long error = 0;
+  DOMString message = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/SpeechRecognitionEvent.webidl
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+interface nsISupports;
+
+[Constructor(DOMString type, optional SpeechRecognitionEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface SpeechRecognitionEvent : Event
+{
+  readonly attribute unsigned long resultIndex;
+  readonly attribute nsISupports? results;
+  readonly attribute DOMString? interpretation;
+  readonly attribute Document? emma;
+};
+
+dictionary SpeechRecognitionEventInit : EventInit
+{
+  unsigned long resultIndex = 0;
+  nsISupports? results = null;
+  DOMString interpretation = "";
+  Document? emma = null;
+};
--- a/dom/webidl/SpeechSynthesisEvent.webidl
+++ b/dom/webidl/SpeechSynthesisEvent.webidl
@@ -4,15 +4,23 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is
  * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
-interface Event;
 
-interface SpeechSynthesisEvent : Event {
+[Constructor(DOMString type, optional SpeechSynthesisEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface SpeechSynthesisEvent : Event
+{
   readonly attribute unsigned long charIndex;
   readonly attribute float elapsedTime;
-  readonly attribute DOMString name;
+  readonly attribute DOMString? name;
 };
+
+dictionary SpeechSynthesisEventInit : EventInit
+{
+  unsigned long charIndex = 0;
+  float elapsedTime = 0;
+  DOMString name = "";
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/StorageEvent.webidl
@@ -0,0 +1,42 @@
+/* -*- 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/.
+ *
+ * Interface for a client side storage. See
+ * http://dev.w3.org/html5/webstorage/#the-storage-event
+ * for more information.
+ *
+ * Event sent to a window when a storage area changes.
+ */
+interface Storage;
+
+[Constructor(DOMString type, optional StorageEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface StorageEvent : Event
+{
+  readonly attribute DOMString? key;
+  readonly attribute DOMString? oldValue;
+  readonly attribute DOMString? newValue;
+  readonly attribute DOMString? url;
+  readonly attribute Storage? storageArea;
+
+  // initStorageEvent is a Gecko specific deprecated method.
+  [Throws]
+  void initStorageEvent(DOMString type,
+                        boolean canBubble,
+                        boolean cancelable,
+                        DOMString? key,
+                        DOMString? oldValue,
+                        DOMString? newValue,
+                        DOMString? url,
+                        Storage? storageArea);
+};
+
+dictionary StorageEventInit : EventInit
+{
+  DOMString? key = null;
+  DOMString? oldValue = null;
+  DOMString? newValue = null;
+  DOMString url = "";
+  Storage? storageArea = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/StyleRuleChangeEvent.webidl
@@ -0,0 +1,19 @@
+/* -*- 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/.
+ */
+interface CSSRule;
+
+[Constructor(DOMString type, optional StyleRuleChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface StyleRuleChangeEvent : Event
+{
+  readonly attribute CSSStyleSheet? stylesheet;
+  readonly attribute CSSRule? rule;
+};
+
+dictionary StyleRuleChangeEventInit : EventInit
+{
+  CSSStyleSheet? stylesheet = null;
+  CSSRule? rule = null;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/StyleSheetApplicableStateChangeEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional StyleSheetApplicableStateChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface StyleSheetApplicableStateChangeEvent : Event
+{
+  readonly attribute CSSStyleSheet? stylesheet;
+  readonly attribute boolean applicable;
+};
+
+dictionary StyleSheetApplicableStateChangeEventInit : EventInit
+{
+  CSSStyleSheet? stylesheet = null;
+  boolean applicable = false;
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/StyleSheetChangeEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional StyleSheetChangeEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface StyleSheetChangeEvent : Event
+{
+  readonly attribute CSSStyleSheet? stylesheet;
+  readonly attribute boolean documentSheet;
+};
+
+dictionary StyleSheetChangeEventInit : EventInit
+{
+  CSSStyleSheet? stylesheet = null;
+  boolean documentSheet = false;
+};
--- a/dom/webidl/USSDReceivedEvent.webidl
+++ b/dom/webidl/USSDReceivedEvent.webidl
@@ -1,10 +1,18 @@
 /* -*- 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/.
  */
 
-dictionary USSDReceivedEventDict {
+[Constructor(DOMString type, optional USSDReceivedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface USSDReceivedEvent : Event
+{
+  readonly attribute DOMString? message;
+  readonly attribute boolean sessionEnded;
+};
+
+dictionary USSDReceivedEventInit : EventInit
+{
   DOMString? message = null;
   boolean sessionEnded = false;
-};
\ No newline at end of file
+};
new file mode 100644
--- /dev/null
+++ b/dom/webidl/UserProximityEvent.webidl
@@ -0,0 +1,16 @@
+/* -*- 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/.
+ */
+
+[Constructor(DOMString type, optional UserProximityEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
+interface UserProximityEvent : Event
+{
+  readonly attribute boolean near;
+};
+
+dictionary UserProximityEventInit : EventInit
+{
+  boolean near = false;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -27,17 +27,16 @@ webidl_files = \
   BatteryManager.webidl \
   BeforeUnloadEvent.webidl \
   BiquadFilterNode.webidl \
   Blob.webidl \
   CameraManager.webidl \
   CanvasRenderingContext2D.webidl \
   CaretPosition.webidl \
   CDATASection.webidl \
-  CFStateChangeEvent.webidl \
   ChannelMergerNode.webidl \
   ChannelSplitterNode.webidl \
   CharacterData.webidl \
   ChildNode.webidl \
   ClientRect.webidl \
   ClientRectList.webidl \
   ClipboardEvent.webidl \
   CommandEvent.webidl \
@@ -339,17 +338,16 @@ webidl_files = \
   UIEvent.webidl \
   URL.webidl \
   ValidityState.webidl \
   WebComponents.webidl \
   WebSocket.webidl \
   WheelEvent.webidl \
   UndoManager.webidl \
   URLUtils.webidl \
-  USSDReceivedEvent.webidl \
   VideoStreamTrack.webidl \
   WaveShaperNode.webidl \
   WaveTable.webidl \
   Window.webidl \
   XMLDocument.webidl \
   XMLHttpRequest.webidl \
   XMLHttpRequestEventTarget.webidl \
   XMLHttpRequestUpload.webidl \
@@ -386,31 +384,95 @@ webidl_files += \
   SpeechGrammarList.webidl \
   SpeechRecognitionAlternative.webidl \
   SpeechRecognitionResultList.webidl \
   SpeechRecognitionResult.webidl \
   SpeechRecognition.webidl \
   SpeechSynthesisUtterance.webidl \
   SpeechSynthesisVoice.webidl \
   SpeechSynthesis.webidl \
+  SpeechSynthesisEvent.webidl \
   $(NULL)
 endif
 
 ifdef MOZ_GAMEPAD
 webidl_files += \
   Gamepad.webidl \
   $(NULL)
 endif
 
 ifdef MOZ_B2G_RIL
 webidl_files += \
   MozStkCommandEvent.webidl \
   $(NULL)
 endif
 
+webidl_files += \
+  ProgressEvent.webidl \
+  StorageEvent.webidl \
+  DeviceProximityEvent.webidl \
+  MozSettingsEvent.webidl \
+  UserProximityEvent.webidl \
+  CustomEvent.webidl \
+  PageTransitionEvent.webidl \
+  DOMTransactionEvent.webidl \
+  PopStateEvent.webidl \
+  HashChangeEvent.webidl \
+  CloseEvent.webidl \
+  MozContactChangeEvent.webidl \
+  DeviceOrientationEvent.webidl \
+  DeviceLightEvent.webidl \
+  MozApplicationEvent.webidl \
+  SmartCardEvent.webidl \
+  StyleRuleChangeEvent.webidl \
+  StyleSheetChangeEvent.webidl \
+  StyleSheetApplicableStateChangeEvent.webidl \
+  ElementReplaceEvent.webidl \
+  MozSmsEvent.webidl \
+  MozMmsEvent.webidl \
+  DeviceStorageChangeEvent.webidl \
+  PopupBlockedEvent.webidl \
+  BlobEvent.webidl \
+  $(NULL)
+
+ifdef MOZ_B2G_BT
+webidl_files += \
+  BluetoothDeviceEvent.webidl \
+  $(NULL)
+endif
+
+ifdef MOZ_B2G_RIL
+webidl_files += \
+  CallEvent.webidl \
+  CFStateChangeEvent.webidl \
+  DataErrorEvent.webidl \
+  IccCardLockErrorEvent.webidl \
+  MozWifiStatusChangeEvent.webidl \
+  MozWifiConnectionInfoEvent.webidl \
+  MozCellBroadcastEvent.webidl \
+  MozVoicemailEvent.webidl \
+  USSDReceivedEvent.webidl \
+  $(NULL)
+endif
+
+ifdef MOZ_GAMEPAD
+webidl_files += \
+  GamepadEvent.webidl \
+  GamepadButtonEvent.webidl \
+  GamepadAxisMoveEvent.webidl \
+  $(NULL)
+endif
+
+ifdef MOZ_WEBSPEECH
+webidl_files += \
+  SpeechRecognitionEvent.webidl \
+  SpeechRecognitionError.webidl \
+  $(NULL)
+endif
+
 ifdef ENABLE_TESTS
 test_webidl_files := \
   TestCodeGen.webidl \
   TestDictionary.webidl \
   TestExampleGen.webidl \
   TestJSImplGen.webidl \
   TestJSImplInheritanceGen.webidl \
   TestTypedef.webidl \
--- a/js/xpconnect/src/Makefile.in
+++ b/js/xpconnect/src/Makefile.in
@@ -112,48 +112,62 @@ GeneratedEvents.h: $(srcdir)/dictionary_
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  -I$(LIBXUL_DIST)/sdk/bin \
 	  $(srcdir)/event_impl_gen.py \
 	  -I $(DEPTH)/dist/idl \
 	  --header-output GeneratedEvents.h \
 	  event_impl_gen.conf
 
+GeneratedEventClasses.h: GeneratedEvents.cpp
+
 GeneratedEvents.cpp: DictionaryHelpers.h \
+                     GeneratedEvents.h \
                      $(srcdir)/dictionary_helper_gen.conf \
                      event_impl_gen.conf \
                      $(srcdir)/dictionary_helper_gen.py \
                      $(srcdir)/event_impl_gen.py \
                      $(LIBXUL_DIST)/sdk/bin/header.py \
                      $(LIBXUL_DIST)/sdk/bin/xpidl.py \
                      $(DEPTH)/js/src/js-confdefs.h
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  -I$(LIBXUL_DIST)/sdk/bin \
 	  $(srcdir)/event_impl_gen.py \
 	  -I $(DEPTH)/dist/idl \
-	  --header-output GeneratedEvents.h \
+	  --class-declarations GeneratedEventClasses.h \
 	  --stub-output GeneratedEvents.cpp \
 	  --makedepend-output $(MDDEPDIR)/event_impl_gen.pp \
 	  event_impl_gen.conf
 
+GeneratedEvents-webidl: event_impl_gen.conf
+	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
+	  $(PLY_INCLUDE) \
+	  -I$(LIBXUL_DIST)/sdk/bin \
+	  $(srcdir)/event_impl_gen.py \
+	  -I $(DEPTH)/dist/idl \
+	  --webidltarget=$(top_srcdir)/dom/webidl \
+	  event_impl_gen.conf
+
 _EXTRA_EXPORT_FILES = \
   DictionaryHelpers.h \
+  GeneratedEventClasses.h \
   $(NULL)
 
 libs:: $(_EXTRA_EXPORT_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/dist/include
 
 GARBAGE += \
 		dom_quickstubs.h \
 		dom_quickstubs.cpp \
 		DictionaryHelpers.h \
 		DictionaryHelpers.cpp \
 		GeneratedEvents.h \
 		GeneratedEvents.cpp \
+		GeneratedEventClasses.h \
 		event_impl_gen.conf \
 		xpidl_debug \
 		$(MDDEPDIR)/dom_qsgen.pp \
 		$(MDDEPDIR)/dombindingsgen.pp \
 		$(MDDEPDIR)/dictionary_helper_gen.pp \
 		$(MDDEPDIR)/event_impl_gen.pp \
 		$(wildcard $(topsrcdir)/other-licenses/ply/ply/*.pyc) \
 		$(NULL)
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -70,8 +70,17 @@ special_includes = [
   ]
 
 """ name of the type to not include using #include "typename.h" """
 exclude_automatic_type_include = [
     'nsISupports',
     'mozIDOMApplication',
     'nsIDOMBlob'
   ]
+
+""" Map xpidl interface names to implementation classes. The third column is the canonical interface. """
+xpidl_to_native = [
+    ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'],
+    ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'],
+    ['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'],
+    ['nsIDOMGamepad', 'nsDOMGamepad', 'nsIDOMGamepad']
+  ]
+
--- a/js/xpconnect/src/event_impl_gen.py
+++ b/js/xpconnect/src/event_impl_gen.py
@@ -18,47 +18,56 @@ def findIDL(includePath, interfaceFileNa
         # this filename ends up in makedepend output.
         path = d + '/' + interfaceFileName
         if os.path.exists(path):
             return path
     raise BaseException("No IDL file found for interface %s "
                         "in include path %r"
                         % (interfaceFileName, includePath))
 
+eventFileNameToIdl = {};
+
 def loadIDL(parser, includePath, filename):
+    global eventFileNameToIdl
+    if filename in eventFileNameToIdl:
+        return eventFileNameToIdl[filename]
+
     idlFile = findIDL(includePath, filename)
     if not idlFile in makeutils.dependencies:
         makeutils.dependencies.append(idlFile)
     idl = p.parse(open(idlFile).read(), idlFile)
     idl.resolve(includePath, p)
+    eventFileNameToIdl[filename] = idl
     return idl
 
 def loadEventIDL(parser, includePath, eventname):
     eventidl = ("nsIDOM%s.idl" % eventname)
-    idlFile = findIDL(includePath, eventidl)
-    if not idlFile in makeutils.dependencies:
-        makeutils.dependencies.append(idlFile)
-    idl = p.parse(open(idlFile).read(), idlFile)
-    idl.resolve(includePath, p)
-    return idl
+    return loadIDL(parser, includePath, eventidl)
 
 class Configuration:
     def __init__(self, filename):
         config = {}
         execfile(filename, config)
         self.simple_events = config.get('simple_events', [])
         self.special_includes = config.get('special_includes', [])
         self.exclude_automatic_type_include = config.get('exclude_automatic_type_include', [])
+        self.xpidl_to_native = config.get('xpidl_to_native', [])
 
 def readConfigFile(filename):
     return Configuration(filename)
 
 def firstCap(str):
     return str[0].upper() + str[1:]
 
+def getBaseName(iface):
+    basename = ("%s" % iface.base[6:])
+    if (basename == "Event"):
+        basename = "nsDOMEvent"
+    return basename
+
 def print_header_file(fd, conf):
     fd.write("#if defined MOZ_GENERATED_EVENT_LIST\n")
     for e in conf.simple_events:
         fd.write("MOZ_GENERATED_EVENT(%s)\n" % e);
     fd.write("#undef MOZ_GENERATED_EVENT\n");
     fd.write("\n#elif defined MOZ_GENERATED_EVENTS_INCLUDES\n")
     for e in conf.simple_events:
         fd.write("#include \"nsIDOM%s.h\"\n" % e)
@@ -79,16 +88,148 @@ def print_header_file(fd, conf):
         fd.write("nsresult\n")
         fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, " % e)
         fd.write("mozilla::dom::EventTarget* aOwner, ")
         fd.write("nsPresContext* aPresContext, nsEvent* aEvent);\n")
  
     fd.write("\n#endif\n")
     fd.write("#endif\n")
 
+def print_classes_file(fd, conf):
+    fd.write("#ifndef _gen_mozilla_idl_generated_event_declarations_h_\n")
+    fd.write("#define _gen_mozilla_idl_generated_event_declarations_h_\n\n")
+
+    fd.write("#include \"nsDOMEvent.h\"\n");
+    includes = []
+    for s in conf.special_includes:
+        if not s in includes:
+            includes.append(strip_end(s, ".h"))
+
+    for e in conf.simple_events:
+        if not e in includes:
+            includes.append(("nsIDOM%s" % e))
+
+    attrnames = []
+    for e in conf.simple_events:
+        idl = loadEventIDL(p, options.incdirs, e)
+        collect_names_and_non_primitive_attribute_types(idl, attrnames, includes)
+
+    for c in includes:
+      if not c in conf.exclude_automatic_type_include:
+            fd.write("#include \"%s.h\"\n" % c)
+
+    for e in conf.simple_events:
+        fd.write('#include "mozilla/dom/%sBinding.h"\n' % e);
+
+    fd.write("namespace mozilla {\n")
+    fd.write("namespace dom {\n")
+    for e in conf.simple_events:
+        idl = loadEventIDL(p, options.incdirs, e)
+        for pr in idl.productions:
+            if pr.kind == 'interface':
+                print_class_declaration(e, pr, fd, conf)
+    fd.write("} // namespace dom\n")
+    fd.write("} // namespace mozilla\n\n")
+    fd.write("#endif\n");
+
+def print_class_declaration(eventname, iface, fd, conf):
+    classname = ("%s" % eventname)
+    basename = getBaseName(iface)
+    attributes = []
+    ccattributes = []
+    for member in iface.members:
+        if isinstance(member, xpidl.Attribute):
+            attributes.append(member)
+            if (member.realtype.nativeType('in').endswith('*')):
+                ccattributes.append(member);
+
+    baseinterfaces = []
+    baseiface = iface.idl.getName(iface.base, iface.location)
+    while baseiface.name != "nsIDOMEvent":
+        baseinterfaces.append(baseiface)
+        baseiface = baseiface.idl.getName(baseiface.base, baseiface.location)
+    baseinterfaces.reverse()
+
+    allattributes = []
+    for baseiface in baseinterfaces:
+        for member in baseiface.members:
+            if isinstance(member, xpidl.Attribute):
+                allattributes.append(member)
+    allattributes.extend(attributes);
+
+    fd.write("\nclass %s : public %s, public %s\n" % (classname, basename, iface.name))
+    fd.write("{\n")
+    fd.write("public:\n")
+    fd.write("  %s(mozilla::dom::EventTarget* aOwner, " % classname)
+    fd.write("nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr);\n");
+    fd.write("  virtual ~%s();\n\n" % classname)
+    fd.write("  NS_DECL_ISUPPORTS_INHERITED\n")
+    fd.write("  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename))
+    fd.write("  NS_FORWARD_TO_NSDOMEVENT\n")
+
+    for baseiface in baseinterfaces:
+        baseimpl = ("%s" % baseiface.name[6:])
+        if (baseimpl == "Event"):
+            baseimpl = "nsDOMEvent"
+        fd.write("  NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl))
+
+    fd.write("  NS_DECL_%s\n" % iface.name.upper())
+    fd.write("  virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n\n")
+
+    hasVariant = False
+    for a in allattributes:
+        if a.type == "nsIVariant":
+            hasVariant = True
+            break;
+    fd.write("  static already_AddRefed<%s> Constructor(const GlobalObject& aGlobal, " % eventname)
+    if hasVariant:
+        fd.write("JSContext* aCx, ")
+    fd.write("const nsAString& aType, ")
+    fd.write("const %sInit& aParam, " % eventname)
+    fd.write("ErrorResult& aRv);\n\n")
+
+    fd.write("  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE\n")
+    fd.write("  {\n")
+    fd.write("    return mozilla::dom::%sBinding::Wrap(aCx, aScope, this);\n" % eventname)
+    fd.write("  }\n\n")
+
+    for a in attributes:
+        """xpidl methods take care of string member variables!"""
+        firstCapName = firstCap(a.name)
+        cleanNativeType = a.realtype.nativeType('in').strip('* ')
+        if a.realtype.nativeType('in').count("nsAString"):
+            continue
+        elif a.realtype.nativeType('in').count("nsIVariant"):
+            fd.write("  JS::Value Get%s(JSContext* aCx, ErrorResult& aRv);\n\n" % firstCapName);
+        elif a.realtype.nativeType('in').endswith('*'):
+            fd.write("  already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName))
+            fd.write("  {\n");
+            fd.write("    nsCOMPtr<%s> %s = do_QueryInterface(m%s);\n" % (xpidl_to_canonical(cleanNativeType, conf), a.name, firstCapName))
+            fd.write("    return %s.forget().downcast<%s>();\n" % (a.name, xpidl_to_native(cleanNativeType, conf)))
+            fd.write("  }\n\n");
+        else:
+            fd.write("  %s %s()\n" % (cleanNativeType, firstCapName))
+            fd.write("  {\n");
+            fd.write("    return m%s;\n" % firstCapName)
+            fd.write("  }\n\n");
+
+    fd.write("  void ")
+    fd.write("Init%s(" % eventname)
+    if hasVariant:
+        fd.write("JSContext* aCx, ")
+    fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable")
+    for a in allattributes:
+        writeNativeAttributeParams(fd, a, conf)
+    fd.write(", ErrorResult& aRv);\n\n")
+
+    fd.write("protected:\n")
+    for a in attributes:
+        fd.write("  %s\n" % attributeVariableTypeAndName(a))
+    fd.write("};\n")
+
 def collect_names_and_non_primitive_attribute_types(idl, attrnames, forwards):
     for p in idl.productions:
         if p.kind == 'interface' or p.kind == 'dictionary':
             interfaces = []
             base = p.base
             baseiface = p
             while base is not None:
                 baseiface = baseiface.idl.getName(baseiface.base, baseiface.location)    
@@ -109,49 +250,30 @@ def collect_names_and_non_primitive_attr
             if member.realtype.nativeType('in').endswith('*'):
                 t = member.realtype.nativeType('in').strip('* ')
                 if not t in forwards:
                     forwards.append(t)
 
 def print_cpp(idl, fd, conf, eventname):
     for p in idl.productions:
         if p.kind == 'interface':
-            write_cpp(eventname, p, fd)
+            write_cpp(eventname, p, fd, conf)
 
 def print_cpp_file(fd, conf):
     fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n")
-    fd.write('#include "GeneratedEvents.h"\n')
+    fd.write('#include "GeneratedEventClasses.h"\n')
+    fd.write('#include "xpcprivate.h"\n');
     fd.write('#include "nsDOMClassInfoID.h"\n')
     fd.write('#include "nsPresContext.h"\n')
     fd.write('#include "nsGUIEvent.h"\n')
     fd.write('#include "nsDOMEvent.h"\n');
     fd.write('#include "mozilla/dom/EventTarget.h"\n');
 
-    includes = []
-    for s in conf.special_includes:
-        if not s in includes:
-            includes.append(strip_end(s, ".h"))
-    
-    for e in conf.simple_events:
-        if not e in includes:
-            includes.append(("nsIDOM%s" % e))
-
-    attrnames = []
     for e in conf.simple_events:
         idl = loadEventIDL(p, options.incdirs, e)
-        collect_names_and_non_primitive_attribute_types(idl, attrnames, includes)
-    
-    for c in includes:
-      if not c in conf.exclude_automatic_type_include:
-            fd.write("#include \"%s.h\"\n" % c)
-
-    for e in conf.simple_events:
-        idlname = ("nsIDOM%s.idl" % e)
-        idl = p.parse(open(findIDL(options.incdirs, idlname)).read(), idlname)
-        idl.resolve(options.incdirs, p)
         print_cpp(idl, fd, conf, e)
 
 def init_value(attribute):
     realtype = attribute.realtype.nativeType('in')
     realtype = realtype.strip(' ')
     if realtype.endswith('*'):
         return "nullptr"
     if realtype == "bool":
@@ -192,33 +314,56 @@ def writeAttributeGetter(fd, classname, 
     fd.write("{\n");
     if a.realtype.nativeType('in').endswith('*'):
         fd.write("  NS_IF_ADDREF(*a%s = m%s);\n" % (firstCap(a.name), firstCap(a.name)))
     elif a.realtype.nativeType('in').count("nsAString"):
         fd.write("  a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
     elif a.realtype.nativeType('in').count("nsACString"):
         fd.write("  a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
     else:
-        fd.write("  *a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
+        fd.write("  *a%s = %s();\n" % (firstCap(a.name), firstCap(a.name)))
     fd.write("  return NS_OK;\n");
     fd.write("}\n\n");
+    if a.realtype.nativeType('in').count("nsIVariant"):
+        fd.write("JS::Value\n")
+        fd.write("%s::Get%s(JSContext* aCx, ErrorResult& aRv)\n" % (classname, firstCap(a.name)))
+        fd.write("{\n")
+        fd.write("  JS::Rooted<JS::Value> retVal(aCx, JS::NullValue());\n");
+        fd.write("  nsresult rv = NS_ERROR_UNEXPECTED;\n")
+        fd.write("  if (m%s && !XPCVariant::VariantDataToJS(m%s, &rv, retVal.address())) {\n" % (firstCap(a.name), firstCap(a.name)))
+        fd.write("    aRv.Throw(NS_ERROR_FAILURE);\n")
+        fd.write("  }\n")
+        fd.write("  return retVal;\n");
+        fd.write("}\n\n")
 
 def writeAttributeParams(fd, a):
     if a.realtype.nativeType('in').endswith('*'):
         fd.write(", %s* a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name)))
     elif a.realtype.nativeType('in').count("nsAString"):
         fd.write(", const nsAString& a%s" % firstCap(a.name))
     elif a.realtype.nativeType('in').count("nsACString"):
         fd.write(", const nsACString& a%s" % firstCap(a.name))
     else:
         fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name)))
 
-def write_cpp(eventname, iface, fd):
-    classname = ("nsDOM%s" % eventname)
-    basename = ("ns%s" % iface.base[3:])
+def writeNativeAttributeParams(fd, a, conf):
+    if a.type == "nsIVariant":
+        fd.write(", JS::Value a%s" % firstCap(a.name));
+    elif a.realtype.nativeType('in').endswith('*'):
+        fd.write(", %s* a%s" % (xpidl_to_native(a.realtype.nativeType('in').strip('* '), conf), firstCap(a.name)))
+    elif a.realtype.nativeType('in').count("nsAString"):
+        fd.write(", const nsAString& a%s" % firstCap(a.name))
+    elif a.realtype.nativeType('in').count("nsACString"):
+        fd.write(", const nsACString& a%s" % firstCap(a.name))
+    else:
+        fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name)))
+
+def write_cpp(eventname, iface, fd, conf):
+    classname = ("%s" % eventname)
+    basename = getBaseName(iface)
     attributes = []
     ccattributes = []
     for member in iface.members:
         if isinstance(member, xpidl.Attribute):
             attributes.append(member)
             if (member.realtype.nativeType('in').endswith('*')):
                 ccattributes.append(member);
 
@@ -230,137 +375,399 @@ def write_cpp(eventname, iface, fd):
     baseinterfaces.reverse()
 
     baseattributes = []
     for baseiface in baseinterfaces:
         for member in baseiface.members:
             if isinstance(member, xpidl.Attribute):
                 baseattributes.append(member)
 
+    allattributes = []
+    allattributes.extend(baseattributes);
+    allattributes.extend(attributes);
 
-    fd.write("\nclass %s : public %s, public %s\n" % (classname, basename, iface.name))
-    fd.write("{\n")
-    fd.write("public:\n")
-    fd.write("  %s(mozilla::dom::EventTarget* aOwner, " % classname)
-    fd.write("nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr)\n");
-    fd.write("  : %s(aOwner, aPresContext, aEvent)" % basename)
+    fd.write("namespace mozilla {\n")
+    fd.write("namespace dom {\n\n")
+
+    fd.write("%s::%s(mozilla::dom::EventTarget* aOwner, " % (classname, classname))
+    fd.write("nsPresContext* aPresContext, nsEvent* aEvent)\n");
+    fd.write(": %s(aOwner, aPresContext, aEvent)" % basename)
     for a in attributes:
-        fd.write(",\n    m%s(%s)" % (firstCap(a.name), init_value(a)))
-    fd.write("\n  {}\n")
-    fd.write("  virtual ~%s() {}\n\n" % classname)
-    fd.write("  NS_DECL_ISUPPORTS_INHERITED\n")
-    fd.write("  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename))
-    fd.write("  NS_FORWARD_TO_NSDOMEVENT\n")
+        fd.write(",\n  m%s(%s)" % (firstCap(a.name), init_value(a)))
+    fd.write("\n{\n")
+    fd.write("  SetIsDOMBinding();\n")
+    fd.write("}\n\n")
 
-    for baseiface in baseinterfaces:
-        baseimpl = ("ns%s" % baseiface.name[3:])
-        fd.write("  NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl))
-
-    fd.write("  NS_DECL_%s\n" % iface.name.upper())
-    fd.write("  virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n")
-    fd.write("protected:\n")
-    for a in attributes:
-        fd.write("  %s\n" % attributeVariableTypeAndName(a))
-    fd.write("};\n\n")
+    fd.write("%s::~%s() {}\n\n" % (classname, classname))
 
     fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, %s)\n" % (classname, basename))
     for c in ccattributes:
         fd.write("  NS_IMPL_CYCLE_COLLECTION_UNLINK(m%s)\n" % firstCap(c.name))
     fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_END\n\n");
     fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(%s, %s)\n" % (classname, basename))
     for c in ccattributes:
         fd.write("  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(m%s)\n" % firstCap(c.name))
     fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END\n\n");
 
     fd.write("NS_IMPL_ADDREF_INHERITED(%s, %s)\n" % (classname, basename))
     fd.write("NS_IMPL_RELEASE_INHERITED(%s, %s)\n\n" % (classname, basename))
-
-    fd.write("DOMCI_DATA(%s, %s)\n\n" % (eventname, classname))
+    fd.write("} // namespace dom\n")
+    fd.write("} // namespace mozilla\n\n")
+    fd.write("DOMCI_DATA(%s, mozilla::dom::%s)\n\n" % (eventname, classname))
+    fd.write("namespace mozilla {\n")
+    fd.write("namespace dom {\n\n")
 
     fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname)
     fd.write("  NS_INTERFACE_MAP_ENTRY(nsIDOM%s)\n" % eventname)
     fd.write("  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(%s)\n" % eventname)
     fd.write("NS_INTERFACE_MAP_END_INHERITING(%s)\n\n" % basename)
 
     fd.write("nsresult\n")
     fd.write("%s::InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal)\n" % classname)
     fd.write("{\n");
     fd.write("  mozilla::idl::%sInit d;\n" % eventname)
     fd.write("  nsresult rv = d.Init(aCx, aVal);\n")
     fd.write("  NS_ENSURE_SUCCESS(rv, rv);\n")
     fd.write("  return Init%s(aType, d.bubbles, d.cancelable" % eventname)
-    for a in baseattributes:
-      fd.write(", d.%s" % a.name)
-    for a in attributes:
+    for a in allattributes:
         fd.write(", d.%s" % a.name)
     fd.write(");\n")
     fd.write("}\n\n")
 
+    hasVariant = False
+    for a in allattributes:
+        if a.type == "nsIVariant":
+            hasVariant = True
+            break;
+
+    fd.write("already_AddRefed<%s>\n" % eventname)
+    fd.write("%s::Constructor(const GlobalObject& aGlobal, " % eventname)
+    if hasVariant:
+        fd.write("JSContext* aCx, ");
+    fd.write("const nsAString& aType, ")
+    fd.write("const %sInit& aParam, " % eventname)
+    fd.write("ErrorResult& aRv)\n")
+    fd.write("{\n")
+    fd.write("  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());\n")
+    fd.write("  nsRefPtr<%s> e = new %s(t, nullptr, nullptr);\n" % (eventname, eventname))
+    fd.write("  bool trusted = e->Init(t);\n")
+    fd.write("  e->Init%s(" % eventname)
+    if hasVariant:
+        fd.write("aCx, ");
+    fd.write("aType, aParam.mBubbles, aParam.mCancelable")
+    for a in allattributes:
+        fd.write(", aParam.m%s" % firstCap(a.name))
+    fd.write(", aRv);\n")
+    fd.write("  e->SetTrusted(trusted);\n")
+    fd.write("  return e.forget();\n")
+    fd.write("}\n\n")
+
     fd.write("NS_IMETHODIMP\n")
     fd.write("%s::Init%s(" % (classname, eventname))
     fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable")
-    for a in baseattributes:
-      writeAttributeParams(fd, a)
-    for a in attributes:
+    for a in allattributes:
         writeAttributeParams(fd, a)
     fd.write(")\n{\n")
-    fd.write("  nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, basename[5:]))
+    fd.write("  nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, ("%s" % iface.base[6:])))
     for a in baseattributes:
       fd.write(", a%s" % firstCap(a.name))
     fd.write(");\n");
     fd.write("  NS_ENSURE_SUCCESS(rv, rv);\n")
     for a in attributes:
         fd.write("  m%s = a%s;\n" % (firstCap(a.name), firstCap(a.name)))
     fd.write("  return NS_OK;\n")
     fd.write("}\n\n")
 
+    fd.write("void\n")
+    fd.write("%s::Init%s(" % (classname, eventname))
+    if hasVariant:
+        fd.write("JSContext* aCx, ")
+    fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable")
+    for a in allattributes:
+        writeNativeAttributeParams(fd, a, conf)
+    fd.write(", ErrorResult& aRv")
+    fd.write(")\n")
+    fd.write("{\n");
+    for a in allattributes:
+        if a.type == "nsIVariant":
+            fd.write("  nsCOMPtr<nsIVariant> %s = dont_AddRef(XPCVariant::newVariant(aCx, a%s));\n" % (a.name, firstCap(a.name)))
+            fd.write("  if (!%s) {\n" % a.name)
+            fd.write("    aRv.Throw(NS_ERROR_FAILURE);\n")
+            fd.write("    return;\n")
+            fd.write("  }\n")
+        elif a.realtype.nativeType('in').endswith('*'):
+            xpidl_t = a.realtype.nativeType('in').strip('* ')
+            native_t = xpidl_to_native(xpidl_t, conf)
+            if xpidl_t != native_t:
+                fd.write("  nsCOMPtr<%s> %s = do_QueryInterface(static_cast<%s*>(a%s));\n" % (xpidl_t, a.name, xpidl_to_canonical(xpidl_t, conf), firstCap(a.name)))
+    fd.write("  aRv = Init%s(" % classname);
+    fd.write("aType, aCanBubble, aCancelable")
+    for a in allattributes:
+        if a.realtype.nativeType('in').endswith('*'):
+            xpidl_t = a.realtype.nativeType('in').strip('* ')
+            native_t = xpidl_to_native(xpidl_t, conf)
+            if xpidl_t != native_t or a.type == "nsIVariant":
+                fd.write(", %s" % a.name)
+                continue
+        fd.write(", a%s" % firstCap(a.name))
+    fd.write(");\n}\n\n");
+
     for a in attributes:
         writeAttributeGetter(fd, classname, a)
 
+    fd.write("} // namespace dom\n")
+    fd.write("} // namespace mozilla\n\n")
+
     fd.write("nsresult\n")
     fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, "  % eventname)
     fd.write("mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext = nullptr, nsEvent* aEvent = nullptr)\n")
     fd.write("{\n")
-    fd.write("  %s* it = new %s(aOwner, aPresContext, aEvent);\n" % (classname, classname))
+    fd.write("  mozilla::dom::%s* it = new mozilla::dom::%s(aOwner, aPresContext, aEvent);\n" % (classname, classname))
     fd.write("  return CallQueryInterface(it, aInstance);\n")
     fd.write("}\n\n")
 
+def toWebIDLType(attribute, inType=False, onlyInterface=False):
+    if attribute.type == "nsIVariant":
+        return "any";
+    if attribute.type == "nsISupports":
+        return "%s%s" % (attribute.type, "" if onlyInterface else "?")
+    if attribute.type.count("nsIDOM"):
+        return "%s%s" % (attribute.type[6:], "" if onlyInterface else "?")
+    if attribute.type.count("nsI"):
+        return "%s%s" % (attribute.type[3:], "" if onlyInterface else "?")
+    if attribute.realtype.nativeType('in').endswith('*') or attribute.realtype.nativeType('in').count("nsAString"):
+        return "%s%s" % (attribute.type, "" if onlyInterface else "?")
+    return attribute.type
+
+def write_webidl(eventname, iface, fd, conf, idl):
+    basename = ("%s" % iface.base[6:])
+    attributes = []
+    ccattributes = []
+    consts = []
+    hasInit = False
+    initMethod = "init%s" % eventname;
+    for member in iface.members:
+        if isinstance(member, xpidl.Attribute):
+            attributes.append(member)
+            if (member.realtype.nativeType('in').endswith('*')):
+                ccattributes.append(member);
+        elif isinstance(member, xpidl.Method) and member.name == initMethod:
+            if not member.noscript and not member.notxpcom:
+                hasInit = True
+        elif isinstance(member, xpidl.ConstMember):
+            consts.append(member);
+        else:
+            raise BaseException("Unsupported idl member %s::%s" % (eventname, member.name))
+
+    baseinterfaces = []
+    baseiface = iface.idl.getName(iface.base, iface.location)
+    while baseiface.name != "nsIDOMEvent":
+        baseinterfaces.append(baseiface)
+        baseiface = baseiface.idl.getName(baseiface.base, baseiface.location)
+    baseinterfaces.reverse()
+
+    allattributes = []
+    for baseiface in baseinterfaces:
+        for member in baseiface.members:
+            if isinstance(member, xpidl.Attribute):
+                allattributes.append(member)
+    allattributes.extend(attributes)
+
+    fd.write(
+"""/* -*- 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/.
+ */
+""")
+
+    neededInterfaces = []
+    for a in attributes:
+        if a.realtype.nativeType('in').endswith('*'):
+            nativeType = a.realtype.nativeType('in').strip('* ')
+            mappingForWebIDL = False
+            for xp in conf.xpidl_to_native:
+                if xp[0] == nativeType:
+                    mappingForWebIDL = True
+                    break;
+            if not mappingForWebIDL:
+                webidlType = toWebIDLType(a, False, True)
+                if (not webidlType in neededInterfaces and webidlType != "any"):
+                    neededInterfaces.append(webidlType);
+
+    for i in neededInterfaces:
+        fd.write("interface %s;\n" % i)
+
+    fd.write("\n");
+    fd.write("[Constructor(DOMString type, optional %sInit eventInitDict), HeaderFile=\"GeneratedEventClasses.h\"]\n" % eventname);
+    fd.write("interface %s : %s\n" % (eventname, basename))
+    fd.write("{\n")
+
+    for c in consts:
+        fd.write("  const %s %s = %s;\n" % (c.type, c.name, c.getValue()))
+    if len(consts):
+        fd.write("\n")
+
+    for a in attributes:
+        if a.realtype.nativeType('in').count("nsIVariant"):
+            fd.write("  [Throws]\n")
+            fd.write("  readonly attribute %s %s;\n" % (toWebIDLType(a), a.name))
+        elif a.realtype.nativeType('in').endswith('*') or a.realtype.nativeType('in').count("nsAString"):
+            fd.write("  readonly attribute %s %s;\n" % (toWebIDLType(a), a.name))
+        else:
+            fd.write("  readonly attribute %s %s;\n" % (a.type, a.name))
+    if hasInit:
+        fd.write("\n  [Throws]\n")
+        m = "  void %s(" % initMethod
+        fd.write(m)
+        indent = "".join(" " for i in range(len(m)))
+        indent = ",\n%s" % indent
+        fd.write("DOMString type")
+        fd.write(indent);
+        fd.write("boolean canBubble")
+        fd.write(indent);
+        fd.write("boolean cancelable")
+        for a in baseattributes + attributes:
+            fd.write(indent);
+            fd.write("%s %s" % (toWebIDLType(a, True), a.name))
+        fd.write(");\n");
+    fd.write("};\n\n")
+
+    dname = "%sInit" % eventname
+    for p in idl.productions:
+        if p.kind == "dictionary" and p.name == dname:
+            fd.write("dictionary %s : %sInit\n" % (dname, basename))
+            fd.write("{\n")
+            # We want to keep the same ordering what interface has.
+            for ifaceattribute in attributes:
+                for member in p.members:
+                    if member.name == ifaceattribute.name:
+                        a = member
+                        if a.realtype.nativeType('in').endswith('*'):
+                            fd.write("  %s %s = null;\n" % (toWebIDLType(a, True), a.name))
+                        elif a.realtype.nativeType('in').count("nsAString"):
+                            if a.defvalue is None:
+                                if a.nullable:
+                                    fd.write("  %s? %s = null;\n" % (a.type, a.name))
+                                else:
+                                    fd.write("  %s %s = \"\";\n" % (a.type, a.name))
+                            else:
+                                if a.nullable:
+                                    fd.write("  %s? %s = \"%s\";\n" % (a.type, a.name, a.defvalue))
+                                else:
+                                    fd.write("  %s %s = \"%s\";\n" % (a.type, a.name, a.defvalue))
+                        else:
+                            if a.defvalue is None:
+                                if a.type == "boolean":
+                                    fd.write("  %s %s = false;\n" % (a.type, a.name))
+                                else:
+                                    fd.write("  %s %s = 0;\n" % (a.type, a.name))
+                            # Infinity is not supported by all the types, but
+                            # WebIDL parser will then complain about the wrong values.
+                            elif a.defvalue == "Infinity":
+                                fd.write("  unrestricted %s %s = Infinity;\n" % (a.type, a.name))
+                            elif a.defvalue == "-Infinity":
+                                fd.write("  unrestricted %s %s = -Infinity;\n" % (a.type, a.name))
+                            else:
+                                fd.write("  %s %s = %s;\n" % (a.type, a.name, a.defvalue))
+                    continue
+            fd.write("};\n")
+            return
+
+    # There is no dictionary defined in the .idl file. Generate one based on
+    # the interface.
+    fd.write("dictionary %s : %sInit\n" % (dname, basename))
+    fd.write("{\n")
+    for a in attributes:
+        if a.realtype.nativeType('in').endswith('*'):
+            fd.write("  %s %s = null;\n" % (toWebIDLType(a, True), a.name))
+        elif a.realtype.nativeType('in').count("nsAString"):
+            fd.write("  %s? %s = \"\";\n" % (a.type, a.name))
+        elif a.type == "boolean":
+            fd.write("  %s %s = false;\n" % (a.type, a.name))
+        else:
+            fd.write("  %s %s = 0;\n" % (a.type, a.name))
+    fd.write("};\n")
+
+def print_webidl_file(idl, fd, conf, eventname):
+    for p in idl.productions:
+        if p.kind == 'interface':
+            write_webidl(eventname, p, fd, conf, idl)
+
+def xpidl_to_native(xpidl, conf):
+    for x in conf.xpidl_to_native:
+        if x[0] == xpidl:
+            return x[1]
+    return xpidl
+
+def xpidl_to_canonical(xpidl, conf):
+    for x in conf.xpidl_to_native:
+        if x[0] == xpidl:
+            return x[2]
+    return xpidl
+
+def native_to_xpidl(native, conf):
+    for x in conf.xpidl_to_native:
+        if x[1] == native:
+            return x[0]
+    return native
+
+def print_webidl_files(webidlDir, conf):
+    for e in conf.simple_events:
+        idl = loadEventIDL(p, options.incdirs, e)
+        webidl = "%s/%s.webidl" % (webidlDir, e)
+        if not os.path.exists(webidl):
+            fd = open(webidl, 'w')
+            print_webidl_file(idl, fd, conf, e)
+            fd.close();
+
 if __name__ == '__main__':
     from optparse import OptionParser
     o = OptionParser(usage="usage: %prog [options] configfile")
     o.add_option('-I', action='append', dest='incdirs', default=['.'],
                  help="Directory to search for imported files")
     o.add_option('-o', "--stub-output",
                  type='string', dest='stub_output', default=None,
                  help="Quick stub C++ source output file", metavar="FILE")
     o.add_option('--header-output', type='string', default=None,
                  help="Quick stub header output file", metavar="FILE")
     o.add_option('--makedepend-output', type='string', default=None,
                  help="gnumake dependencies output file", metavar="FILE")
     o.add_option('--cachedir', dest='cachedir', default=None,
                  help="Directory in which to cache lex/parse tables.")
+    o.add_option('--class-declarations', type='string', default=None,
+                 help="Class declarations", metavar="FILE")
+    o.add_option('--webidltarget', dest='webidltarget', default=None,
+                 help="Directory in which to store generated WebIDL files.")
     (options, filenames) = o.parse_args()
     if len(filenames) != 1:
         o.error("Exactly one config filename is needed.")
     filename = filenames[0]
 
     if options.cachedir is not None:
         if not os.path.isdir(options.cachedir):
             os.mkdir(options.cachedir)
         sys.path.append(options.cachedir)
 
     # Instantiate the parser.
     p = xpidl.IDLParser(outputdir=options.cachedir)
 
     conf = readConfigFile(filename)
 
+    if options.header_output is not None:
+        outfd = open(options.header_output, 'w')
+        print_header_file(outfd, conf)
+        outfd.close()
+    if options.class_declarations is not None:
+        outfd = open(options.class_declarations, 'w')
+        print_classes_file(outfd, conf)
+        outfd.close()
     if options.stub_output is not None:
         makeutils.targets.append(options.stub_output)
         outfd = open(options.stub_output, 'w')
         print_cpp_file(outfd, conf)
         outfd.close()
         if options.makedepend_output is not None:
             makeutils.writeMakeDependOutput(options.makedepend_output)
-    if options.header_output is not None:
-        outfd = open(options.header_output, 'w')
-        print_header_file(outfd, conf)
-        outfd.close()
 
+    if options.webidltarget is not None:
+        print_webidl_files(options.webidltarget, conf)
+