Backing out bf0a78471e5e:dc7022e2d807 for inexplicable windows crashes.
authorMs2ger <ms2ger@gmail.com>
Sat, 14 Apr 2012 17:52:34 +0200
changeset 91686 e1bef8037d364093de996c9fbd8af78fbb1945d4
parent 91685 dc7022e2d8074e3fedb8fa95fc5ea5a660ab954d
child 91697 356d8a2fd732609bce56967c76ecddc712188b38
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
milestone14.0a1
Backing out bf0a78471e5e:dc7022e2d807 for inexplicable windows crashes.
accessible/src/generic/FormControlAccessible.cpp
accessible/src/html/nsHTMLImageAccessible.cpp
caps/src/nsScriptSecurityManager.cpp
content/base/public/Element.h
content/base/public/nsContentUtils.h
content/base/public/nsIContent.h
content/base/src/nsContentUtils.cpp
content/base/src/nsDOMFileReader.h
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsFrameMessageManager.cpp
content/base/src/nsGenericDOMDataNode.cpp
content/base/src/nsGenericDOMDataNode.h
content/base/src/nsGenericElement.cpp
content/base/src/nsGenericElement.h
content/base/src/nsStyledElement.cpp
content/base/src/nsStyledElement.h
content/events/src/nsEventListenerService.cpp
content/html/document/src/nsHTMLDocument.h
docshell/base/nsDocShell.cpp
dom/Makefile.in
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMScriptObjectFactory.cpp
dom/base/nsDOMScriptObjectFactory.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsIDOMScriptObjectFactory.h
dom/bindings/Codegen.py
dom/imported-tests/Makefile.in
dom/imported-tests/README
dom/imported-tests/WebIDLParser.js
dom/imported-tests/failures.txt
dom/imported-tests/html.json
dom/imported-tests/html.mk
dom/imported-tests/html.txt
dom/imported-tests/html/tests/submission/Mozilla/Makefile.in
dom/imported-tests/html/tests/submission/Mozilla/nested-document-write-external.js
dom/imported-tests/html/tests/submission/Mozilla/test_body-onload.html
dom/imported-tests/html/tests/submission/Mozilla/test_pageload-image.html
dom/imported-tests/html/tests/submission/Mozilla/test_pageload-video.html
dom/imported-tests/html/tests/submission/Mozilla/test_script-for-onload.html
dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html
dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html
dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html
dom/imported-tests/idlharness.js
dom/imported-tests/importTestsuite.py
dom/imported-tests/parseManifest.py
dom/imported-tests/testharness.css
dom/imported-tests/testharness.js
dom/imported-tests/testharnessreport.js.in
dom/imported-tests/updateTestharness.py
dom/imported-tests/webapps.json
dom/imported-tests/webapps.mk
dom/imported-tests/webapps.txt
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/Makefile.in
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm
dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm
dom/imported-tests/writeReporter.py
dom/indexedDB/IDBRequest.cpp
dom/interfaces/storage/nsPIDOMStorage.h
dom/interfaces/xul/nsIDOMXULMultSelectCntrlEl.idl
dom/ipc/ContentParent.cpp
dom/ipc/CrashReporterParent.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/ipc/PluginIdentifierParent.cpp
dom/plugins/ipc/PluginInstanceParent.h
dom/plugins/ipc/PluginModuleParent.cpp
dom/src/storage/nsDOMStorage.cpp
dom/src/storage/nsDOMStorage.h
dom/system/gonk/SystemWorkerManager.cpp
dom/tests/mochitest/Makefile.in
dom/tests/mochitest/w3c/Makefile.in
dom/tests/mochitest/w3c/README
dom/tests/mochitest/w3c/WebIDLParser.js
dom/tests/mochitest/w3c/failures.txt
dom/tests/mochitest/w3c/html.json
dom/tests/mochitest/w3c/html.mk
dom/tests/mochitest/w3c/html.txt
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/Makefile.in
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/nested-document-write-external.js
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_body-onload.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-image.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_pageload-video.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_script-for-onload.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-parse-error.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html
dom/tests/mochitest/w3c/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html
dom/tests/mochitest/w3c/idlharness.js
dom/tests/mochitest/w3c/importTestsuite.py
dom/tests/mochitest/w3c/parseManifest.py
dom/tests/mochitest/w3c/testharness.css
dom/tests/mochitest/w3c/testharness.js
dom/tests/mochitest/w3c/testharnessreport.js.in
dom/tests/mochitest/w3c/updateTestharness.py
dom/tests/mochitest/w3c/webapps.json
dom/tests/mochitest/w3c/webapps.mk
dom/tests/mochitest/w3c/webapps.txt
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/Makefile.in
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm
dom/tests/mochitest/w3c/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm
dom/tests/mochitest/w3c/writeReporter.py
dom/workers/RuntimeService.cpp
dom/workers/WorkerPrivate.cpp
editor/composer/src/nsComposerCommands.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditor.h
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
gfx/src/X11Util.h
js/src/jscntxt.h
js/src/jscntxtinlines.h
js/src/jscompartment.h
js/src/jsobj.cpp
js/src/jsscope.cpp
js/xpconnect/idl/nsIJSContextStack.idl
js/xpconnect/idl/nsIXPConnect.idl
js/xpconnect/src/XPCContext.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCQuickStubs.h
js/xpconnect/src/codegen.py
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/qsgen.py
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
toolkit/components/alerts/mac/mozGrowlDelegate.mm
toolkit/xre/nsNativeAppSupportOS2.cpp
toolkit/xre/nsNativeAppSupportWin.cpp
xpcom/base/nsError.h
--- a/accessible/src/generic/FormControlAccessible.cpp
+++ b/accessible/src/generic/FormControlAccessible.cpp
@@ -114,23 +114,23 @@ void
 ProgressMeterAccessible<Max>::Value(nsString& aValue)
 {
   nsLeafAccessible::Value(aValue);
   if (!aValue.IsEmpty())
     return;
 
   double maxValue = 0;
   nsresult rv = GetMaximumValue(&maxValue);
-  if (NS_FAILED(rv) || maxValue == 0)
+  NS_ENSURE_SUCCESS(rv, );
+  if (maxValue == 0)
     return;
 
   double curValue = 0;
   GetCurrentValue(&curValue);
-  if (NS_FAILED(rv))
-    return;
+  NS_ENSURE_SUCCESS(rv, );
 
   // Treat the current value bigger than maximum as 100%.
   double percentValue = (curValue < maxValue) ?
     (curValue / maxValue) * 100 : 100;
 
   aValue.AppendFloat(percentValue);
   aValue.AppendLiteral("%");
 }
--- a/accessible/src/html/nsHTMLImageAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageAccessible.cpp
@@ -238,17 +238,18 @@ nsHTMLImageAccessible::GetLongDescURI() 
       element->GetURIAttr(nsGkAtoms::longdesc, nsnull, getter_AddRefs(uri));
       return uri.forget();
     }
   }
 
   nsDocAccessible* document = Document();
   if (document) {
     IDRefsIterator iter(document, mContent, nsGkAtoms::aria_describedby);
-    while (nsIContent* target = iter.NextElem()) {
+    nsIContent* target = nsnull;
+    while (target = iter.NextElem()) {
       if ((target->IsHTML(nsGkAtoms::a) || target->IsHTML(nsGkAtoms::area)) &&
           target->HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
         nsGenericHTMLElement* element =
           nsGenericHTMLElement::FromContent(target);
 
         nsCOMPtr<nsIURI> uri;
         element->GetURIAttr(nsGkAtoms::href, nsnull, getter_AddRefs(uri));
         return uri.forget();
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -358,17 +358,20 @@ nsScriptSecurityManager::GetCurrentJSCon
         return nsnull;
     return cx;
 }
 
 JSContext *
 nsScriptSecurityManager::GetSafeJSContext()
 {
     // Get JSContext from stack.
-    return sJSContextStack->GetSafeJSContext();
+    JSContext *cx;
+    if (NS_FAILED(sJSContextStack->GetSafeJSContext(&cx)))
+        return nsnull;
+    return cx;
 }
 
 /* static */
 bool
 nsScriptSecurityManager::SecurityCompareURIs(nsIURI* aSourceURI,
                                              nsIURI* aTargetURI)
 {
     return NS_SecurityCompareURIs(aSourceURI, aTargetURI, sStrictFileOriginPolicy);
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -83,19 +83,19 @@ enum {
 };
 
 namespace mozilla {
 namespace dom {
 
 class Link;
 
 // IID for the dom::Element interface
-#define NS_ELEMENT_IID \
-{ 0xab6554b0, 0xb675, 0x45a7, \
-  { 0xac, 0x23, 0x44, 0x1c, 0x94, 0x5f, 0x3b, 0xee } }
+#define NS_ELEMENT_IID      \
+{ 0xa1588efb, 0x5a84, 0x49cd, \
+  { 0x99, 0x1a, 0xac, 0x84, 0x9d, 0x92, 0x05, 0x0f } }
 
 class Element : public nsIContent
 {
 public:
 #ifdef MOZILLA_INTERNAL_API
   Element(already_AddRefed<nsINodeInfo> aNodeInfo) :
     nsIContent(aNodeInfo),
     mState(NS_EVENT_STATE_MOZ_READONLY)
@@ -166,63 +166,16 @@ public:
    */
   void UnlockStyleStates(nsEventStates aStates);
 
   /**
    * Clear all style state locks on this element.
    */
   void ClearStyleStateLocks();
 
-  /**
-   * Get the inline style rule, if any, for this element.
-   */
-  virtual css::StyleRule* GetInlineStyleRule() = 0;
-
-  /**
-   * Set the inline style rule for this element. This will send an appropriate
-   * AttributeChanged notification if aNotify is true.
-   */
-  virtual nsresult SetInlineStyleRule(css::StyleRule* aStyleRule,
-                                      const nsAString* aSerialized,
-                                      bool aNotify) = 0;
-
-  /**
-   * Get the SMIL override style rule for this element. If the rule hasn't been
-   * created, this method simply returns null.
-   */
-  virtual css::StyleRule* GetSMILOverrideStyleRule() = 0;
-
-  /**
-   * Set the SMIL override style rule for this element. If aNotify is true, this
-   * method will notify the document's pres context, so that the style changes
-   * will be noticed.
-   */
-  virtual nsresult SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
-                                            bool aNotify) = 0;
-
-  /**
-   * Returns a new nsISMILAttr that allows the caller to animate the given
-   * attribute on this element.
-   *
-   * The CALLER OWNS the result and is responsible for deleting it.
-   */
-  virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0;
-
-  /**
-   * Get the SMIL override style for this element. This is a style declaration
-   * that is applied *after* the inline style, and it can be used e.g. to store
-   * animated style values.
-   *
-   * Note: This method is analogous to the 'GetStyle' method in
-   * nsGenericHTMLElement and nsStyledElement.
-   *
-   * TODO: Bug 744157 - All callers QI to nsICSSDeclaration.
-   */
-  virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0;
-
 protected:
   /**
    * Method to get the _intrinsic_ content state of this element.  This is the
    * state that is independent of the element's presentation.  To get the full
    * content state, use State().  See nsEventStates.h for
    * the possible bits that could be set here.
    */
   virtual nsEventStates IntrinsicState() const;
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -390,16 +390,19 @@ public:
   static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
                                                  PRUint32 aSrcOffset,
                                                  PRUnichar* aDest,
                                                  PRUint32 aLength,
                                                  bool& aLastCharCR);
 
   static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
 
+  static nsISupports *
+  GetClassInfoInstance(nsDOMClassInfoID aID);
+
   static const nsDependentSubstring TrimCharsInSet(const char* aSet,
                                                    const nsAString& aValue);
 
   template<bool IsWhitespace(PRUnichar)>
   static const nsDependentSubstring TrimWhitespace(const nsAString& aStr,
                                                    bool aTrimTrailing = true);
 
   /**
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -72,18 +72,18 @@ enum nsLinkState {
   eLinkState_Unknown    = 0,
   eLinkState_Unvisited  = 1,
   eLinkState_Visited    = 2,
   eLinkState_NotLink    = 3
 };
 
 // IID for the nsIContent interface
 #define NS_ICONTENT_IID \
-{ 0xa887c108, 0xc25e, 0x42ab, \
-  { 0x87, 0xef, 0xad, 0x4b, 0xee, 0x50, 0x28, 0x28 } }
+{ 0x94671671, 0x9e1b, 0x447a, \
+  { 0xad, 0xb7, 0xc3, 0x2e, 0x05, 0x6a, 0x96, 0xc9 } }
 
 /**
  * A node of content in a document's content model. This interface
  * is supported by all content objects.
  */
 class nsIContent : public nsINode {
 public:
   typedef mozilla::widget::IMEState IMEState;
@@ -789,16 +789,32 @@ public:
 
   /**
    * Walk aRuleWalker over the content style rules (presentational
    * hint rules) for this content node.
    */
   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
 
   /**
+   * Get the inline style rule, if any, for this content node
+   */
+  virtual mozilla::css::StyleRule* GetInlineStyleRule() = 0;
+
+  /**
+   * Set the inline style rule for this node.  This will send an
+   * appropriate AttributeChanged notification if aNotify is true.  If
+   * a serialized form of aStyleRule is available, a pointer to it
+   * should be passed in aSerialized.  Otherwise, aSerialized should
+   * be null.
+   */
+  NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                const nsAString* aSerialized,
+                                bool aNotify) = 0;
+
+  /**
    * Is the attribute named stored in the mapped attributes?
    *
    * // XXXbz we use this method in HasAttributeDependentStyle, so svg
    *    returns true here even though it stores nothing in the mapped
    *    attributes.
    */
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const = 0;
 
@@ -854,16 +870,49 @@ public:
   }
   void SetPrimaryFrame(nsIFrame* aFrame) {
     NS_ASSERTION(IsInDoc(), "This will end badly!");
     NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
                     "Losing track of existing primary frame");
     mPrimaryFrame = aFrame;
   }
 
+  /*
+   * Returns a new nsISMILAttr that allows the caller to animate the given
+   * attribute on this element.
+   *
+   * The CALLER OWNS the result and is responsible for deleting it.
+   */
+  virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0;
+
+  /**
+   * Get the SMIL override style for this content node.  This is a style
+   * declaration that is applied *after* the inline style, and it can be used
+   * e.g. to store animated style values.
+   *
+   * Note: This method is analogous to the 'GetStyle' method in
+   * nsGenericHTMLElement and nsStyledElement.
+   */
+  virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0;
+
+  /**
+   * Get the SMIL override style rule for this content node.  If the rule
+   * hasn't been created (or if this nsIContent object doesn't support SMIL
+   * override style), this method simply returns null.
+   */
+  virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule() = 0;
+
+  /**
+   * Set the SMIL override style rule for this node.  If aNotify is true, this
+   * method will notify the document's pres context, so that the style changes
+   * will be noticed.
+   */
+  virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                            bool aNotify) = 0;
+
   nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
                                       nsAString& aNamespaceURI) const;
 
   /**
    * If this content has independent selection, e.g., if this is input field
    * or textarea, this return TRUE.  Otherwise, false.
    */
   bool HasIndependentSelection();
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -1618,17 +1618,18 @@ nsContentUtils::GetContextFromDocument(n
 
 //static
 void
 nsContentUtils::TraceSafeJSContext(JSTracer* aTrc)
 {
   if (!sThreadJSContextStack) {
     return;
   }
-  JSContext* cx = sThreadJSContextStack->GetSafeJSContext();
+  JSContext* cx = nsnull;
+  sThreadJSContextStack->GetSafeJSContext(&cx);
   if (!cx) {
     return;
   }
   if (JSObject* global = JS_GetGlobalObject(cx)) {
     JS_CALL_OBJECT_TRACER(aTrc, global, "safe context");
   }
 }
 
--- a/content/base/src/nsDOMFileReader.h
+++ b/content/base/src/nsDOMFileReader.h
@@ -86,17 +86,16 @@ public:
   NS_DECL_EVENT_HANDLER(loadend)
   NS_DECL_EVENT_HANDLER(loadstart)
 
   // nsIJSNativeInitializer                                                
   NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj, 
                         PRUint32 argc, jsval* argv);
 
   // nsICharsetDetectionObserver
-  using mozilla::dom::FileIOObject::Notify;
   NS_IMETHOD Notify(const char *aCharset, nsDetectionConfident aConf);
 
   // FileIOObject overrides
   NS_IMETHOD DoAbort(nsAString& aEvent);
   NS_IMETHOD DoOnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
                              nsresult aStatus, nsAString& aSuccessEvent,
                              nsAString& aTerminationEvent);
   NS_IMETHOD DoOnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3840,17 +3840,17 @@ nsDocument::SetScriptGlobalObject(nsIScr
       JSObject *obj = GetWrapperPreserveColor();
       if (obj) {
         JSObject *newScope = aScriptGlobalObject->GetGlobalJSObject();
         nsIScriptContext *scx = aScriptGlobalObject->GetContext();
         JSContext *cx = scx ? scx->GetNativeContext() : nsnull;
         if (!cx) {
           nsContentUtils::ThreadJSContextStack()->Peek(&cx);
           if (!cx) {
-            cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
+            nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
             NS_ASSERTION(cx, "Uhoh, no context, this is bad!");
           }
         }
         if (cx) {
           NS_ASSERTION(JS_GetGlobalForObject(cx, obj) == newScope,
                        "Wrong scope, this is really bad!");
         }
       }
@@ -6049,17 +6049,17 @@ GetContextAndScope(nsIDocument* aOldDocu
       // No context reachable from the old or new document, use the
       // calling context, or the safe context if no caller can be
       // found.
 
       nsIThreadJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
       stack->Peek(&cx);
 
       if (!cx) {
-        cx = stack->GetSafeJSContext();
+        stack->GetSafeJSContext(&cx);
 
         if (!cx) {
           // No safe context reachable, bail.
           NS_WARNING("No context reachable in GetContextAndScopes()!");
 
           return NS_ERROR_NOT_AVAILABLE;
         }
       }
@@ -6464,73 +6464,79 @@ nsDocument::IsScriptEnabled()
   NS_ENSURE_TRUE(cx, false);
 
   bool enabled;
   nsresult rv = sm->CanExecuteScripts(cx, NodePrincipal(), &enabled);
   NS_ENSURE_SUCCESS(rv, false);
   return enabled;
 }
 
-nsRadioGroupStruct*
-nsDocument::GetRadioGroup(const nsAString& aName)
+nsresult
+nsDocument::GetRadioGroup(const nsAString& aName,
+                          nsRadioGroupStruct **aRadioGroup)
 {
   nsAutoString tmKey(aName);
-  if (IsHTML()) {
-    ToLowerCase(tmKey); //should case-insensitive.
-  }
-
-  nsRadioGroupStruct* radioGroup;
-  if (mRadioGroups.Get(tmKey, &radioGroup)) {
-    return radioGroup;
-  }
-
-  nsAutoPtr<nsRadioGroupStruct> newRadioGroup(new nsRadioGroupStruct());
-  NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, newRadioGroup), nsnull);
-
-  return newRadioGroup.forget();
+  if(IsHTML())
+     ToLowerCase(tmKey); //should case-insensitive.
+  if (mRadioGroups.Get(tmKey, aRadioGroup))
+    return NS_OK;
+
+  nsAutoPtr<nsRadioGroupStruct> radioGroup(new nsRadioGroupStruct());
+  NS_ENSURE_TRUE(radioGroup, NS_ERROR_OUT_OF_MEMORY);
+  NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, radioGroup), NS_ERROR_OUT_OF_MEMORY);
+
+  *aRadioGroup = radioGroup;
+  radioGroup.forget();
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::SetCurrentRadioButton(const nsAString& aName,
                                   nsIDOMHTMLInputElement* aRadio)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_OK);
-
-  radioGroup->mSelectedRadioButton = aRadio;
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (radioGroup) {
+    radioGroup->mSelectedRadioButton = aRadio;
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetCurrentRadioButton(const nsAString& aName,
                                   nsIDOMHTMLInputElement** aRadio)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_OK);
-
-  *aRadio = radioGroup->mSelectedRadioButton;
-  NS_IF_ADDREF(*aRadio);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (radioGroup) {
+    *aRadio = radioGroup->mSelectedRadioButton;
+    NS_IF_ADDREF(*aRadio);
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
                                PRInt32 *aPositionIndex,
                                PRInt32 *aItemsInGroup)
 {
   *aPositionIndex = 0;
   *aItemsInGroup = 1;
   nsAutoString name;
   aRadio->GetName(name);
   if (name.IsEmpty()) {
     return NS_OK;
   }
 
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(name);
-  NS_ENSURE_TRUE(radioGroup, NS_ERROR_OUT_OF_MEMORY);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  nsresult rv = GetRadioGroup(name, &radioGroup);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIFormControl> radioControl(do_QueryInterface(aRadio));
   NS_ASSERTION(radioControl, "Radio button should implement nsIFormControl");
   *aPositionIndex = radioGroup->mRadioButtons.IndexOf(radioControl);
   NS_ASSERTION(*aPositionIndex >= 0, "Radio button not found in its own group");
   *aItemsInGroup = radioGroup->mRadioButtons.Count();
 
   return NS_OK;
@@ -6543,18 +6549,21 @@ nsDocument::GetNextRadioButton(const nsA
                                nsIDOMHTMLInputElement** aRadioOut)
 {
   // XXX Can we combine the HTML radio button method impls of 
   //     nsDocument and nsHTMLFormControl?
   // XXX Why is HTML radio button stuff in nsDocument, as 
   //     opposed to nsHTMLDocument?
   *aRadioOut = nsnull;
 
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_ERROR_FAILURE);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (!radioGroup) {
+    return NS_ERROR_FAILURE;
+  }
 
   // Return the radio button relative to the focused radio button.
   // If no radio is focused, get the radio relative to the selected one.
   nsCOMPtr<nsIDOMHTMLInputElement> currentRadio;
   if (aFocusedRadio) {
     currentRadio = aFocusedRadio;
   }
   else {
@@ -6589,55 +6598,62 @@ nsDocument::GetNextRadioButton(const nsA
   NS_IF_ADDREF(*aRadioOut = radio);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::AddToRadioGroup(const nsAString& aName,
                             nsIFormControl* aRadio)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_OK);
-
-  radioGroup->mRadioButtons.AppendObject(aRadio);
-
-  nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
-  NS_ASSERTION(element, "radio controls have to be content elements");
-  if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
-    radioGroup->mRequiredRadioCount++;
-  }
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (radioGroup) {
+    radioGroup->mRadioButtons.AppendObject(aRadio);
+
+    nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
+    NS_ASSERTION(element, "radio controls have to be content elements");
+    if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
+      radioGroup->mRequiredRadioCount++;
+    }
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::RemoveFromRadioGroup(const nsAString& aName,
                                  nsIFormControl* aRadio)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_OK);
-
-  radioGroup->mRadioButtons.RemoveObject(aRadio);
-
-  nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
-  NS_ASSERTION(element, "radio controls have to be content elements");
-  if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
-    radioGroup->mRequiredRadioCount--;
-    NS_ASSERTION(radioGroup->mRequiredRadioCount >= 0,
-                 "mRequiredRadioCount shouldn't be negative!");
-  }
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (radioGroup) {
+    radioGroup->mRadioButtons.RemoveObject(aRadio);
+
+    nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
+    NS_ASSERTION(element, "radio controls have to be content elements");
+    if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
+      radioGroup->mRequiredRadioCount--;
+      NS_ASSERTION(radioGroup->mRequiredRadioCount >= 0,
+                   "mRequiredRadioCount shouldn't be negative!");
+    }
+  }
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::WalkRadioGroup(const nsAString& aName,
                            nsIRadioVisitor* aVisitor,
                            bool aFlushContent)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
-  NS_ENSURE_TRUE(radioGroup, NS_OK);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
+  if (!radioGroup) {
+    return NS_OK;
+  }
 
   for (int i = 0; i < radioGroup->mRadioButtons.Count(); i++) {
     if (!aVisitor->Visit(radioGroup->mRadioButtons[i])) {
       return NS_OK;
     }
   }
 
   return NS_OK;
@@ -6656,17 +6672,18 @@ nsDocument::GetRequiredRadioCount(const 
   mRadioGroups.Get(tmKey, &radioGroup);
 
   return radioGroup ? radioGroup->mRequiredRadioCount : 0;
 }
 
 void
 nsDocument::RadioRequiredChanged(const nsAString& aName, nsIFormControl* aRadio)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
 
   if (!radioGroup) {
     return;
   }
 
   nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
   NS_ASSERTION(element, "radio controls have to be content elements");
   if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
@@ -6691,17 +6708,18 @@ nsDocument::GetValueMissingState(const n
   mRadioGroups.Get(tmKey, &radioGroup);
 
   return radioGroup && radioGroup->mGroupSuffersFromValueMissing;
 }
 
 void
 nsDocument::SetValueMissingState(const nsAString& aName, bool aValue)
 {
-  nsRadioGroupStruct* radioGroup = GetRadioGroup(aName);
+  nsRadioGroupStruct* radioGroup = nsnull;
+  GetRadioGroup(aName, &radioGroup);
 
   if (!radioGroup) {
     return;
   }
 
   radioGroup->mGroupSuffersFromValueMissing = aValue;
 }
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -749,17 +749,18 @@ public:
                                   nsIFormControl* aRadio);
   virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
   virtual void RadioRequiredChanged(const nsAString& aName,
                                     nsIFormControl* aRadio);
   virtual bool GetValueMissingState(const nsAString& aName) const;
   virtual void SetValueMissingState(const nsAString& aName, bool aValue);
 
   // for radio group
-  nsRadioGroupStruct* GetRadioGroup(const nsAString& aName);
+  nsresult GetRadioGroup(const nsAString& aName,
+                         nsRadioGroupStruct **aRadioGroup);
 
   // nsIDOMNode
   NS_DECL_NSIDOMNODE
 
   // nsIDOMDocument
   NS_DECL_NSIDOMDOCUMENT
 
   // nsIDOMXMLDocument
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -374,17 +374,17 @@ nsFrameMessageManager::ReceiveMessage(ns
                                       const nsAString& aMessage,
                                       bool aSync, const nsAString& aJSON,
                                       JSObject* aObjectsArray,
                                       InfallibleTArray<nsString>* aJSONRetVal,
                                       JSContext* aContext)
 {
   JSContext* ctx = mContext ? mContext : aContext;
   if (!ctx) {
-    ctx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
+    nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&ctx);
   }
   if (mListeners.Length()) {
     nsCOMPtr<nsIAtom> name = do_GetAtom(aMessage);
     MMListenerRemover lr(this);
 
     for (PRUint32 i = 0; i < mListeners.Length(); ++i) {
       if (mListeners[i].mMessage == name) {
         nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS =
@@ -718,17 +718,18 @@ CachedScriptUnrooter(const nsAString& aK
   return PL_DHASH_REMOVE;
 }
 
 // static
 void
 nsFrameScriptExecutor::Shutdown()
 {
   if (sCachedScripts) {
-    JSContext* cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
+    JSContext* cx = nsnull;
+    nsContentUtils::ThreadJSContextStack()->GetSafeJSContext(&cx);
     if (cx) {
 #ifdef DEBUG_smaug
       printf("Will clear cached frame manager scripts!\n");
 #endif
       JSAutoRequest ar(cx);
       NS_ASSERTION(sCachedScripts != nsnull, "Need cached scripts");
       sCachedScripts->Enumerate(CachedScriptUnrooter, cx);
     } else {
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -944,16 +944,51 @@ nsGenericDOMDataNode::DoGetClasses() con
 }
 
 NS_IMETHODIMP
 nsGenericDOMDataNode::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
 {
   return NS_OK;
 }
 
+nsIDOMCSSStyleDeclaration*
+nsGenericDOMDataNode::GetSMILOverrideStyle()
+{
+  return nsnull;
+}
+
+css::StyleRule*
+nsGenericDOMDataNode::GetSMILOverrideStyleRule()
+{
+  return nsnull;
+}
+
+nsresult
+nsGenericDOMDataNode::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule,
+                                               bool aNotify)
+{
+  NS_NOTREACHED("How come we're setting SMILOverrideStyle on a non-element?");
+  return NS_ERROR_UNEXPECTED;
+}
+
+css::StyleRule*
+nsGenericDOMDataNode::GetInlineStyleRule()
+{
+  return nsnull;
+}
+
+NS_IMETHODIMP
+nsGenericDOMDataNode::SetInlineStyleRule(css::StyleRule* aStyleRule,
+                                         const nsAString* aSerialized,
+                                         bool aNotify)
+{
+  NS_NOTREACHED("How come we're setting inline style on a non-element?");
+  return NS_ERROR_UNEXPECTED;
+}
+
 NS_IMETHODIMP_(bool)
 nsGenericDOMDataNode::IsAttributeMapped(const nsIAtom* aAttribute) const
 {
   return false;
 }
 
 nsChangeHint
 nsGenericDOMDataNode::GetAttributeChangeHint(const nsIAtom* aAttribute,
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -221,28 +221,40 @@ public:
   }
   virtual nsresult AppendText(const PRUnichar* aBuffer, PRUint32 aLength,
                               bool aNotify);
   virtual bool TextIsOnlyWhitespace();
   virtual void AppendTextTo(nsAString& aResult);
   virtual void DestroyContent();
   virtual void SaveSubtreeState();
 
+  virtual nsISMILAttr* GetAnimatedAttr(PRInt32 /*aNamespaceID*/, nsIAtom* /*aName*/)
+  {
+    return nsnull;
+  }
+  virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle();
+  virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule();
+  virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                            bool aNotify);
+
 #ifdef DEBUG
   virtual void List(FILE* out, PRInt32 aIndent) const;
   virtual void DumpContent(FILE* out, PRInt32 aIndent, bool aDumpAll) const;
 #endif
 
   virtual nsIContent *GetBindingParent() const;
   virtual bool IsNodeOfType(PRUint32 aFlags) const;
   virtual bool IsLink(nsIURI** aURI) const;
 
   virtual nsIAtom* DoGetID() const;
   virtual const nsAttrValue* DoGetClasses() const;
   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
+  virtual mozilla::css::StyleRule* GetInlineStyleRule();
+  NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                const nsAString* aSerialized, bool aNotify);
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                               PRInt32 aModType) const;
   virtual nsIAtom *GetClassAttributeName() const;
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
   {
     *aResult = CloneDataNode(aNodeInfo, true);
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -3605,17 +3605,17 @@ nsGenericElement::SetSMILOverrideStyleRu
 }
 
 css::StyleRule*
 nsGenericElement::GetInlineStyleRule()
 {
   return nsnull;
 }
 
-nsresult
+NS_IMETHODIMP
 nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule,
                                      const nsAString* aSerialized,
                                      bool aNotify)
 {
   NS_NOTYETIMPLEMENTED("nsGenericElement::SetInlineStyleRule");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -363,19 +363,19 @@ public:
   virtual void DumpContent(FILE* out, PRInt32 aIndent, bool aDumpAll) const;
   void List(FILE* out, PRInt32 aIndent, const nsCString& aPrefix) const;
   void ListAttributes(FILE* out) const;
 #endif
 
   virtual const nsAttrValue* DoGetClasses() const;
   NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
   virtual mozilla::css::StyleRule* GetInlineStyleRule();
-  virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
-                                      const nsAString* aSerialized,
-                                      bool aNotify);
+  NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                const nsAString* aSerialized,
+                                bool aNotify);
   NS_IMETHOD_(bool)
     IsAttributeMapped(const nsIAtom* aAttribute) const;
   virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
                                               PRInt32 aModType) const;
   /*
    * Attribute Mapping Helpers
    */
   struct MappedAttributeEntry {
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -156,17 +156,17 @@ nsStyledElementNotElementCSSInlineStyle:
     // Now. the id is really removed so it would not be safe to keep this flag.
     ClearHasID();
   }
 
   return nsGenericElement::AfterSetAttr(aNamespaceID, aAttribute, aValue,
                                         aNotify);
 }
 
-nsresult
+NS_IMETHODIMP
 nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule,
                                                             const nsAString* aSerialized,
                                                             bool aNotify)
 {
   SetMayHaveStyle();
   bool modification = false;
   nsAttrValue oldValue;
 
--- a/content/base/src/nsStyledElement.h
+++ b/content/base/src/nsStyledElement.h
@@ -69,19 +69,19 @@ protected:
 public:
   // nsIContent interface methods
   virtual nsIAtom* GetClassAttributeName() const;
   virtual nsIAtom* GetIDAttributeName() const;
   virtual nsIAtom* DoGetID() const;
   virtual const nsAttrValue* DoGetClasses() const;
 
   virtual mozilla::css::StyleRule* GetInlineStyleRule();
-  virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
-                                      const nsAString* aSerialized,
-                                      bool aNotify);
+  NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
+                                const nsAString* aSerialized,
+                                bool aNotify);
 
   virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                              bool aNotify);
   virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
                                 const nsAttrValue* aValue, bool aNotify);
 
   nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval);
 
--- a/content/events/src/nsEventListenerService.cpp
+++ b/content/events/src/nsEventListenerService.cpp
@@ -129,17 +129,18 @@ nsEventListenerInfo::GetJSVal(JSContext*
 NS_IMETHODIMP
 nsEventListenerInfo::ToSource(nsAString& aResult)
 {
   aResult.SetIsVoid(true);
 
   nsCOMPtr<nsIThreadJSContextStack> stack =
     nsContentUtils::ThreadJSContextStack();
   if (stack) {
-    JSContext* cx = stack->GetSafeJSContext();
+    JSContext* cx = nsnull;
+    stack->GetSafeJSContext(&cx);
     if (cx && NS_SUCCEEDED(stack->Push(cx))) {
       {
         // Extra block to finish the auto request before calling pop
         JSAutoRequest ar(cx);
         JSAutoEnterCompartment ac;
         jsval v = JSVAL_NULL;
         if (GetJSVal(cx, ac, &v)) {
           JSString* str = JS_ValueToSource(cx, v);
@@ -171,17 +172,18 @@ nsEventListenerInfo::GetDebugObject(nsIS
   
   bool isOn = false;
   jsd->GetIsOn(&isOn);
   NS_ENSURE_TRUE(isOn, NS_OK);
 
   nsCOMPtr<nsIThreadJSContextStack> stack =
     nsContentUtils::ThreadJSContextStack();
   if (stack) {
-    JSContext* cx = stack->GetSafeJSContext();
+    JSContext* cx = nsnull;
+    stack->GetSafeJSContext(&cx);
     if (cx && NS_SUCCEEDED(stack->Push(cx))) {
       {
         // Extra block to finish the auto request before calling pop
         JSAutoRequest ar(cx);
         JSAutoEnterCompartment ac;
         jsval v = JSVAL_NULL;
         if (GetJSVal(cx, ac, &v)) {
           nsCOMPtr<jsdIValue> jsdValue;
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -119,17 +119,16 @@ public:
  
   // nsIDOMDocument interface
   NS_FORWARD_NSIDOMDOCUMENT(nsDocument::)
 
   // nsIDOMNode interface
   NS_FORWARD_NSIDOMNODE(nsDocument::)
 
   // nsIDOMHTMLDocument interface
-  using nsDocument::GetPlugins;
   NS_DECL_NSIDOMHTMLDOCUMENT
 
   /**
    * Returns the result of document.all[aID] which can either be a node
    * or a nodelist depending on if there are multiple nodes with the same
    * id.
    */
   nsISupports *GetDocumentAllResult(const nsAString& aID,
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -164,17 +164,16 @@
 #include "nsIStructuredCloneContainer.h"
 #include "nsIFaviconService.h"
 #include "mozIAsyncFavicons.h"
 
 // Editor-related
 #include "nsIEditingSession.h"
 
 #include "nsPIDOMWindow.h"
-#include "nsGlobalWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsIDOMDocument.h"
 #include "nsICachingChannel.h"
 #include "nsICacheVisitor.h"
 #include "nsICacheEntryDescriptor.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIWyciwygChannel.h"
 
@@ -10851,37 +10850,46 @@ nsDocShell::EnsureScriptEnvironment()
                  "within EnsureScriptEnvironment()!");
 
     // Yeah, this isn't re-entrant safe, but that's ok since if we
     // re-enter this method, we'll infinitely loop...
     AutoRestore<bool> boolSetter(mInEnsureScriptEnv);
     mInEnsureScriptEnv = true;
 #endif
 
+    nsCOMPtr<nsIDOMScriptObjectFactory> factory =
+        do_GetService(kDOMScriptObjectFactoryCID);
+    NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
+
     nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));
     NS_ENSURE_TRUE(browserChrome, NS_ERROR_NOT_AVAILABLE);
 
     PRUint32 chromeFlags;
     browserChrome->GetChromeFlags(&chromeFlags);
 
     bool isModalContentWindow =
         (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL) &&
         !(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME);
 
     // If our window is modal and we're not opened as chrome, make
     // this window a modal content window.
-    nsRefPtr<nsGlobalWindow> window =
-        NS_NewScriptGlobalObject(mItemType == typeChrome, isModalContentWindow);
-    MOZ_ASSERT(window);
-    mScriptGlobal = window;
-
-    window->SetDocShell(this);
+    factory->NewScriptGlobalObject(mItemType == typeChrome,
+                                   isModalContentWindow,
+                                   getter_AddRefs(mScriptGlobal));
+    NS_ENSURE_TRUE(mScriptGlobal, NS_ERROR_FAILURE);
+
+    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobal));
+    win->SetDocShell(static_cast<nsIDocShell *>(this));
 
     // Ensure the script object is set up to run script.
-    return mScriptGlobal->EnsureScriptEnvironment();
+    nsresult rv;
+    rv = mScriptGlobal->EnsureScriptEnvironment();
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsDocShell::EnsureEditorData()
 {
     bool openDocHasDetachedEditor = mOSHE && mOSHE->HasDetachedEditor();
     if (!mEditorData && !mIsBeingDestroyed && !openDocHasDetachedEditor) {
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -100,19 +100,14 @@ DIRS += \
   $(NULL)
 endif
 
 ifdef MOZ_B2G_BT
 DIRS += \
   bluetooth \
   $(NULL)
 endif
-
-TEST_DIRS += \
-  tests \
-  imported-tests \
-  $(NULL)
-
+TEST_DIRS += tests
 ifneq (,$(filter gtk2 cocoa windows android qt os2,$(MOZ_WIDGET_TOOLKIT)))
 TEST_DIRS += plugins/test
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -48,19 +48,17 @@
 
 // JavaScript includes
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "jsprvtd.h"    // we are using private JS typedefs...
 #include "jsdbgapi.h"
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
-#include "XrayWrapper.h"
-
-#include "xpcpublic.h"
+
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 
 #include "mozilla/dom/bindings/Common.h"
 
 #include "nscore.h"
 #include "nsDOMClassInfo.h"
 #include "nsCRT.h"
@@ -81,16 +79,18 @@
 #include "nsUnicharUtils.h"
 #include "xptcall.h"
 #include "prprf.h"
 #include "nsTArray.h"
 #include "nsCSSValue.h"
 #include "nsIRunnable.h"
 #include "nsThreadUtils.h"
 #include "nsDOMEventTargetHelper.h"
+#include "xpcprivate.h"
+#include "XrayWrapper.h"
 
 // General helper includes
 #include "nsGlobalWindow.h"
 #include "nsHistory.h"
 #include "nsIContent.h"
 #include "nsIAttribute.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
@@ -2413,18 +2413,20 @@ nsDOMClassInfo::Init()
 
   sSecMan = sm;
   NS_ADDREF(sSecMan);
 
   nsCOMPtr<nsIThreadJSContextStack> stack =
     do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  JSContext* cx = stack->GetSafeJSContext();
-  NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
+  JSContext *cx = nsnull;
+
+  rv = stack->GetSafeJSContext(&cx);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
     DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
   DOM_CLASSINFO_MAP_END
@@ -4917,17 +4919,18 @@ nsDOMClassInfo::PostCreatePrototype(JSCo
                    ? 0
                    : JSPROP_ENUMERATE;
 
   PRUint32 count = 0;
   while (mData->mInterfaces[count]) {
     count++;
   }
 
-  if (!xpc::DOM_DefineQuickStubs(cx, proto, flags, count, mData->mInterfaces)) {
+  if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
+                                       count, mData->mInterfaces)) {
     JS_ClearPendingException(cx);
   }
 
   // This is called before any other location that requires
   // sObjectClass, so compute it here. We assume that nobody has had a
   // chance to monkey around with proto's prototype chain before this.
   if (!sObjectClass) {
     FindObjectClass(proto);
@@ -5818,20 +5821,21 @@ IDBConstantGetter(JSContext *cx, JSObjec
 }
 
 static nsresult
 DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
 {
   const char* interface;
   if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
     interface = IDBConstant::IDBCursor;
-  } else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
+  }
+  else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
     interface = IDBConstant::IDBRequest;
-  } else {
-    MOZ_ASSERT(aIID->Equals(NS_GET_IID(nsIIDBTransaction)));
+  }
+  else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
     interface = IDBConstant::IDBTransaction;
   }
 
   for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
     const IDBConstant& c = sIDBConstants[i];
     if (c.interface != interface) {
       continue;
     }
@@ -8770,19 +8774,19 @@ nsHTMLDocumentSH::DocumentAllGetProperty
 
     if (!obj) {
       NS_ERROR("The JS engine lies!");
 
       return JS_TRUE;
     }
   }
 
-  nsHTMLDocument* doc = GetDocument(obj);
-  nsISupports* result = nsnull;
-  nsWrapperCache* cache = nsnull;
+  nsHTMLDocument *doc = GetDocument(obj);
+  nsISupports *result;
+  nsWrapperCache *cache;
   nsresult rv = NS_OK;
 
   if (JSID_IS_STRING(id)) {
     if (id == sLength_id) {
       // Map document.all.length to the length of the collection
       // document.getElementsByTagName("*"), and make sure <div
       // id="length"> doesn't shadow document.all.length.
 
@@ -9581,17 +9585,17 @@ public:
     JSContext* cx = nsnull;
     if (mContext) {
       cx = mContext->GetNativeContext();
     } else {
       nsCOMPtr<nsIThreadJSContextStack> stack =
         do_GetService("@mozilla.org/js/xpc/ContextStack;1");
       NS_ENSURE_TRUE(stack, NS_OK);
 
-      cx = stack->GetSafeJSContext();
+      stack->GetSafeJSContext(&cx);
       NS_ENSURE_TRUE(cx, NS_OK);
     }
 
     JSObject* obj = nsnull;
     mWrapper->GetJSObject(&obj);
     NS_ASSERTION(obj, "Should never be null");
     nsHTMLPluginObjElementSH::SetupProtoChain(mWrapper, cx, obj);
     return NS_OK;
--- a/dom/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/base/nsDOMScriptObjectFactory.cpp
@@ -66,53 +66,170 @@
 #include "nsXULPrototypeCache.h"
 #endif
 #include "nsThreadUtils.h"
 
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 nsIExceptionProvider* gExceptionProvider = nsnull;
 
-nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
+nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() :
+  mLoadedAllLanguages(false)
 {
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
   }
 
-  nsCOMPtr<nsIExceptionProvider> provider = new nsDOMExceptionProvider();
-  nsCOMPtr<nsIExceptionService> xs =
-    do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
+  nsCOMPtr<nsIExceptionProvider> provider(new nsDOMExceptionProvider());
+  if (provider) {
+    nsCOMPtr<nsIExceptionService> xs =
+      do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
 
-  if (xs) {
-    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
-    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
-    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
-    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
-    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
+    if (xs) {
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
+      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_EVENTS);
+    }
+
+    NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
+    provider.swap(gExceptionProvider);
   }
 
-  NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
-  provider.swap(gExceptionProvider);
-
   // And pre-create the javascript language.
-  NS_CreateJSRuntime(getter_AddRefs(mJSRuntime));
+  NS_CreateJSRuntime(getter_AddRefs(mLanguageArray[NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT)]));
 }
 
 NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)
   NS_INTERFACE_MAP_ENTRY(nsIDOMScriptObjectFactory)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScriptObjectFactory)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_ADDREF(nsDOMScriptObjectFactory)
 NS_IMPL_RELEASE(nsDOMScriptObjectFactory)
 
+/**
+ * Notes about language registration (for language other than js):
+ * - All language are expected to register (at least) 2 contract IDs
+ *    @mozilla.org/script-language;1?id=%d
+ *  using the language ID as defined in nsIProgrammingLanguage, and
+ *    @mozilla.org/script-language;1?script-type=%s
+ *  using the "mime-type" of the script language
+ *
+ *  Theoretically, a language could register multiple script-type
+ *  names, although this is discouraged - each language should have one,
+ *  canonical name.
+ *
+ *  The most common case is that languages are looked up by ID.  For this
+ *  reason, we keep an array of languages indexed by this ID - the registry
+ *  is only looked the first request for a language ID.
+ *  
+ *  The registry is looked up and getService called for each query by name.
+ *  (As services are cached by CID, multiple contractIDs will still work
+ *  correctly)
+ **/
+
+NS_IMETHODIMP
+nsDOMScriptObjectFactory::GetScriptRuntime(const nsAString &aLanguageName,
+                                           nsIScriptRuntime **aLanguage)
+{
+  // Note that many callers have optimized detection for JS (along with
+  // supporting various alternate names for JS), so don't call this.
+  // One exception is for the new "script-type" attribute on a node - and
+  // there is no need to support backwards compatible names.
+  // As JS is the default language, this is still rarely called for JS -
+  // only when a node explicitly sets JS - so that is done last.
+  nsCAutoString contractid(NS_LITERAL_CSTRING(
+                          "@mozilla.org/script-language;1?script-type="));
+  // Arbitrarily use utf8 encoding should the name have extended chars
+  AppendUTF16toUTF8(aLanguageName, contractid);
+  nsresult rv;
+  nsCOMPtr<nsIScriptRuntime> lang =
+        do_GetService(contractid.get(), &rv);
+
+  if (NS_FAILED(rv)) {
+    if (aLanguageName.Equals(NS_LITERAL_STRING("application/javascript")))
+      return GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT, aLanguage);
+    // Not JS and nothing else we know about.
+    NS_WARNING("No script language registered for this mime-type");
+    return NS_ERROR_FACTORY_NOT_REGISTERED;
+  }
+  // And stash it away in our array for fast lookup by ID.
+  PRUint32 lang_ndx = NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT);
+  if (mLanguageArray[lang_ndx] == nsnull) {
+    mLanguageArray[lang_ndx] = lang;
+  } else {
+    // All languages are services - we should have an identical object!
+    NS_ASSERTION(mLanguageArray[lang_ndx] == lang,
+                 "Got a different language for this ID???");
+  }
+  *aLanguage = lang;
+  NS_IF_ADDREF(*aLanguage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDOMScriptObjectFactory::GetScriptRuntimeByID(PRUint32 aLanguageID, 
+                                               nsIScriptRuntime **aLanguage)
+{
+  if (!NS_STID_VALID(aLanguageID)) {
+    NS_WARNING("Unknown script language");
+    return NS_ERROR_UNEXPECTED;
+  }
+  *aLanguage = mLanguageArray[NS_STID_INDEX(aLanguageID)];
+  if (!*aLanguage) {
+    nsCAutoString contractid(NS_LITERAL_CSTRING(
+                        "@mozilla.org/script-language;1?id="));
+    char langIdStr[25]; // space for an int.
+    sprintf(langIdStr, "%d", aLanguageID);
+    contractid += langIdStr;
+    nsresult rv;
+    nsCOMPtr<nsIScriptRuntime> lang = do_GetService(contractid.get(), &rv);
+
+    if (NS_FAILED(rv)) {
+      NS_ERROR("Failed to get the script language");
+      return rv;
+    }
+
+    // Stash it away in our array for fast lookup by ID.
+    mLanguageArray[NS_STID_INDEX(aLanguageID)] = lang;
+    *aLanguage = lang;
+  }
+  NS_IF_ADDREF(*aLanguage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDOMScriptObjectFactory::GetIDForScriptType(const nsAString &aLanguageName,
+                                             PRUint32 *aScriptTypeID)
+{
+  nsCOMPtr<nsIScriptRuntime> languageRuntime;
+  nsresult rv;
+  rv = GetScriptRuntime(aLanguageName, getter_AddRefs(languageRuntime));
+  if (NS_FAILED(rv))
+    return rv;
+
+  *aScriptTypeID = nsIProgrammingLanguage::JAVASCRIPT;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDOMScriptObjectFactory::NewScriptGlobalObject(bool aIsChrome,
+                                                bool aIsModalContentWindow,
+                                                nsIScriptGlobalObject **aGlobal)
+{
+  return NS_NewScriptGlobalObject(aIsChrome, aIsModalContentWindow, aGlobal);
+}
+
 NS_IMETHODIMP_(nsISupports *)
 nsDOMScriptObjectFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
 {
   return NS_GetDOMClassInfoInstance(aID);
 }
 
 NS_IMETHODIMP_(nsISupports *)
 nsDOMScriptObjectFactory::GetExternalClassInfoInstance(const nsAString& aName)
@@ -169,16 +286,18 @@ nsDOMScriptObjectFactory::Observe(nsISup
         xs->UnregisterExceptionProvider(gExceptionProvider,
                                         NS_ERROR_MODULE_DOM);
         xs->UnregisterExceptionProvider(gExceptionProvider,
                                         NS_ERROR_MODULE_SVG);
         xs->UnregisterExceptionProvider(gExceptionProvider,
                                         NS_ERROR_MODULE_DOM_XPATH);
         xs->UnregisterExceptionProvider(gExceptionProvider,
                                         NS_ERROR_MODULE_XPCONNECT);
+        xs->UnregisterExceptionProvider(gExceptionProvider,
+                                        NS_ERROR_MODULE_DOM_EVENTS);
       }
 
       NS_RELEASE(gExceptionProvider);
     }
   }
 
   return NS_OK;
 }
@@ -195,17 +314,17 @@ CreateXPConnectException(nsresult aResul
     exception = do_CreateInstance("@mozilla.org/js/xpc/Exception;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = exception->Initialize(nsnull, aResult, nsnull, nsnull, nsnull,
                                nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  exception.forget(_retval);
+  NS_ADDREF(*_retval = exception);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
 					       nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
 					       const nsIID *aProtoChainInterface,
 					       const nsIID **aInterfaces,
@@ -220,52 +339,41 @@ nsDOMScriptObjectFactory::RegisterDOMCla
                                              aConstructorFptr,
                                              aProtoChainInterface,
                                              aInterfaces,
                                              aScriptableFlags,
                                              aHasClassInterface,
                                              aConstructorCID);
 }
 
-
 // Factories
-static nsresult
-GetJSRuntime(nsIScriptRuntime** aLanguage)
-{
-  nsCOMPtr<nsIDOMScriptObjectFactory> factory =
-    do_GetService(kDOMScriptObjectFactoryCID);
-  NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
-
-  NS_IF_ADDREF(*aLanguage = factory->GetJSRuntime());
-  return NS_OK;
-}
-
 nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
                              nsIScriptRuntime **aLanguage)
 {
-  *aLanguage = NULL;
-
-  NS_ENSURE_TRUE(aLanguageName.EqualsLiteral("application/javascript"),
-                 NS_ERROR_FAILURE);
-
-  return GetJSRuntime(aLanguage);
+  nsresult rv;
+  *aLanguage = nsnull;
+  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
+        do_GetService(kDOMScriptObjectFactoryCID, &rv);
+  if (NS_FAILED(rv))
+    return rv;
+  return factory->GetScriptRuntime(aLanguageName, aLanguage);
 }
 
 nsresult NS_GetScriptRuntimeByID(PRUint32 aScriptTypeID,
                                  nsIScriptRuntime **aLanguage)
 {
-  *aLanguage = NULL;
-
-  NS_ENSURE_TRUE(aScriptTypeID == nsIProgrammingLanguage::JAVASCRIPT,
-                 NS_ERROR_FAILURE);
-
-  return GetJSRuntime(aLanguage);
+  nsresult rv;
+  *aLanguage = nsnull;
+  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
+        do_GetService(kDOMScriptObjectFactoryCID, &rv);
+  if (NS_FAILED(rv))
+    return rv;
+  return factory->GetScriptRuntimeByID(aScriptTypeID, aLanguage);
 }
 
-
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsDOMExceptionProvider, nsIExceptionProvider)
 
 NS_IMETHODIMP
 nsDOMExceptionProvider::GetException(nsresult result,
                                      nsIException *aDefaultException,
                                      nsIException **_retval)
 {
   if (!NS_IsMainThread()) {
--- a/dom/base/nsDOMScriptObjectFactory.h
+++ b/dom/base/nsDOMScriptObjectFactory.h
@@ -63,26 +63,43 @@ public:
   nsDOMScriptObjectFactory();
 
   NS_DECL_ISUPPORTS
 
   // nsIObserver
   NS_DECL_NSIOBSERVER
 
   // nsIDOMScriptObjectFactory
+  NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
+                              nsIScriptRuntime **aLanguage);
+
+  NS_IMETHOD GetScriptRuntimeByID(PRUint32 aLanguageID, 
+                                  nsIScriptRuntime **aLanguage);
+
+  NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
+                                PRUint32 *aLanguageID);
+
+  NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
+                                   bool aIsModalContentWindow,
+                                   nsIScriptGlobalObject **aGlobal);
+
   NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID);
   NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName);
 
   NS_IMETHOD RegisterDOMClassInfo(const char *aName,
                                   nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
                                   const nsIID *aProtoChainInterface,
                                   const nsIID **aInterfaces,
                                   PRUint32 aScriptableFlags,
                                   bool aHasClassInterface,
                                   const nsCID *aConstructorCID);
+
+protected:
+  bool mLoadedAllLanguages;
+  nsCOMPtr<nsIScriptRuntime> mLanguageArray[NS_STID_ARRAY_UBOUND];
 };
 
 class nsDOMExceptionProvider : public nsIExceptionProvider
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEXCEPTIONPROVIDER
 };
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -881,16 +881,17 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
 #endif
     mShowFocusRingForContent(false),
     mFocusByKeyOccurred(false),
     mNotifiedIDDestroyed(false),
     mTimeoutInsertionPoint(nsnull),
     mTimeoutPublicIdCounter(1),
     mTimeoutFiringDepth(0),
     mJSObject(nsnull),
+    mPendingStorageEventsObsolete(nsnull),
     mTimeoutsSuspendDepth(0),
     mFocusMethod(0),
     mSerial(0),
 #ifdef DEBUG
     mSetOpenerWindowCalled(false),
 #endif
     mCleanedUp(false),
     mCallCleanUpAfterModalDialogCloses(false),
@@ -915,19 +916,20 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
       NS_ADDREF(mObserver);
       nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
       if (os) {
         // Watch for online/offline status changes so we can fire events. Use
         // a strong reference.
         os->AddObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                         false);
 
-        // Watch for dom-storage2-changed so we can fire storage
+        // Watch for dom-storage-changed so we can fire storage
         // events. Use a strong reference.
         os->AddObserver(mObserver, "dom-storage2-changed", false);
+        os->AddObserver(mObserver, "dom-storage-changed", false);
       }
     }
   } else {
     // |this| is an outer window. Outer windows start out frozen and
     // remain frozen until they get an inner window, so freeze this
     // outer window here.
     Freeze();
 
@@ -1196,16 +1198,17 @@ nsGlobalWindow::CleanUp(bool aIgnoreModa
   mEventTargetObjects.EnumerateEntries(DisconnectEventTargetObjects, nsnull);
   mEventTargetObjects.Clear();
 
   if (mObserver) {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
       os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
       os->RemoveObserver(mObserver, "dom-storage2-changed");
+      os->RemoveObserver(mObserver, "dom-storage-changed");
     }
 
     // Drop its reference to this dying window, in case for some bogus reason
     // the object stays around.
     mObserver->Forget();
     NS_RELEASE(mObserver);
   }
 
@@ -1218,16 +1221,17 @@ nsGlobalWindow::CleanUp(bool aIgnoreModa
   mStatusbar = nsnull;
   mScrollbars = nsnull;
   mLocation = nsnull;
   mHistory = nsnull;
   mFrames = nsnull;
   mWindowUtils = nsnull;
   mApplicationCache = nsnull;
   mIndexedDB = nsnull;
+  mPendingStorageEventsObsolete = nsnull;
 
   mPerformance = nsnull;
 
   ClearControllers();
 
   mOpener = nsnull;             // Forces Release
   if (mContext) {
 #ifdef DEBUG
@@ -6190,17 +6194,17 @@ PostMessageEvent::Run()
     cx = scriptContext->GetNativeContext();
   }
 
   if (!cx) {
     // This can happen if mTargetWindow has been closed.  To avoid leaking,
     // we need to find a JSContext.
     nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
     if (cxStack) {
-      cx = cxStack->GetSafeJSContext();
+      cxStack->GetSafeJSContext(&cx);
     }
 
     if (!cx) {
       NS_WARNING("Cannot find a JSContext!  Leaking PostMessage buffer.");
       return NS_ERROR_FAILURE;
     }
   }
 
@@ -8466,16 +8470,86 @@ nsGlobalWindow::Observe(nsISupports* aSu
       // we don't need to fire.
       mFireOfflineStatusChangeEventOnThaw = !mFireOfflineStatusChangeEventOnThaw;
     } else {
       FireOfflineStatusEvent();
     }
     return NS_OK;
   }
 
+  if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage-changed")) {
+    nsIPrincipal *principal;
+    nsresult rv;
+
+    principal = GetPrincipal();
+    if (principal) {
+      // A global storage object changed, check to see if it's one
+      // this window can access.
+
+      nsCOMPtr<nsIURI> codebase;
+      principal->GetURI(getter_AddRefs(codebase));
+
+      if (!codebase) {
+        return NS_OK;
+      }
+
+      nsCAutoString currentDomain;
+      rv = codebase->GetAsciiHost(currentDomain);
+      if (NS_FAILED(rv)) {
+        return NS_OK;
+      }
+    }
+
+    nsAutoString domain(aData);
+
+    if (IsFrozen()) {
+      // This window is frozen, rather than firing the events here,
+      // store the domain in which the change happened and fire the
+      // events if we're ever thawed.
+
+      if (!mPendingStorageEventsObsolete) {
+        mPendingStorageEventsObsolete = new nsDataHashtable<nsStringHashKey, bool>;
+        NS_ENSURE_TRUE(mPendingStorageEventsObsolete, NS_ERROR_OUT_OF_MEMORY);
+
+        rv = mPendingStorageEventsObsolete->Init();
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
+
+      mPendingStorageEventsObsolete->Put(domain, true);
+
+      return NS_OK;
+    }
+
+    nsRefPtr<nsDOMStorageEventObsolete> event = new nsDOMStorageEventObsolete();
+    NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
+
+    rv = event->InitStorageEvent(NS_LITERAL_STRING("storage"), false, false, domain);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
+
+    nsCOMPtr<nsIDOMEventTarget> target;
+
+    if (htmlDoc) {
+      nsCOMPtr<nsIDOMHTMLElement> body;
+      htmlDoc->GetBody(getter_AddRefs(body));
+
+      target = do_QueryInterface(body);
+    }
+
+    if (!target) {
+      target = this;
+    }
+
+    bool defaultActionEnabled;
+    target->DispatchEvent((nsIDOMStorageEventObsolete *)event, &defaultActionEnabled);
+
+    return NS_OK;
+  }
+
   if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage2-changed")) {
     nsIPrincipal *principal;
     nsresult rv;
 
     nsCOMPtr<nsIDOMStorageEvent> event = do_QueryInterface(aSubject, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIDOMStorage> changingStorage;
@@ -8619,25 +8693,47 @@ nsGlobalWindow::CloneStorageEvent(const 
   aEvent->GetStorageArea(getter_AddRefs(storageArea));
 
   aEvent = new nsDOMStorageEvent();
   return aEvent->InitStorageEvent(aType, canBubble, cancelable,
                                   key, oldValue, newValue,
                                   url, storageArea);
 }
 
+static PLDHashOperator
+FirePendingStorageEvents(const nsAString& aKey, bool aData, void *userArg)
+{
+  nsGlobalWindow *win = static_cast<nsGlobalWindow *>(userArg);
+
+  nsCOMPtr<nsIDOMStorage> storage;
+  win->GetSessionStorage(getter_AddRefs(storage));
+
+  if (storage) {
+    win->Observe(storage, "dom-storage-changed",
+                 aKey.IsEmpty() ? nsnull : PromiseFlatString(aKey).get());
+  }
+
+  return PL_DHASH_NEXT;
+}
+
 nsresult
 nsGlobalWindow::FireDelayedDOMEvents()
 {
   FORWARD_TO_INNER(FireDelayedDOMEvents, (), NS_ERROR_UNEXPECTED);
 
   for (PRInt32 i = 0; i < mPendingStorageEvents.Count(); ++i) {
     Observe(mPendingStorageEvents[i], "dom-storage2-changed", nsnull);
   }
 
+  if (mPendingStorageEventsObsolete) {
+    // Fire pending storage events.
+    mPendingStorageEventsObsolete->EnumerateRead(FirePendingStorageEvents, this);
+    mPendingStorageEventsObsolete = nsnull;
+  }
+
   if (mApplicationCache) {
     static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())->FirePendingEvents();
   }
 
   if (mFireOfflineStatusChangeEventOnThaw) {
     mFireOfflineStatusChangeEventOnThaw = false;
     FireOfflineStatusEvent();
   }
@@ -9246,17 +9342,17 @@ nsGlobalWindow::RunTimeout(nsTimeout *aT
     // Hold on to the timeout in case mExpr or mFunObj releases its
     // doc.
     timeout->AddRef();
 
     ++gRunningTimeoutDepth;
     ++mTimeoutFiringDepth;
 
     bool trackNestingLevel = !timeout->mIsInterval;
-    PRUint32 nestingLevel = 0;
+    PRUint32 nestingLevel;
     if (trackNestingLevel) {
       nestingLevel = sNestingLevel;
       sNestingLevel = timeout->mNestingLevel;
     }
 
     nsCOMPtr<nsIScriptTimeoutHandler> handler(timeout->mScriptHandler);
     JSObject* scriptObject = handler->GetScriptObject();
     if (!scriptObject) {
@@ -9964,19 +10060,18 @@ nsGlobalWindow::SuspendTimeouts(PRUint32
   FORWARD_TO_INNER_VOID(SuspendTimeouts, (aIncrease, aFreezeChildren));
 
   bool suspended = (mTimeoutsSuspendDepth != 0);
   mTimeoutsSuspendDepth += aIncrease;
 
   if (!suspended) {
     nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
     if (ac) {
-      for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
+      for (int i = 0; i < mEnabledSensors.Length(); i++)
         ac->RemoveWindowListener(mEnabledSensors[i], this);
-      }
     }
 
     // Suspend all of the workers for this window.
     nsIScriptContext *scx = GetContextInternal();
     JSContext *cx = scx ? scx->GetNativeContext() : nsnull;
     mozilla::dom::workers::SuspendWorkersForWindow(cx, this);
 
     TimeStamp now = TimeStamp::Now();
@@ -10045,19 +10140,18 @@ nsGlobalWindow::ResumeTimeouts(bool aTha
   NS_ASSERTION(mTimeoutsSuspendDepth, "Mismatched calls to ResumeTimeouts!");
   --mTimeoutsSuspendDepth;
   bool shouldResume = (mTimeoutsSuspendDepth == 0);
   nsresult rv;
 
   if (shouldResume) {
     nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
     if (ac) {
-      for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
+      for (int i = 0; i < mEnabledSensors.Length(); i++)
         ac->AddWindowListener(mEnabledSensors[i], this);
-      }
     }
 
     // Resume all of the workers for this window.
     nsIScriptContext *scx = GetContextInternal();
     JSContext *cx = scx ? scx->GetNativeContext() : nsnull;
     mozilla::dom::workers::ResumeWorkersForWindow(cx, this);
 
     // Restore all of the timeouts, using the stored time remaining
@@ -10154,17 +10248,17 @@ nsGlobalWindow::TimeoutSuspendCount()
   FORWARD_TO_INNER(TimeoutSuspendCount, (), 0);
   return mTimeoutsSuspendDepth;
 }
 
 void
 nsGlobalWindow::EnableDeviceSensor(PRUint32 aType)
 {
   bool alreadyEnabled = false;
-  for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
+  for (int i = 0; i < mEnabledSensors.Length(); i++) {
     if (mEnabledSensors[i] == aType) {
       alreadyEnabled = true;
       break;
     }
   }
 
   if (alreadyEnabled)
     return;
@@ -10174,18 +10268,18 @@ nsGlobalWindow::EnableDeviceSensor(PRUin
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac)
     ac->AddWindowListener(aType, this);
 }
 
 void
 nsGlobalWindow::DisableDeviceSensor(PRUint32 aType)
 {
-  PRInt32 doomedElement = -1;
-  for (PRUint32 i = 0; i < mEnabledSensors.Length(); i++) {
+  PRUint32 doomedElement = -1;
+  for (int i = 0; i < mEnabledSensors.Length(); i++) {
     if (mEnabledSensors[i] == aType) {
       doomedElement = i;
       break;
     }
   }
 
   if (doomedElement == -1)
     return;
@@ -10641,16 +10735,43 @@ nsGlobalModalWindow::SetNewDocument(nsID
 void
 nsGlobalWindow::SetHasAudioAvailableEventListeners()
 {
   if (mDoc) {
     mDoc->NotifyAudioAvailableListener();
   }
 }
 
+//*****************************************************************************
+// nsGlobalWindow: Creator Function (This should go away)
+//*****************************************************************************
+
+nsresult
+NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
+                         nsIScriptGlobalObject **aResult)
+{
+  *aResult = nsnull;
+
+  nsGlobalWindow *global;
+
+  if (aIsChrome) {
+    global = new nsGlobalChromeWindow(nsnull);
+  } else if (aIsModalContentWindow) {
+    global = new nsGlobalModalWindow(nsnull);
+  } else {
+    global = new nsGlobalWindow(nsnull);
+  }
+
+  NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);
+
+  NS_ADDREF(*aResult = global);
+
+  return NS_OK;
+}
+
 #define EVENT(name_, id_, type_, struct_)                                    \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
                                              jsval *vp) {                    \
     nsEventListenerManager *elm = GetListenerManager(false);              \
     if (elm) {                                                               \
       elm->GetJSEventListener(nsGkAtoms::on##name_, vp);                     \
     } else {                                                                 \
       *vp = JSVAL_NULL;                                                      \
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -934,16 +934,17 @@ protected:
 
   // These member variables are used on both inner and the outer windows.
   nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
   nsCOMPtr<nsIDocument> mDoc;  // For fast access to principals
   JSObject* mJSObject;
 
   typedef nsCOMArray<nsIDOMStorageEvent> nsDOMStorageEventArray;
   nsDOMStorageEventArray mPendingStorageEvents;
+  nsAutoPtr< nsDataHashtable<nsStringHashKey, bool> > mPendingStorageEventsObsolete;
 
   PRUint32 mTimeoutsSuspendDepth;
 
   // the method that was used to focus mFocusedNode
   PRUint32 mFocusMethod;
 
   PRUint32 mSerial;
 
@@ -1052,25 +1053,13 @@ public:
                                               nsISupports *aState,
                                               bool aForceReuseInnerWindow);
 
 protected:
   nsCOMPtr<nsIVariant> mReturnValue;
 };
 
 /* factory function */
-inline already_AddRefed<nsGlobalWindow>
-NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
-{
-  nsRefPtr<nsGlobalWindow> global;
-
-  if (aIsChrome) {
-    global = new nsGlobalChromeWindow(nsnull);
-  } else if (aIsModalContentWindow) {
-    global = new nsGlobalModalWindow(nsnull);
-  } else {
-    global = new nsGlobalWindow(nsnull);
-  }
-
-  return global.forget();
-}
+nsresult
+NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
+                         nsIScriptGlobalObject **aResult);
 
 #endif /* nsGlobalWindow_h___ */
--- a/dom/base/nsIDOMScriptObjectFactory.h
+++ b/dom/base/nsIDOMScriptObjectFactory.h
@@ -36,54 +36,67 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsIDOMScriptObjectFactory_h__
 #define nsIDOMScriptObjectFactory_h__
 
 #include "nsISupports.h"
 #include "nsIDOMClassInfo.h"
 #include "nsStringGlue.h"
-#include "nsIScriptRuntime.h"
 
-#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
-{ 0x2a50e17c, 0x46ff, 0x4150, \
-  { 0xbb, 0x46, 0xd8, 0x07, 0xb3, 0x36, 0xde, 0xab } }
+#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID   \
+{ 0x8c0eb687, 0xa859, 0x4a62, \
+ { 0x99, 0x82, 0xea, 0xbf, 0x9e, 0xf5, 0x59, 0x5f } }
 
 class nsIScriptContext;
 class nsIScriptGlobalObject;
+class nsIScriptRuntime;
 class nsIDOMEventListener;
 
 typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
   (const char* aName);
 
 class nsIDOMScriptObjectFactory : public nsISupports {
 public:  
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
 
+  // Get a script language given its "name" (ie, the mime-type)
+  // Note that to fetch javascript from this function, you must currently
+  // use the name "application/javascript" (but also note that all existing
+  // callers of this function optimize the detection of JS, so do not
+  // ask this function for JS)
+  NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
+                              nsIScriptRuntime **aLanguage) = 0;
+
+  // Get a script language given its nsIProgrammingLanguage ID.
+  NS_IMETHOD GetScriptRuntimeByID(PRUint32 aScriptTypeID, 
+                                  nsIScriptRuntime **aLanguage) = 0;
+
+  // Get the ID for a language given its name - but like GetScriptRuntime,
+  // only "application/javascript" is currently supported for JS.
+  NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
+                                PRUint32 *aScriptTypeID) = 0;
+
+  NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
+                                   bool aIsModalContentWindow,
+                                   nsIScriptGlobalObject **aGlobal) = 0;
+
   NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
   NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) = 0;
 
   // Register the info for an external class. aName must be static
   // data, it will not be deleted by the DOM code. aProtoChainInterface
   // must be registered in the JAVASCRIPT_DOM_INTERFACE category, or
   // prototypes for this class won't work (except if the interface
   // name starts with nsIDOM).
   NS_IMETHOD RegisterDOMClassInfo(const char *aName,
                                   nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
                                   const nsIID *aProtoChainInterface,
                                   const nsIID **aInterfaces,
                                   PRUint32 aScriptableFlags,
                                   bool aHasClassInterface,
                                   const nsCID *aConstructorCID) = 0;
-
-  nsIScriptRuntime* GetJSRuntime()
-  {
-    return mJSRuntime;
-  }
-
-protected:
-  nsCOMPtr<nsIScriptRuntime> mJSRuntime;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,
                               NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
 
 #endif /* nsIDOMScriptObjectFactory_h__ */
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1319,23 +1319,23 @@ def getArgumentConversionTemplate(type, 
             replacements["intermediateCast"] = "(uint8_t)"
         elif tag is IDLType.Tags.int16:
             replacements["intermediateCast"] = "(uint16_t)"
         else:
             replacements["intermediateCast"] = ""
     elif tag is IDLType.Tags.int64:
         # XXXbz this may not match what WebIDL says to do in terms of reducing
         # mod 2^64.  Should we check?
-        replacements["jstype"] = "int64_t"
-        replacements["converter"] = "xpc::ValueToInt64"
+        replacements["jstype"] = "PRInt64"
+        replacements["converter"] = "xpc_qsValueToInt64"
     elif tag is IDLType.Tags.uint64:
         # XXXbz this may not match what WebIDL says to do in terms of reducing
         # mod 2^64.  Should we check?
-        replacements["jstype"] = "uint64_t"
-        replacements["converter"] = "xpc::ValueToUint64"
+        replacements["jstype"] = "PRUint64"
+        replacements["converter"] = "xpc_qsValueToUint64"
     elif tag in [IDLType.Tags.float, IDLType.Tags.double]:
         replacements["jstype"] = "double"
         replacements["converter"] = "JS::ToNumber"
     else:
         raise TypeError("Unknown primitive type '%s'" % type);
 
     # We substitute the %(name)s things here.  Our caller will
     # substitute the ${name} things.
deleted file mode 100644
--- a/dom/imported-tests/Makefile.in
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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/.
-
-DEPTH = ../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = dom/imported-tests
-
-DIRS = \
-  $(NULL)
-
-include $(srcdir)/html.mk
-include $(srcdir)/webapps.mk
-include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
-
-_SUPPORT_FILES = \
-  testharness.js \
-  testharnessreport.js \
-  testharness.css \
-  idlharness.js \
-  WebIDLParser.js \
-  $(NULL)
-
-testharnessreport.js: testharnessreport.js.in writeReporter.py html.json webapps.json
-	$(PYTHON_PATH) $(srcdir)/writeReporter.py $<
-
-libs:: $(_SUPPORT_FILES)
-	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/resources
deleted file mode 100644
--- a/dom/imported-tests/README
+++ /dev/null
@@ -1,97 +0,0 @@
-This directory contains tests imported from W3C test suites. In order to make it
-as easy as possible to update these tests, no changes are made to the imported
-files (names for scripted tests do get a test_ prefix to integrate with the test
-runner, however). The scripts to update tests are provided.
-
-
-=======================
-Files in this directory
-=======================
-
-Source;  Usage and purpose;  License
-
-* testharness.js / testharness.css
-  Directly imported from the W3C repository (<http://dvcs.w3.org/hg/resources>),
-  with the updateTestharness.py script.
-  Provide the test harness.
-  W3C Test Suite License / W3C 3-clause BSD License
-
-* idlharness.js
-  Directly imported from the W3C repository (<http://dvcs.w3.org/hg/resources>),
-  with the updateTestharness.py script.
-  Used to test WebIDL.
-  W3C Test Suite License / W3C 3-clause BSD License
-
-* WebIDLParser.js
-  Directly imported from the W3C repository (<http://dvcs.w3.org/hg/resources>),
-  with the updateTestharness.py script.
-  Used by idlharness.js to parse IDL blocks.
-  MIT License
-
-* updateTestharness.py
-  Used to update the above files.
-  MPL
-
-* parseManifest.py
-  Imported from <https://bitbucket.org/ms2ger/test-runner>. Parses MANIFEST
-  files (provided in the W3C repository) as documented at
-  <https://bitbucket.org/ms2ger/test-runner/raw/tip/manifests.txt>.
-  MIT License
-
-* testharnessreport.js.in
-  Glue between testharness.js and our Mochitest runner.
-  MPL
-
-* importTestsuite.py
-  Imports a test suite from a remote repository. Takes one argument, a file in
-  the format described under webapps.txt.
-  Note: removes both source and destination directory before starting. Do not
-        use with outstanding changes in either directory.
-  MPL
-
-* Makefile.in
-  Integration with our build system. Installs support files into /resources and
-  includes a .mk file for each repository.
-  MPL
-
-* failures.txt
-  List of JSON files with expected failures.
-
-* html.json / webapps.json / ...
-  Expected failures for tests in the webapps repository.
-
-* html.mk / webapps.mk / ...
-  Generated by importTestsuite.py from webapps.txt.
-  Contains a list of the directories with tests. To be included in Makefile.in.
-
-* html.txt / webapps.txt / ...
-  Input to importTestsuite.py.
-  Lists the URL of the repository and the destination directory (separated by a
-  vertical bar), followed by a list of directories within the repository
-  (separated by line feeds).
-
-* html / webapps / ...
-  Actual tests.
-  W3C Test Suite License / W3C 3-clause BSD License
-
-* writeReporter.py
-  Generates testharness.js from testharnessreport.js.in and the JSON files for
-  repositories listed in failures.txt.
-  MPL
-
-
-=====================================================================
-Importing an additional directory from an already-imported repository
-=====================================================================
-
-Add a line to the relevant data file (e.g. webapps.txt), with the path to the
-additional directory relative to the root of the remote repository, and then run
-the importTestsuite.py script, passing the data file as its argument.
-
-
-==========================
-Importing a new test suite
-==========================
-
-Create a data file in the format documented above, and run the
-importTestsuite.py script, passing the data file as its argument.
deleted file mode 100644
--- a/dom/imported-tests/WebIDLParser.js
+++ /dev/null
@@ -1,6020 +0,0 @@
-// From https://github.com/darobin/webidl.js/tree/, under MIT license
-// Forked at https://github.com/ayg/webidl.js
-window.WebIDLParser = (function(){
-  /* Generated by PEG.js 0.6.2 (http://pegjs.majda.cz/). */
-  
-  var result = {
-    /*
-     * Parses the input with a generated parser. If the parsing is successfull,
-     * returns a value explicitly or implicitly specified by the grammar from
-     * which the parser was generated (see |PEG.buildParser|). If the parsing is
-     * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
-     */
-    parse: function(input, startRule) {
-      var parseFunctions = {
-        "AbsoluteScopedName": parse_AbsoluteScopedName,
-        "Argument": parse_Argument,
-        "Arguments": parse_Arguments,
-        "ArgumentsRest": parse_ArgumentsRest,
-        "ArrayType": parse_ArrayType,
-        "Attribute": parse_Attribute,
-        "BooleanLiteral": parse_BooleanLiteral,
-        "ExtAttr": parse_ExtAttr,
-        "ExtAttrArgList": parse_ExtAttrArgList,
-        "ExtAttrNameValue": parse_ExtAttrNameValue,
-        "ExtAttrNamedArgList": parse_ExtAttrNamedArgList,
-        "ExtAttrNoArg": parse_ExtAttrNoArg,
-        "ExtAttrs": parse_ExtAttrs,
-        "ExtAttrsRest": parse_ExtAttrsRest,
-        "GetRaises": parse_GetRaises,
-        "Nullable": parse_Nullable,
-        "Operation": parse_Operation,
-        "OperationRest": parse_OperationRest,
-        "PrimitiveType": parse_PrimitiveType,
-        "Qualifiers": parse_Qualifiers,
-        "Raises": parse_Raises,
-        "RelativeScopedName": parse_RelativeScopedName,
-        "ReturnType": parse_ReturnType,
-        "ScopedName": parse_ScopedName,
-        "ScopedNameList": parse_ScopedNameList,
-        "ScopedNameListRest": parse_ScopedNameListRest,
-        "ScopedNameRest": parse_ScopedNameRest,
-        "Sequence": parse_Sequence,
-        "SetRaises": parse_SetRaises,
-        "SimpleType": parse_SimpleType,
-        "Special": parse_Special,
-        "Stringifier": parse_Stringifier,
-        "TypeDesc": parse_TypeDesc,
-        "UnsignedIntegerType": parse_UnsignedIntegerType,
-        "attrOrOp": parse_attrOrOp,
-        "const": parse_const,
-        "constExpr": parse_constExpr,
-        "decimal": parse_decimal,
-        "defaultValue": parse_defaultValue,
-        "definition": parse_definition,
-        "definitions": parse_definitions,
-        "dictionary": parse_dictionary,
-        "dictionaryMember": parse_dictionaryMember,
-        "dotFloat": parse_dotFloat,
-        "exMember": parse_exMember,
-        "exception": parse_exception,
-        "expFloat": parse_expFloat,
-        "extendedAttributeList": parse_extendedAttributeList,
-        "field": parse_field,
-        "float": parse_float,
-        "floatEe": parse_floatEe,
-        "hex": parse_hex,
-        "identifier": parse_identifier,
-        "ifInheritance": parse_ifInheritance,
-        "ifMember": parse_ifMember,
-        "implements": parse_implements,
-        "integer": parse_integer,
-        "interface": parse_interface,
-        "leadFloat": parse_leadFloat,
-        "module": parse_module,
-        "octal": parse_octal,
-        "other": parse_other,
-        "partialinterface": parse_partialinterface,
-        "s": parse_s,
-        "space": parse_space,
-        "string": parse_string,
-        "type": parse_type,
-        "typedef": parse_typedef,
-        "w": parse_w
-      };
-      
-      if (startRule !== undefined) {
-        if (parseFunctions[startRule] === undefined) {
-          throw new Error("Invalid rule name: " + quote(startRule) + ".");
-        }
-      } else {
-        startRule = "definitions";
-      }
-      
-      var pos = 0;
-      var reportMatchFailures = true;
-      var rightmostMatchFailuresPos = 0;
-      var rightmostMatchFailuresExpected = [];
-      var cache = {};
-      
-      function padLeft(input, padding, length) {
-        var result = input;
-        
-        var padLength = length - input.length;
-        for (var i = 0; i < padLength; i++) {
-          result = padding + result;
-        }
-        
-        return result;
-      }
-      
-      function escape(ch) {
-        var charCode = ch.charCodeAt(0);
-        
-        if (charCode <= 0xFF) {
-          var escapeChar = 'x';
-          var length = 2;
-        } else {
-          var escapeChar = 'u';
-          var length = 4;
-        }
-        
-        return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
-      }
-      
-      function quote(s) {
-        /*
-         * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
-         * string literal except for the closing quote character, backslash,
-         * carriage return, line separator, paragraph separator, and line feed.
-         * Any character may appear in the form of an escape sequence.
-         */
-        return '"' + s
-          .replace(/\\/g, '\\\\')            // backslash
-          .replace(/"/g, '\\"')              // closing quote character
-          .replace(/\r/g, '\\r')             // carriage return
-          .replace(/\n/g, '\\n')             // line feed
-          .replace(/[\x80-\uFFFF]/g, escape) // non-ASCII characters
-          + '"';
-      }
-      
-      function matchFailed(failure) {
-        if (pos < rightmostMatchFailuresPos) {
-          return;
-        }
-        
-        if (pos > rightmostMatchFailuresPos) {
-          rightmostMatchFailuresPos = pos;
-          rightmostMatchFailuresExpected = [];
-        }
-        
-        rightmostMatchFailuresExpected.push(failure);
-      }
-      
-      function parse_space() {
-        var cacheKey = 'space@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        if (input.substr(pos, 1) === " ") {
-          var result20 = " ";
-          pos += 1;
-        } else {
-          var result20 = null;
-          if (reportMatchFailures) {
-            matchFailed("\" \"");
-          }
-        }
-        if (result20 !== null) {
-          var result0 = result20;
-        } else {
-          if (input.substr(pos, 1) === "	") {
-            var result19 = "	";
-            pos += 1;
-          } else {
-            var result19 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"	\"");
-            }
-          }
-          if (result19 !== null) {
-            var result0 = result19;
-          } else {
-            if (input.substr(pos, 1) === "\r") {
-              var result18 = "\r";
-              pos += 1;
-            } else {
-              var result18 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"\\r\"");
-              }
-            }
-            if (result18 !== null) {
-              var result0 = result18;
-            } else {
-              if (input.substr(pos, 1) === "\n") {
-                var result17 = "\n";
-                pos += 1;
-              } else {
-                var result17 = null;
-                if (reportMatchFailures) {
-                  matchFailed("\"\\n\"");
-                }
-              }
-              if (result17 !== null) {
-                var result0 = result17;
-              } else {
-                if (input.substr(pos, 1) === "") {
-                  var result16 = "";
-                  pos += 1;
-                } else {
-                  var result16 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"\"");
-                  }
-                }
-                if (result16 !== null) {
-                  var result0 = result16;
-                } else {
-                  var savedPos3 = pos;
-                  if (input.substr(pos, 2) === "//") {
-                    var result12 = "//";
-                    pos += 2;
-                  } else {
-                    var result12 = null;
-                    if (reportMatchFailures) {
-                      matchFailed("\"//\"");
-                    }
-                  }
-                  if (result12 !== null) {
-                    var result13 = [];
-                    if (input.substr(pos).match(/^[^\n]/) !== null) {
-                      var result15 = input.charAt(pos);
-                      pos++;
-                    } else {
-                      var result15 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("[^\\n]");
-                      }
-                    }
-                    while (result15 !== null) {
-                      result13.push(result15);
-                      if (input.substr(pos).match(/^[^\n]/) !== null) {
-                        var result15 = input.charAt(pos);
-                        pos++;
-                      } else {
-                        var result15 = null;
-                        if (reportMatchFailures) {
-                          matchFailed("[^\\n]");
-                        }
-                      }
-                    }
-                    if (result13 !== null) {
-                      if (input.substr(pos, 1) === "\n") {
-                        var result14 = "\n";
-                        pos += 1;
-                      } else {
-                        var result14 = null;
-                        if (reportMatchFailures) {
-                          matchFailed("\"\\n\"");
-                        }
-                      }
-                      if (result14 !== null) {
-                        var result11 = [result12, result13, result14];
-                      } else {
-                        var result11 = null;
-                        pos = savedPos3;
-                      }
-                    } else {
-                      var result11 = null;
-                      pos = savedPos3;
-                    }
-                  } else {
-                    var result11 = null;
-                    pos = savedPos3;
-                  }
-                  if (result11 !== null) {
-                    var result0 = result11;
-                  } else {
-                    var savedPos0 = pos;
-                    if (input.substr(pos, 2) === "/*") {
-                      var result2 = "/*";
-                      pos += 2;
-                    } else {
-                      var result2 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"/*\"");
-                      }
-                    }
-                    if (result2 !== null) {
-                      var result3 = [];
-                      if (input.substr(pos).match(/^[^*]/) !== null) {
-                        var result10 = input.charAt(pos);
-                        pos++;
-                      } else {
-                        var result10 = null;
-                        if (reportMatchFailures) {
-                          matchFailed("[^*]");
-                        }
-                      }
-                      if (result10 !== null) {
-                        var result5 = result10;
-                      } else {
-                        var savedPos1 = pos;
-                        if (input.substr(pos, 1) === "*") {
-                          var result7 = "*";
-                          pos += 1;
-                        } else {
-                          var result7 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\"*\"");
-                          }
-                        }
-                        if (result7 !== null) {
-                          var savedPos2 = pos;
-                          var savedReportMatchFailuresVar0 = reportMatchFailures;
-                          reportMatchFailures = false;
-                          if (input.substr(pos, 1) === "/") {
-                            var result9 = "/";
-                            pos += 1;
-                          } else {
-                            var result9 = null;
-                            if (reportMatchFailures) {
-                              matchFailed("\"/\"");
-                            }
-                          }
-                          reportMatchFailures = savedReportMatchFailuresVar0;
-                          if (result9 === null) {
-                            var result8 = '';
-                          } else {
-                            var result8 = null;
-                            pos = savedPos2;
-                          }
-                          if (result8 !== null) {
-                            var result6 = [result7, result8];
-                          } else {
-                            var result6 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result6 = null;
-                          pos = savedPos1;
-                        }
-                        if (result6 !== null) {
-                          var result5 = result6;
-                        } else {
-                          var result5 = null;;
-                        };
-                      }
-                      while (result5 !== null) {
-                        result3.push(result5);
-                        if (input.substr(pos).match(/^[^*]/) !== null) {
-                          var result10 = input.charAt(pos);
-                          pos++;
-                        } else {
-                          var result10 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("[^*]");
-                          }
-                        }
-                        if (result10 !== null) {
-                          var result5 = result10;
-                        } else {
-                          var savedPos1 = pos;
-                          if (input.substr(pos, 1) === "*") {
-                            var result7 = "*";
-                            pos += 1;
-                          } else {
-                            var result7 = null;
-                            if (reportMatchFailures) {
-                              matchFailed("\"*\"");
-                            }
-                          }
-                          if (result7 !== null) {
-                            var savedPos2 = pos;
-                            var savedReportMatchFailuresVar0 = reportMatchFailures;
-                            reportMatchFailures = false;
-                            if (input.substr(pos, 1) === "/") {
-                              var result9 = "/";
-                              pos += 1;
-                            } else {
-                              var result9 = null;
-                              if (reportMatchFailures) {
-                                matchFailed("\"/\"");
-                              }
-                            }
-                            reportMatchFailures = savedReportMatchFailuresVar0;
-                            if (result9 === null) {
-                              var result8 = '';
-                            } else {
-                              var result8 = null;
-                              pos = savedPos2;
-                            }
-                            if (result8 !== null) {
-                              var result6 = [result7, result8];
-                            } else {
-                              var result6 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result6 = null;
-                            pos = savedPos1;
-                          }
-                          if (result6 !== null) {
-                            var result5 = result6;
-                          } else {
-                            var result5 = null;;
-                          };
-                        }
-                      }
-                      if (result3 !== null) {
-                        if (input.substr(pos, 2) === "*/") {
-                          var result4 = "*/";
-                          pos += 2;
-                        } else {
-                          var result4 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\"*/\"");
-                          }
-                        }
-                        if (result4 !== null) {
-                          var result1 = [result2, result3, result4];
-                        } else {
-                          var result1 = null;
-                          pos = savedPos0;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos0;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos0;
-                    }
-                    if (result1 !== null) {
-                      var result0 = result1;
-                    } else {
-                      var result0 = null;;
-                    };
-                  };
-                };
-              };
-            };
-          };
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_s() {
-        var cacheKey = 's@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var result1 = parse_space();
-        if (result1 !== null) {
-          var result0 = [];
-          while (result1 !== null) {
-            result0.push(result1);
-            var result1 = parse_space();
-          }
-        } else {
-          var result0 = null;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_w() {
-        var cacheKey = 'w@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var result1 = parse_s();
-        var result0 = result1 !== null ? result1 : '';
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_identifier() {
-        var cacheKey = 'identifier@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos).match(/^[A-Z_a-z]/) !== null) {
-          var result3 = input.charAt(pos);
-          pos++;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("[A-Z_a-z]");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = [];
-          if (input.substr(pos).match(/^[0-9A-Z_a-z]/) !== null) {
-            var result5 = input.charAt(pos);
-            pos++;
-          } else {
-            var result5 = null;
-            if (reportMatchFailures) {
-              matchFailed("[0-9A-Z_a-z]");
-            }
-          }
-          while (result5 !== null) {
-            result4.push(result5);
-            if (input.substr(pos).match(/^[0-9A-Z_a-z]/) !== null) {
-              var result5 = input.charAt(pos);
-              pos++;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9A-Z_a-z]");
-              }
-            }
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(nmstart, nmchars) { return nmstart + nmchars.join(""); })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_octal() {
-        var cacheKey = 'octal@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "0") {
-          var result3 = "0";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"0\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = [];
-          if (input.substr(pos).match(/^[0-7]/) !== null) {
-            var result5 = input.charAt(pos);
-            pos++;
-          } else {
-            var result5 = null;
-            if (reportMatchFailures) {
-              matchFailed("[0-7]");
-            }
-          }
-          while (result5 !== null) {
-            result4.push(result5);
-            if (input.substr(pos).match(/^[0-7]/) !== null) {
-              var result5 = input.charAt(pos);
-              pos++;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-7]");
-              }
-            }
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(value) { return "0" + value.join(""); })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_hex() {
-        var cacheKey = 'hex@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "0") {
-          var result3 = "0";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"0\"");
-          }
-        }
-        if (result3 !== null) {
-          if (input.substr(pos).match(/^[Xx]/) !== null) {
-            var result4 = input.charAt(pos);
-            pos++;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("[Xx]");
-            }
-          }
-          if (result4 !== null) {
-            if (input.substr(pos).match(/^[0-9A-Fa-f]/) !== null) {
-              var result6 = input.charAt(pos);
-              pos++;
-            } else {
-              var result6 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9A-Fa-f]");
-              }
-            }
-            if (result6 !== null) {
-              var result5 = [];
-              while (result6 !== null) {
-                result5.push(result6);
-                if (input.substr(pos).match(/^[0-9A-Fa-f]/) !== null) {
-                  var result6 = input.charAt(pos);
-                  pos++;
-                } else {
-                  var result6 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("[0-9A-Fa-f]");
-                  }
-                }
-              }
-            } else {
-              var result5 = null;
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(x, value) { return "0" + x + value.join(""); })(result1[1], result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_decimal() {
-        var cacheKey = 'decimal@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos).match(/^[0-9]/) !== null) {
-          var result3 = input.charAt(pos);
-          pos++;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("[0-9]");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = [];
-          if (input.substr(pos).match(/^[0-9]/) !== null) {
-            var result5 = input.charAt(pos);
-            pos++;
-          } else {
-            var result5 = null;
-            if (reportMatchFailures) {
-              matchFailed("[0-9]");
-            }
-          }
-          while (result5 !== null) {
-            result4.push(result5);
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result5 = input.charAt(pos);
-              pos++;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(numStart, numRest) { return numStart + numRest.join(""); })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_integer() {
-        var cacheKey = 'integer@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "-") {
-          var result8 = "-";
-          pos += 1;
-        } else {
-          var result8 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"-\"");
-          }
-        }
-        var result3 = result8 !== null ? result8 : '';
-        if (result3 !== null) {
-          var result7 = parse_hex();
-          if (result7 !== null) {
-            var result4 = result7;
-          } else {
-            var result6 = parse_octal();
-            if (result6 !== null) {
-              var result4 = result6;
-            } else {
-              var result5 = parse_decimal();
-              if (result5 !== null) {
-                var result4 = result5;
-              } else {
-                var result4 = null;;
-              };
-            };
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(neg, num) { return neg + num; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_floatEe() {
-        var cacheKey = 'floatEe@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos).match(/^[Ee]/) !== null) {
-          var result3 = input.charAt(pos);
-          pos++;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("[Ee]");
-          }
-        }
-        if (result3 !== null) {
-          if (input.substr(pos).match(/^[+\-]/) !== null) {
-            var result7 = input.charAt(pos);
-            pos++;
-          } else {
-            var result7 = null;
-            if (reportMatchFailures) {
-              matchFailed("[+\\-]");
-            }
-          }
-          var result4 = result7 !== null ? result7 : '';
-          if (result4 !== null) {
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result6 = input.charAt(pos);
-              pos++;
-            } else {
-              var result6 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-            if (result6 !== null) {
-              var result5 = [];
-              while (result6 !== null) {
-                result5.push(result6);
-                if (input.substr(pos).match(/^[0-9]/) !== null) {
-                  var result6 = input.charAt(pos);
-                  pos++;
-                } else {
-                  var result6 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("[0-9]");
-                  }
-                }
-              }
-            } else {
-              var result5 = null;
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(e, sign, exp) { return e + sign + exp.join(""); })(result1[0], result1[1], result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_expFloat() {
-        var cacheKey = 'expFloat@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos).match(/^[0-9]/) !== null) {
-          var result5 = input.charAt(pos);
-          pos++;
-        } else {
-          var result5 = null;
-          if (reportMatchFailures) {
-            matchFailed("[0-9]");
-          }
-        }
-        if (result5 !== null) {
-          var result3 = [];
-          while (result5 !== null) {
-            result3.push(result5);
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result5 = input.charAt(pos);
-              pos++;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-          }
-        } else {
-          var result3 = null;
-        }
-        if (result3 !== null) {
-          var result4 = parse_floatEe();
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(num, fee) { return num.join("") + fee; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_leadFloat() {
-        var cacheKey = 'leadFloat@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos).match(/^[0-9]/) !== null) {
-          var result9 = input.charAt(pos);
-          pos++;
-        } else {
-          var result9 = null;
-          if (reportMatchFailures) {
-            matchFailed("[0-9]");
-          }
-        }
-        if (result9 !== null) {
-          var result3 = [];
-          while (result9 !== null) {
-            result3.push(result9);
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result9 = input.charAt(pos);
-              pos++;
-            } else {
-              var result9 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-          }
-        } else {
-          var result3 = null;
-        }
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === ".") {
-            var result4 = ".";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\".\"");
-            }
-          }
-          if (result4 !== null) {
-            var result5 = [];
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result8 = input.charAt(pos);
-              pos++;
-            } else {
-              var result8 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-            while (result8 !== null) {
-              result5.push(result8);
-              if (input.substr(pos).match(/^[0-9]/) !== null) {
-                var result8 = input.charAt(pos);
-                pos++;
-              } else {
-                var result8 = null;
-                if (reportMatchFailures) {
-                  matchFailed("[0-9]");
-                }
-              }
-            }
-            if (result5 !== null) {
-              var result7 = parse_floatEe();
-              var result6 = result7 !== null ? result7 : '';
-              if (result6 !== null) {
-                var result1 = [result3, result4, result5, result6];
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(num, dec, fee) { return num.join("") + "." + dec.join("") + fee; })(result1[0], result1[2], result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_dotFloat() {
-        var cacheKey = 'dotFloat@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = [];
-        if (input.substr(pos).match(/^[0-9]/) !== null) {
-          var result9 = input.charAt(pos);
-          pos++;
-        } else {
-          var result9 = null;
-          if (reportMatchFailures) {
-            matchFailed("[0-9]");
-          }
-        }
-        while (result9 !== null) {
-          result3.push(result9);
-          if (input.substr(pos).match(/^[0-9]/) !== null) {
-            var result9 = input.charAt(pos);
-            pos++;
-          } else {
-            var result9 = null;
-            if (reportMatchFailures) {
-              matchFailed("[0-9]");
-            }
-          }
-        }
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === ".") {
-            var result4 = ".";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\".\"");
-            }
-          }
-          if (result4 !== null) {
-            if (input.substr(pos).match(/^[0-9]/) !== null) {
-              var result8 = input.charAt(pos);
-              pos++;
-            } else {
-              var result8 = null;
-              if (reportMatchFailures) {
-                matchFailed("[0-9]");
-              }
-            }
-            if (result8 !== null) {
-              var result5 = [];
-              while (result8 !== null) {
-                result5.push(result8);
-                if (input.substr(pos).match(/^[0-9]/) !== null) {
-                  var result8 = input.charAt(pos);
-                  pos++;
-                } else {
-                  var result8 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("[0-9]");
-                  }
-                }
-              }
-            } else {
-              var result5 = null;
-            }
-            if (result5 !== null) {
-              var result7 = parse_floatEe();
-              var result6 = result7 !== null ? result7 : '';
-              if (result6 !== null) {
-                var result1 = [result3, result4, result5, result6];
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(num, dec, fee) { return num.join("") + "." + dec.join("") + fee; })(result1[0], result1[2], result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_float() {
-        var cacheKey = 'float@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "-") {
-          var result8 = "-";
-          pos += 1;
-        } else {
-          var result8 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"-\"");
-          }
-        }
-        var result3 = result8 !== null ? result8 : '';
-        if (result3 !== null) {
-          var result7 = parse_leadFloat();
-          if (result7 !== null) {
-            var result4 = result7;
-          } else {
-            var result6 = parse_dotFloat();
-            if (result6 !== null) {
-              var result4 = result6;
-            } else {
-              var result5 = parse_expFloat();
-              if (result5 !== null) {
-                var result4 = result5;
-              } else {
-                var result4 = null;;
-              };
-            };
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(neg, num) { return neg + num; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_string() {
-        var cacheKey = 'string@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "\"") {
-          var result3 = "\"";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"\\\"\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = [];
-          if (input.substr(pos).match(/^[^""]/) !== null) {
-            var result6 = input.charAt(pos);
-            pos++;
-          } else {
-            var result6 = null;
-            if (reportMatchFailures) {
-              matchFailed("[^\"\"]");
-            }
-          }
-          while (result6 !== null) {
-            result4.push(result6);
-            if (input.substr(pos).match(/^[^""]/) !== null) {
-              var result6 = input.charAt(pos);
-              pos++;
-            } else {
-              var result6 = null;
-              if (reportMatchFailures) {
-                matchFailed("[^\"\"]");
-              }
-            }
-          }
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "\"") {
-              var result5 = "\"";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"\\\"\"");
-              }
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(str) { return str.join(""); })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_other() {
-        var cacheKey = 'other@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        if (input.substr(pos).match(/^[^	\n\r 0-9A-Z_a-z]/) !== null) {
-          var result3 = input.charAt(pos);
-          pos++;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("[^	\\n\\r 0-9A-Z_a-z]");
-          }
-        }
-        if (result3 !== null) {
-          var result1 = [];
-          while (result3 !== null) {
-            result1.push(result3);
-            if (input.substr(pos).match(/^[^	\n\r 0-9A-Z_a-z]/) !== null) {
-              var result3 = input.charAt(pos);
-              pos++;
-            } else {
-              var result3 = null;
-              if (reportMatchFailures) {
-                matchFailed("[^	\\n\\r 0-9A-Z_a-z]");
-              }
-            }
-          }
-        } else {
-          var result1 = null;
-        }
-        var result2 = result1 !== null
-          ? (function(other) { return other.join(""); })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_type() {
-        var cacheKey = 'type@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_TypeDesc();
-        if (result3 !== null) {
-          var result4 = parse_Nullable();
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(type, nullable) {
-                      if (!type.sequence) type.sequence = false;
-                      type.nullable = nullable;
-                      return type; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_TypeDesc() {
-        var cacheKey = 'TypeDesc@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result5 = parse_Sequence();
-        if (result5 !== null) {
-          var result1 = result5;
-        } else {
-          var result4 = parse_ArrayType();
-          if (result4 !== null) {
-            var result1 = result4;
-          } else {
-            var result3 = parse_SimpleType();
-            if (result3 !== null) {
-              var result1 = result3;
-            } else {
-              var result1 = null;;
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(type) { return type; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Sequence() {
-        var cacheKey = 'Sequence@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 9) === "sequence<") {
-          var result3 = "sequence<";
-          pos += 9;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"sequence<\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_type();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === ">") {
-              var result5 = ">";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\">\"");
-              }
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(type) { return { sequence: true, array: false, idlType: type }; })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ArrayType() {
-        var cacheKey = 'ArrayType@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_SimpleType();
-        if (result3 !== null) {
-          if (input.substr(pos, 2) === "[]") {
-            var result4 = "[]";
-            pos += 2;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"[]\"");
-            }
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(type) {
-                      type.array = true;
-                      return type;
-                  })(result1[0])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_SimpleType() {
-        var cacheKey = 'SimpleType@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result5 = parse_PrimitiveType();
-        if (result5 !== null) {
-          var result1 = result5;
-        } else {
-          var result4 = parse_UnsignedIntegerType();
-          if (result4 !== null) {
-            var result1 = result4;
-          } else {
-            var result3 = parse_ScopedName();
-            if (result3 !== null) {
-              var result1 = result3;
-            } else {
-              var result1 = null;;
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(type) { return { sequence: false, array: false, idlType: type }; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_PrimitiveType() {
-        var cacheKey = 'PrimitiveType@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 3) === "any") {
-          var result12 = "any";
-          pos += 3;
-        } else {
-          var result12 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"any\"");
-          }
-        }
-        if (result12 !== null) {
-          var result3 = result12;
-        } else {
-          if (input.substr(pos, 6) === "object") {
-            var result11 = "object";
-            pos += 6;
-          } else {
-            var result11 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"object\"");
-            }
-          }
-          if (result11 !== null) {
-            var result3 = result11;
-          } else {
-            if (input.substr(pos, 7) === "boolean") {
-              var result10 = "boolean";
-              pos += 7;
-            } else {
-              var result10 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"boolean\"");
-              }
-            }
-            if (result10 !== null) {
-              var result3 = result10;
-            } else {
-              if (input.substr(pos, 5) === "octet") {
-                var result9 = "octet";
-                pos += 5;
-              } else {
-                var result9 = null;
-                if (reportMatchFailures) {
-                  matchFailed("\"octet\"");
-                }
-              }
-              if (result9 !== null) {
-                var result3 = result9;
-              } else {
-                if (input.substr(pos, 5) === "float") {
-                  var result8 = "float";
-                  pos += 5;
-                } else {
-                  var result8 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"float\"");
-                  }
-                }
-                if (result8 !== null) {
-                  var result3 = result8;
-                } else {
-                  if (input.substr(pos, 6) === "double") {
-                    var result7 = "double";
-                    pos += 6;
-                  } else {
-                    var result7 = null;
-                    if (reportMatchFailures) {
-                      matchFailed("\"double\"");
-                    }
-                  }
-                  if (result7 !== null) {
-                    var result3 = result7;
-                  } else {
-                    if (input.substr(pos, 9) === "DOMString") {
-                      var result6 = "DOMString";
-                      pos += 9;
-                    } else {
-                      var result6 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"DOMString\"");
-                      }
-                    }
-                    if (result6 !== null) {
-                      var result3 = result6;
-                    } else {
-                      var result3 = null;;
-                    };
-                  };
-                };
-              };
-            };
-          };
-        }
-        if (result3 !== null) {
-          var savedPos2 = pos;
-          var savedReportMatchFailuresVar0 = reportMatchFailures;
-          reportMatchFailures = false;
-          if (input.substr(pos).match(/^[A-Za-z0-9]/) !== null) {
-            var result5 = input.charAt(pos);
-            pos++;
-          } else {
-            var result5 = null;
-            if (reportMatchFailures) {
-              matchFailed("[A-Za-z0-9]");
-            }
-          }
-          reportMatchFailures = savedReportMatchFailuresVar0;
-          if (result5 === null) {
-            var result4 = '';
-          } else {
-            var result4 = null;
-            pos = savedPos2;
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(type) { return type; })(result1[0])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_UnsignedIntegerType() {
-        var cacheKey = 'UnsignedIntegerType@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 8) === "unsigned") {
-          var result13 = "unsigned";
-          pos += 8;
-        } else {
-          var result13 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"unsigned\"");
-          }
-        }
-        var result3 = result13 !== null ? result13 : '';
-        if (result3 !== null) {
-          var result4 = parse_s();
-          if (result4 !== null) {
-            var savedPos2 = pos;
-            if (input.substr(pos, 4) === "long") {
-              var result10 = "long";
-              pos += 4;
-            } else {
-              var result10 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"long\"");
-              }
-            }
-            if (result10 !== null) {
-              var result11 = parse_s();
-              if (result11 !== null) {
-                if (input.substr(pos, 4) === "long") {
-                  var result12 = "long";
-                  pos += 4;
-                } else {
-                  var result12 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"long\"");
-                  }
-                }
-                if (result12 !== null) {
-                  var result9 = [result10, result11, result12];
-                } else {
-                  var result9 = null;
-                  pos = savedPos2;
-                }
-              } else {
-                var result9 = null;
-                pos = savedPos2;
-              }
-            } else {
-              var result9 = null;
-              pos = savedPos2;
-            }
-            if (result9 !== null) {
-              var result5 = result9;
-            } else {
-              if (input.substr(pos, 4) === "long") {
-                var result8 = "long";
-                pos += 4;
-              } else {
-                var result8 = null;
-                if (reportMatchFailures) {
-                  matchFailed("\"long\"");
-                }
-              }
-              if (result8 !== null) {
-                var result5 = result8;
-              } else {
-                if (input.substr(pos, 5) === "short") {
-                  var result7 = "short";
-                  pos += 5;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"short\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result5 = result7;
-                } else {
-                  if (input.substr(pos, 4) === "byte") {
-                    var result6 = "byte";
-                    pos += 4;
-                  } else {
-                    var result6 = null;
-                    if (reportMatchFailures) {
-                      matchFailed("\"byte\"");
-                    }
-                  }
-                  if (result6 !== null) {
-                    var result5 = result6;
-                  } else {
-                    var result5 = null;;
-                  };
-                };
-              };
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(uns, kind) { return (uns ? "unsigned " : "") + (kind.join ? kind.join("") : kind); })(result1[0], result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ScopedNameList() {
-        var cacheKey = 'ScopedNameList@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_ScopedName();
-        if (result3 !== null) {
-          var result4 = [];
-          var result5 = parse_ScopedNameListRest();
-          while (result5 !== null) {
-            result4.push(result5);
-            var result5 = parse_ScopedNameListRest();
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(first, others) {   var ret = [first];
-                      for (var i = 0, n = others.length; i < n; i++) { ret.push(others[i]); }
-                      return ret; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ScopedNameListRest() {
-        var cacheKey = 'ScopedNameListRest@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === ",") {
-            var result4 = ",";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\",\"");
-            }
-          }
-          if (result4 !== null) {
-            var result5 = parse_w();
-            if (result5 !== null) {
-              var result6 = parse_ScopedName();
-              if (result6 !== null) {
-                var result1 = [result3, result4, result5, result6];
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(rest) { return rest; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ScopedName() {
-        var cacheKey = 'ScopedName@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result4 = parse_AbsoluteScopedName();
-        if (result4 !== null) {
-          var result1 = result4;
-        } else {
-          var result3 = parse_RelativeScopedName();
-          if (result3 !== null) {
-            var result1 = result3;
-          } else {
-            var result1 = null;;
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(name) { return name; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_AbsoluteScopedName() {
-        var cacheKey = 'AbsoluteScopedName@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 2) === "::") {
-          var result3 = "::";
-          pos += 2;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"::\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_RelativeScopedName();
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(rel) { return "::" + rel; })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_RelativeScopedName() {
-        var cacheKey = 'RelativeScopedName@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_identifier();
-        if (result3 !== null) {
-          var result4 = [];
-          var result5 = parse_ScopedNameRest();
-          while (result5 !== null) {
-            result4.push(result5);
-            var result5 = parse_ScopedNameRest();
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name, rest) { return name + rest.join(""); })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ScopedNameRest() {
-        var cacheKey = 'ScopedNameRest@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 2) === "::") {
-          var result3 = "::";
-          pos += 2;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"::\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_identifier();
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name) { return name.join(""); })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_BooleanLiteral() {
-        var cacheKey = 'BooleanLiteral@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        if (input.substr(pos, 4) === "true") {
-          var result4 = "true";
-          pos += 4;
-        } else {
-          var result4 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"true\"");
-          }
-        }
-        if (result4 !== null) {
-          var result1 = result4;
-        } else {
-          if (input.substr(pos, 5) === "false") {
-            var result3 = "false";
-            pos += 5;
-          } else {
-            var result3 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"false\"");
-            }
-          }
-          if (result3 !== null) {
-            var result1 = result3;
-          } else {
-            var result1 = null;;
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(value) { return value; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Nullable() {
-        var cacheKey = 'Nullable@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        if (input.substr(pos, 1) === "?") {
-          var result3 = "?";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"?\"");
-          }
-        }
-        var result1 = result3 !== null ? result3 : '';
-        var result2 = result1 !== null
-          ? (function(nullable) { return nullable ? true : false; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ReturnType() {
-        var cacheKey = 'ReturnType@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        if (input.substr(pos, 4) === "void") {
-          var result4 = "void";
-          pos += 4;
-        } else {
-          var result4 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"void\"");
-          }
-        }
-        if (result4 !== null) {
-          var result1 = result4;
-        } else {
-          var result3 = parse_type();
-          if (result3 !== null) {
-            var result1 = result3;
-          } else {
-            var result1 = null;;
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(ret) { return ret; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_definitions() {
-        var cacheKey = 'definitions@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          var result4 = [];
-          var result5 = parse_definition();
-          while (result5 !== null) {
-            result4.push(result5);
-            var result5 = parse_definition();
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(defs) { return defs; })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_definition() {
-        var cacheKey = 'definition@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result9 = parse_partialinterface();
-        if (result9 !== null) {
-          var result1 = result9;
-        } else {
-          var result8 = parse_module();
-          if (result8 !== null) {
-            var result1 = result8;
-          } else {
-            var result7 = parse_interface();
-            if (result7 !== null) {
-              var result1 = result7;
-            } else {
-              var result6 = parse_dictionary();
-              if (result6 !== null) {
-                var result1 = result6;
-              } else {
-                var result5 = parse_typedef();
-                if (result5 !== null) {
-                  var result1 = result5;
-                } else {
-                  var result4 = parse_exception();
-                  if (result4 !== null) {
-                    var result1 = result4;
-                  } else {
-                    var result3 = parse_implements();
-                    if (result3 !== null) {
-                      var result1 = result3;
-                    } else {
-                      var result1 = null;;
-                    };
-                  };
-                };
-              };
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(def) { return def; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_partialinterface() {
-        var cacheKey = 'partialinterface@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result21 = parse_extendedAttributeList();
-        var result3 = result21 !== null ? result21 : '';
-        if (result3 !== null) {
-          var result20 = parse_s();
-          var result4 = result20 !== null ? result20 : '';
-          if (result4 !== null) {
-            if (input.substr(pos, 7) === "partial") {
-              var result5 = "partial";
-              pos += 7;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"partial\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                if (input.substr(pos, 9) === "interface") {
-                  var result7 = "interface";
-                  pos += 9;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"interface\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result8 = parse_s();
-                  if (result8 !== null) {
-                    var result9 = parse_identifier();
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === "{") {
-                          var result11 = "{";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\"{\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result13 = [];
-                            var result19 = parse_ifMember();
-                            while (result19 !== null) {
-                              result13.push(result19);
-                              var result19 = parse_ifMember();
-                            }
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === "}") {
-                                  var result15 = "}";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\"}\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    if (input.substr(pos, 1) === ";") {
-                                      var result17 = ";";
-                                      pos += 1;
-                                    } else {
-                                      var result17 = null;
-                                      if (reportMatchFailures) {
-                                        matchFailed("\";\"");
-                                      }
-                                    }
-                                    if (result17 !== null) {
-                                      var result18 = parse_w();
-                                      if (result18 !== null) {
-                                        var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16, result17, result18];
-                                      } else {
-                                        var result1 = null;
-                                        pos = savedPos1;
-                                      }
-                                    } else {
-                                      var result1 = null;
-                                      pos = savedPos1;
-                                    }
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, name, mem) { return { type: "partialinterface", name: name, members: mem, extAttrs: extAttrs }; })(result1[0], result1[6], result1[10])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_module() {
-        var cacheKey = 'module@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result18 = parse_extendedAttributeList();
-        var result3 = result18 !== null ? result18 : '';
-        if (result3 !== null) {
-          var result17 = parse_s();
-          var result4 = result17 !== null ? result17 : '';
-          if (result4 !== null) {
-            if (input.substr(pos, 6) === "module") {
-              var result5 = "module";
-              pos += 6;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"module\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === "{") {
-                      var result9 = "{";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"{\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result11 = parse_definitions();
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            if (input.substr(pos, 1) === "}") {
-                              var result13 = "}";
-                              pos += 1;
-                            } else {
-                              var result13 = null;
-                              if (reportMatchFailures) {
-                                matchFailed("\"}\"");
-                              }
-                            }
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === ";") {
-                                  var result15 = ";";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\";\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, name, defs) { return { type: "module", name: name, definitions: defs, extAttrs: extAttrs }; })(result1[0], result1[4], result1[8])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_implements() {
-        var cacheKey = 'implements@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result14 = parse_extendedAttributeList();
-        var result3 = result14 !== null ? result14 : '';
-        if (result3 !== null) {
-          var result13 = parse_s();
-          var result4 = result13 !== null ? result13 : '';
-          if (result4 !== null) {
-            var result5 = parse_ScopedName();
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                if (input.substr(pos, 10) === "implements") {
-                  var result7 = "implements";
-                  pos += 10;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"implements\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result8 = parse_s();
-                  if (result8 !== null) {
-                    var result9 = parse_ScopedName();
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === ";") {
-                          var result11 = ";";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\";\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, target, impl) { return { type: 'implements', target: target, 'implements': impl, extAttrs: extAttrs }; })(result1[0], result1[2], result1[6])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_interface() {
-        var cacheKey = 'interface@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result22 = parse_extendedAttributeList();
-        var result3 = result22 !== null ? result22 : '';
-        if (result3 !== null) {
-          var result21 = parse_s();
-          var result4 = result21 !== null ? result21 : '';
-          if (result4 !== null) {
-            if (input.substr(pos, 9) === "interface") {
-              var result5 = "interface";
-              pos += 9;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"interface\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    var result20 = parse_ifInheritance();
-                    var result9 = result20 !== null ? result20 : '';
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === "{") {
-                          var result11 = "{";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\"{\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result13 = [];
-                            var result19 = parse_ifMember();
-                            while (result19 !== null) {
-                              result13.push(result19);
-                              var result19 = parse_ifMember();
-                            }
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === "}") {
-                                  var result15 = "}";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\"}\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    if (input.substr(pos, 1) === ";") {
-                                      var result17 = ";";
-                                      pos += 1;
-                                    } else {
-                                      var result17 = null;
-                                      if (reportMatchFailures) {
-                                        matchFailed("\";\"");
-                                      }
-                                    }
-                                    if (result17 !== null) {
-                                      var result18 = parse_w();
-                                      if (result18 !== null) {
-                                        var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16, result17, result18];
-                                      } else {
-                                        var result1 = null;
-                                        pos = savedPos1;
-                                      }
-                                    } else {
-                                      var result1 = null;
-                                      pos = savedPos1;
-                                    }
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, name, herit, mem) { return { type: "interface", name: name, inheritance: herit, members: mem, extAttrs: extAttrs }; })(result1[0], result1[4], result1[6], result1[10])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ifInheritance() {
-        var cacheKey = 'ifInheritance@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === ":") {
-          var result3 = ":";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\":\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var result5 = parse_ScopedNameList();
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(herit) { return herit; })(result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ifMember() {
-        var cacheKey = 'ifMember@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result4 = parse_const();
-        if (result4 !== null) {
-          var result1 = result4;
-        } else {
-          var result3 = parse_attrOrOp();
-          if (result3 !== null) {
-            var result1 = result3;
-          } else {
-            var result1 = null;;
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(mem) { return mem; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_const() {
-        var cacheKey = 'const@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result18 = parse_extendedAttributeList();
-        var result3 = result18 !== null ? result18 : '';
-        if (result3 !== null) {
-          var result17 = parse_s();
-          var result4 = result17 !== null ? result17 : '';
-          if (result4 !== null) {
-            if (input.substr(pos, 5) === "const") {
-              var result5 = "const";
-              pos += 5;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"const\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_type();
-                if (result7 !== null) {
-                  var result8 = parse_s();
-                  if (result8 !== null) {
-                    var result9 = parse_identifier();
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === "=") {
-                          var result11 = "=";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\"=\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result13 = parse_constExpr();
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === ";") {
-                                  var result15 = ";";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\";\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, type, name, value) { return { type: "const", extAttrs: extAttrs, idlType: type, name: name, value: value }; })(result1[0], result1[4], result1[6], result1[10])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_constExpr() {
-        var cacheKey = 'constExpr@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result5 = parse_BooleanLiteral();
-        if (result5 !== null) {
-          var result1 = result5;
-        } else {
-          var result4 = parse_float();
-          if (result4 !== null) {
-            var result1 = result4;
-          } else {
-            var result3 = parse_integer();
-            if (result3 !== null) {
-              var result1 = result3;
-            } else {
-              var result1 = null;;
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(value) { return value; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_attrOrOp() {
-        var cacheKey = 'attrOrOp@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result5 = parse_Stringifier();
-        if (result5 !== null) {
-          var result1 = result5;
-        } else {
-          var result4 = parse_Attribute();
-          if (result4 !== null) {
-            var result1 = result4;
-          } else {
-            var result3 = parse_Operation();
-            if (result3 !== null) {
-              var result1 = result3;
-            } else {
-              var result1 = null;;
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(ao) { return ao; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Stringifier() {
-        var cacheKey = 'Stringifier@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 11) === "stringifier") {
-          var result3 = "stringifier";
-          pos += 11;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"stringifier\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var result8 = parse_Attribute();
-            if (result8 !== null) {
-              var result5 = result8;
-            } else {
-              var result7 = parse_OperationRest();
-              if (result7 !== null) {
-                var result5 = result7;
-              } else {
-                if (input.substr(pos, 1) === ";") {
-                  var result6 = ";";
-                  pos += 1;
-                } else {
-                  var result6 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\";\"");
-                  }
-                }
-                if (result6 !== null) {
-                  var result5 = result6;
-                } else {
-                  var result5 = null;;
-                };
-              };
-            }
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(rest) {
-                      if (rest === ";") return { type: "stringifier" };
-                      else {
-                          rest.stringifier = true;
-                          return rest;
-                      }
-                  })(result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Attribute() {
-        var cacheKey = 'Attribute@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result23 = parse_extendedAttributeList();
-        var result3 = result23 !== null ? result23 : '';
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var savedPos2 = pos;
-            if (input.substr(pos, 8) === "readonly") {
-              var result21 = "readonly";
-              pos += 8;
-            } else {
-              var result21 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"readonly\"");
-              }
-            }
-            if (result21 !== null) {
-              var result22 = parse_s();
-              if (result22 !== null) {
-                var result20 = [result21, result22];
-              } else {
-                var result20 = null;
-                pos = savedPos2;
-              }
-            } else {
-              var result20 = null;
-              pos = savedPos2;
-            }
-            var result5 = result20 !== null ? result20 : '';
-            if (result5 !== null) {
-              if (input.substr(pos, 9) === "attribute") {
-                var result6 = "attribute";
-                pos += 9;
-              } else {
-                var result6 = null;
-                if (reportMatchFailures) {
-                  matchFailed("\"attribute\"");
-                }
-              }
-              if (result6 !== null) {
-                var result7 = parse_s();
-                if (result7 !== null) {
-                  var result8 = parse_type();
-                  if (result8 !== null) {
-                    var result9 = parse_s();
-                    if (result9 !== null) {
-                      var result10 = parse_identifier();
-                      if (result10 !== null) {
-                        var result11 = parse_w();
-                        if (result11 !== null) {
-                          var result19 = parse_GetRaises();
-                          var result12 = result19 !== null ? result19 : '';
-                          if (result12 !== null) {
-                            var result13 = parse_w();
-                            if (result13 !== null) {
-                              var result18 = parse_SetRaises();
-                              var result14 = result18 !== null ? result18 : '';
-                              if (result14 !== null) {
-                                var result15 = parse_w();
-                                if (result15 !== null) {
-                                  if (input.substr(pos, 1) === ";") {
-                                    var result16 = ";";
-                                    pos += 1;
-                                  } else {
-                                    var result16 = null;
-                                    if (reportMatchFailures) {
-                                      matchFailed("\";\"");
-                                    }
-                                  }
-                                  if (result16 !== null) {
-                                    var result17 = parse_w();
-                                    if (result17 !== null) {
-                                      var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16, result17];
-                                    } else {
-                                      var result1 = null;
-                                      pos = savedPos1;
-                                    }
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, ro, type, name, gr, sr) { return { type: "attribute", extAttrs: extAttrs, idlType: type, name: name, readonly: (ro ? true : false), getraises: gr, setraises: sr }; })(result1[0], result1[2], result1[5], result1[7], result1[9], result1[11])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_GetRaises() {
-        var cacheKey = 'GetRaises@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 9) === "getraises") {
-          var result3 = "getraises";
-          pos += 9;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"getraises\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "(") {
-              var result5 = "(";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"(\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_ScopedNameList();
-              if (result6 !== null) {
-                if (input.substr(pos, 1) === ")") {
-                  var result7 = ")";
-                  pos += 1;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\")\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result1 = [result3, result4, result5, result6, result7];
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(list) { return list; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_SetRaises() {
-        var cacheKey = 'SetRaises@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 9) === "setraises") {
-          var result3 = "setraises";
-          pos += 9;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"setraises\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "(") {
-              var result5 = "(";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"(\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_ScopedNameList();
-              if (result6 !== null) {
-                if (input.substr(pos, 1) === ")") {
-                  var result7 = ")";
-                  pos += 1;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\")\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result1 = [result3, result4, result5, result6, result7];
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(list) { return list; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Operation() {
-        var cacheKey = 'Operation@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result8 = parse_extendedAttributeList();
-        var result3 = result8 !== null ? result8 : '';
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var result5 = parse_Qualifiers();
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result7 = parse_OperationRest();
-                if (result7 !== null) {
-                  var result1 = [result3, result4, result5, result6, result7];
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, quals, rest) {
-                      for (var k in quals) rest[k] = quals[k];
-                      if (extAttrs) rest.extAttrs = extAttrs;
-                      return rest;
-                  })(result1[0], result1[2], result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Qualifiers() {
-        var cacheKey = 'Qualifiers@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 6) === "static") {
-            var result7 = "static";
-            pos += 6;
-          } else {
-            var result7 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"static\"");
-            }
-          }
-          if (result7 !== null) {
-            var result4 = result7;
-          } else {
-            var result5 = [];
-            var result6 = parse_Special();
-            while (result6 !== null) {
-              result5.push(result6);
-              var result6 = parse_Special();
-            }
-            if (result5 !== null) {
-              var result4 = result5;
-            } else {
-              var result4 = null;;
-            };
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(quals) {   if (typeof quals == "string") return [quals];
-          		    return quals; })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Special() {
-        var cacheKey = 'Special@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 6) === "getter") {
-            var result10 = "getter";
-            pos += 6;
-          } else {
-            var result10 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"getter\"");
-            }
-          }
-          if (result10 !== null) {
-            var result4 = result10;
-          } else {
-            if (input.substr(pos, 6) === "setter") {
-              var result9 = "setter";
-              pos += 6;
-            } else {
-              var result9 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"setter\"");
-              }
-            }
-            if (result9 !== null) {
-              var result4 = result9;
-            } else {
-              if (input.substr(pos, 7) === "creator") {
-                var result8 = "creator";
-                pos += 7;
-              } else {
-                var result8 = null;
-                if (reportMatchFailures) {
-                  matchFailed("\"creator\"");
-                }
-              }
-              if (result8 !== null) {
-                var result4 = result8;
-              } else {
-                if (input.substr(pos, 7) === "deleter") {
-                  var result7 = "deleter";
-                  pos += 7;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"deleter\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result4 = result7;
-                } else {
-                  if (input.substr(pos, 12) === "legacycaller") {
-                    var result6 = "legacycaller";
-                    pos += 12;
-                  } else {
-                    var result6 = null;
-                    if (reportMatchFailures) {
-                      matchFailed("\"legacycaller\"");
-                    }
-                  }
-                  if (result6 !== null) {
-                    var result4 = result6;
-                  } else {
-                    var result4 = null;;
-                  };
-                };
-              };
-            };
-          }
-          if (result4 !== null) {
-            var result5 = parse_w();
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(spe) { return spe; })(result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_OperationRest() {
-        var cacheKey = 'OperationRest@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_ReturnType();
-        if (result3 !== null) {
-          var result4 = parse_s();
-          if (result4 !== null) {
-            var result19 = parse_identifier();
-            var result5 = result19 !== null ? result19 : '';
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                if (input.substr(pos, 1) === "(") {
-                  var result7 = "(";
-                  pos += 1;
-                } else {
-                  var result7 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"(\"");
-                  }
-                }
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    var result18 = parse_Arguments();
-                    var result9 = result18 !== null ? result18 : '';
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === ")") {
-                          var result11 = ")";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\")\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result17 = parse_Raises();
-                            var result13 = result17 !== null ? result17 : '';
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === ";") {
-                                  var result15 = ";";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\";\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(ret, name, args, exc) { return { type: "operation", idlType: ret, name: name, arguments: (args ? args : []), raises: exc }; })(result1[0], result1[2], result1[6], result1[10])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Arguments() {
-        var cacheKey = 'Arguments@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_Argument();
-        if (result3 !== null) {
-          var result4 = [];
-          var result5 = parse_ArgumentsRest();
-          while (result5 !== null) {
-            result4.push(result5);
-            var result5 = parse_ArgumentsRest();
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(first, others) {   var ret = [first];
-                      for (var i = 0, n = others.length; i < n; i++) { ret.push(others[i]); }
-                      return ret; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ArgumentsRest() {
-        var cacheKey = 'ArgumentsRest@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === ",") {
-            var result4 = ",";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\",\"");
-            }
-          }
-          if (result4 !== null) {
-            var result5 = parse_w();
-            if (result5 !== null) {
-              var result6 = parse_Argument();
-              if (result6 !== null) {
-                var result1 = [result3, result4, result5, result6];
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(rest) { return rest; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Argument() {
-        var cacheKey = 'Argument@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result16 = parse_extendedAttributeList();
-        var result3 = result16 !== null ? result16 : '';
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 2) === "in") {
-              var result15 = "in";
-              pos += 2;
-            } else {
-              var result15 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"in\"");
-              }
-            }
-            var result5 = result15 !== null ? result15 : '';
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                if (input.substr(pos, 8) === "optional") {
-                  var result14 = "optional";
-                  pos += 8;
-                } else {
-                  var result14 = null;
-                  if (reportMatchFailures) {
-                    matchFailed("\"optional\"");
-                  }
-                }
-                var result7 = result14 !== null ? result14 : '';
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    var result9 = parse_type();
-                    if (result9 !== null) {
-                      if (input.substr(pos, 3) === "...") {
-                        var result13 = "...";
-                        pos += 3;
-                      } else {
-                        var result13 = null;
-                        if (reportMatchFailures) {
-                          matchFailed("\"...\"");
-                        }
-                      }
-                      var result10 = result13 !== null ? result13 : '';
-                      if (result10 !== null) {
-                        var result11 = parse_s();
-                        if (result11 !== null) {
-                          var result12 = parse_identifier();
-                          if (result12 !== null) {
-                            var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, opt, type, ell, name) { return { name: name, type: type, variadic: (ell ? true : false), optional: (opt ? true : false), extAttrs: extAttrs }; })(result1[0], result1[4], result1[6], result1[7], result1[9])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_Raises() {
-        var cacheKey = 'Raises@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 6) === "raises") {
-          var result3 = "raises";
-          pos += 6;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"raises\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_s();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "(") {
-              var result5 = "(";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"(\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result7 = parse_ScopedNameList();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === ")") {
-                      var result9 = ")";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\")\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result1 = [result3, result4, result5, result6, result7, result8, result9];
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(list) { return list; })(result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_dictionary() {
-        var cacheKey = 'dictionary@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 10) === "dictionary") {
-          var result3 = "dictionary";
-          pos += 10;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"dictionary\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_s();
-          if (result4 !== null) {
-            var result5 = parse_identifier();
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result18 = parse_ifInheritance();
-                var result7 = result18 !== null ? result18 : '';
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === "{") {
-                      var result9 = "{";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"{\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result11 = [];
-                        var result17 = parse_dictionaryMember();
-                        while (result17 !== null) {
-                          result11.push(result17);
-                          var result17 = parse_dictionaryMember();
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            if (input.substr(pos, 1) === "}") {
-                              var result13 = "}";
-                              pos += 1;
-                            } else {
-                              var result13 = null;
-                              if (reportMatchFailures) {
-                                matchFailed("\"}\"");
-                              }
-                            }
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === ";") {
-                                  var result15 = ";";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\";\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name, superclass, members) {
-                          return { 
-                              type: "dictionary",
-                              name: name,
-                              inheritance: superclass,
-                              members: members
-                          };
-                      })(result1[2], result1[4], result1[8])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_dictionaryMember() {
-        var cacheKey = 'dictionaryMember@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result14 = parse_extendedAttributeList();
-        var result3 = result14 !== null ? result14 : '';
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var result5 = parse_type();
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    var result13 = parse_defaultValue();
-                    var result9 = result13 !== null ? result13 : '';
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        if (input.substr(pos, 1) === ";") {
-                          var result11 = ";";
-                          pos += 1;
-                        } else {
-                          var result11 = null;
-                          if (reportMatchFailures) {
-                            matchFailed("\";\"");
-                          }
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, type, name, defaultValue) {
-                       return {
-                           type: type,
-                           name: name,
-                           defaultValue: defaultValue
-                       };
-                   })(result1[0], result1[2], result1[4], result1[6])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_defaultValue() {
-        var cacheKey = 'defaultValue@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 1) === "=") {
-          var result3 = "=";
-          pos += 1;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"=\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            var result5 = parse_constExpr();
-            if (result5 !== null) {
-              var result1 = [result3, result4, result5];
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(value) { return value; })(result1[2])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_typedef() {
-        var cacheKey = 'typedef@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        if (input.substr(pos, 7) === "typedef") {
-          var result3 = "typedef";
-          pos += 7;
-        } else {
-          var result3 = null;
-          if (reportMatchFailures) {
-            matchFailed("\"typedef\"");
-          }
-        }
-        if (result3 !== null) {
-          var result4 = parse_s();
-          if (result4 !== null) {
-            var result5 = parse_type();
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === ";") {
-                      var result9 = ";";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\";\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result1 = [result3, result4, result5, result6, result7, result8, result9, result10];
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(type, name) { return { type: 'typedef', name: name, idlType: type }; })(result1[2], result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_exception() {
-        var cacheKey = 'exception@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result18 = parse_extendedAttributeList();
-        var result3 = result18 !== null ? result18 : '';
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 9) === "exception") {
-              var result5 = "exception";
-              pos += 9;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"exception\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === "{") {
-                      var result9 = "{";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"{\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result11 = [];
-                        var result17 = parse_exMember();
-                        while (result17 !== null) {
-                          result11.push(result17);
-                          var result17 = parse_exMember();
-                        }
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            if (input.substr(pos, 1) === "}") {
-                              var result13 = "}";
-                              pos += 1;
-                            } else {
-                              var result13 = null;
-                              if (reportMatchFailures) {
-                                matchFailed("\"}\"");
-                              }
-                            }
-                            if (result13 !== null) {
-                              var result14 = parse_w();
-                              if (result14 !== null) {
-                                if (input.substr(pos, 1) === ";") {
-                                  var result15 = ";";
-                                  pos += 1;
-                                } else {
-                                  var result15 = null;
-                                  if (reportMatchFailures) {
-                                    matchFailed("\";\"");
-                                  }
-                                }
-                                if (result15 !== null) {
-                                  var result16 = parse_w();
-                                  if (result16 !== null) {
-                                    var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15, result16];
-                                  } else {
-                                    var result1 = null;
-                                    pos = savedPos1;
-                                  }
-                                } else {
-                                  var result1 = null;
-                                  pos = savedPos1;
-                                }
-                              } else {
-                                var result1 = null;
-                                pos = savedPos1;
-                              }
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, name, mem) { return { type: 'exception', name: name, members: mem, extAttrs: extAttrs }; })(result1[0], result1[4], result1[8])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_exMember() {
-        var cacheKey = 'exMember@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result4 = parse_const();
-        if (result4 !== null) {
-          var result1 = result4;
-        } else {
-          var result3 = parse_field();
-          if (result3 !== null) {
-            var result1 = result3;
-          } else {
-            var result1 = null;;
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(mem) { return mem; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_field() {
-        var cacheKey = 'field@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result12 = parse_extendedAttributeList();
-        var result3 = result12 !== null ? result12 : '';
-        if (result3 !== null) {
-          var result11 = parse_s();
-          var result4 = result11 !== null ? result11 : '';
-          if (result4 !== null) {
-            var result5 = parse_type();
-            if (result5 !== null) {
-              var result6 = parse_s();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === ";") {
-                      var result9 = ";";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\";\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result1 = [result3, result4, result5, result6, result7, result8, result9, result10];
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(extAttrs, type, name) { return { type: "field", extAttrs: extAttrs, idlType: type, name: name }; })(result1[0], result1[2], result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_extendedAttributeList() {
-        var cacheKey = 'extendedAttributeList@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === "[") {
-            var result4 = "[";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\"[\"");
-            }
-          }
-          if (result4 !== null) {
-            var result5 = parse_w();
-            if (result5 !== null) {
-              var result6 = parse_ExtAttrs();
-              if (result6 !== null) {
-                var result7 = parse_w();
-                if (result7 !== null) {
-                  if (input.substr(pos, 1) === "]") {
-                    var result8 = "]";
-                    pos += 1;
-                  } else {
-                    var result8 = null;
-                    if (reportMatchFailures) {
-                      matchFailed("\"]\"");
-                    }
-                  }
-                  if (result8 !== null) {
-                    var result9 = parse_w();
-                    if (result9 !== null) {
-                      var result1 = [result3, result4, result5, result6, result7, result8, result9];
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(ea) { return ea; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrs() {
-        var cacheKey = 'ExtAttrs@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_ExtAttr();
-        if (result3 !== null) {
-          var result4 = [];
-          var result5 = parse_ExtAttrsRest();
-          while (result5 !== null) {
-            result4.push(result5);
-            var result5 = parse_ExtAttrsRest();
-          }
-          if (result4 !== null) {
-            var result1 = [result3, result4];
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(first, others) {   var ret = [first];
-                      for (var i = 0, n = others.length; i < n; i++) { ret.push(others[i]); }
-                      return ret; })(result1[0], result1[1])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrsRest() {
-        var cacheKey = 'ExtAttrsRest@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_w();
-        if (result3 !== null) {
-          if (input.substr(pos, 1) === ",") {
-            var result4 = ",";
-            pos += 1;
-          } else {
-            var result4 = null;
-            if (reportMatchFailures) {
-              matchFailed("\",\"");
-            }
-          }
-          if (result4 !== null) {
-            var result5 = parse_w();
-            if (result5 !== null) {
-              var result6 = parse_ExtAttr();
-              if (result6 !== null) {
-                var result1 = [result3, result4, result5, result6];
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(rest) { return rest; })(result1[3])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttr() {
-        var cacheKey = 'ExtAttr@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result6 = parse_ExtAttrArgList();
-        if (result6 !== null) {
-          var result1 = result6;
-        } else {
-          var result5 = parse_ExtAttrNamedArgList();
-          if (result5 !== null) {
-            var result1 = result5;
-          } else {
-            var result4 = parse_ExtAttrNameValue();
-            if (result4 !== null) {
-              var result1 = result4;
-            } else {
-              var result3 = parse_ExtAttrNoArg();
-              if (result3 !== null) {
-                var result1 = result3;
-              } else {
-                var result1 = null;;
-              };
-            };
-          };
-        }
-        var result2 = result1 !== null
-          ? (function(ea) { return ea; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrNoArg() {
-        var cacheKey = 'ExtAttrNoArg@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var result1 = parse_identifier();
-        var result2 = result1 !== null
-          ? (function(name) {return { name: name }; })(result1)
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrNameValue() {
-        var cacheKey = 'ExtAttrNameValue@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_identifier();
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "=") {
-              var result5 = "=";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"=\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result7 = parse_ScopedName();
-                if (result7 !== null) {
-                  var result1 = [result3, result4, result5, result6, result7];
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name, value) {return { name: name, value: value }; })(result1[0], result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrNamedArgList() {
-        var cacheKey = 'ExtAttrNamedArgList@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_identifier();
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "=") {
-              var result5 = "=";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"=\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result7 = parse_identifier();
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === "(") {
-                      var result9 = "(";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\"(\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result10 = parse_w();
-                      if (result10 !== null) {
-                        var result14 = parse_Arguments();
-                        var result11 = result14 !== null ? result14 : '';
-                        if (result11 !== null) {
-                          var result12 = parse_w();
-                          if (result12 !== null) {
-                            if (input.substr(pos, 1) === ")") {
-                              var result13 = ")";
-                              pos += 1;
-                            } else {
-                              var result13 = null;
-                              if (reportMatchFailures) {
-                                matchFailed("\")\"");
-                              }
-                            }
-                            if (result13 !== null) {
-                              var result1 = [result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13];
-                            } else {
-                              var result1 = null;
-                              pos = savedPos1;
-                            }
-                          } else {
-                            var result1 = null;
-                            pos = savedPos1;
-                          }
-                        } else {
-                          var result1 = null;
-                          pos = savedPos1;
-                        }
-                      } else {
-                        var result1 = null;
-                        pos = savedPos1;
-                      }
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name, value, args) {return { name: name, value: value, arguments: args }; })(result1[0], result1[4], result1[8])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function parse_ExtAttrArgList() {
-        var cacheKey = 'ExtAttrArgList@' + pos;
-        var cachedResult = cache[cacheKey];
-        if (cachedResult) {
-          pos = cachedResult.nextPos;
-          return cachedResult.result;
-        }
-        
-        
-        var savedPos0 = pos;
-        var savedPos1 = pos;
-        var result3 = parse_identifier();
-        if (result3 !== null) {
-          var result4 = parse_w();
-          if (result4 !== null) {
-            if (input.substr(pos, 1) === "(") {
-              var result5 = "(";
-              pos += 1;
-            } else {
-              var result5 = null;
-              if (reportMatchFailures) {
-                matchFailed("\"(\"");
-              }
-            }
-            if (result5 !== null) {
-              var result6 = parse_w();
-              if (result6 !== null) {
-                var result10 = parse_Arguments();
-                var result7 = result10 !== null ? result10 : '';
-                if (result7 !== null) {
-                  var result8 = parse_w();
-                  if (result8 !== null) {
-                    if (input.substr(pos, 1) === ")") {
-                      var result9 = ")";
-                      pos += 1;
-                    } else {
-                      var result9 = null;
-                      if (reportMatchFailures) {
-                        matchFailed("\")\"");
-                      }
-                    }
-                    if (result9 !== null) {
-                      var result1 = [result3, result4, result5, result6, result7, result8, result9];
-                    } else {
-                      var result1 = null;
-                      pos = savedPos1;
-                    }
-                  } else {
-                    var result1 = null;
-                    pos = savedPos1;
-                  }
-                } else {
-                  var result1 = null;
-                  pos = savedPos1;
-                }
-              } else {
-                var result1 = null;
-                pos = savedPos1;
-              }
-            } else {
-              var result1 = null;
-              pos = savedPos1;
-            }
-          } else {
-            var result1 = null;
-            pos = savedPos1;
-          }
-        } else {
-          var result1 = null;
-          pos = savedPos1;
-        }
-        var result2 = result1 !== null
-          ? (function(name, args) {return { name: name, arguments: args }; })(result1[0], result1[4])
-          : null;
-        if (result2 !== null) {
-          var result0 = result2;
-        } else {
-          var result0 = null;
-          pos = savedPos0;
-        }
-        
-        
-        
-        cache[cacheKey] = {
-          nextPos: pos,
-          result:  result0
-        };
-        return result0;
-      }
-      
-      function buildErrorMessage() {
-        function buildExpected(failuresExpected) {
-          failuresExpected.sort();
-          
-          var lastFailure = null;
-          var failuresExpectedUnique = [];
-          for (var i = 0; i < failuresExpected.length; i++) {
-            if (failuresExpected[i] !== lastFailure) {
-              failuresExpectedUnique.push(failuresExpected[i]);
-              lastFailure = failuresExpected[i];
-            }
-          }
-          
-          switch (failuresExpectedUnique.length) {
-            case 0:
-              return 'end of input';
-            case 1:
-              return failuresExpectedUnique[0];
-            default:
-              return failuresExpectedUnique.slice(0, failuresExpectedUnique.length - 1).join(', ')
-                + ' or '
-                + failuresExpectedUnique[failuresExpectedUnique.length - 1];
-          }
-        }
-        
-        var expected = buildExpected(rightmostMatchFailuresExpected);
-        var actualPos = Math.max(pos, rightmostMatchFailuresPos);
-        var actual = actualPos < input.length
-          ? quote(input.charAt(actualPos))
-          : 'end of input';
-        
-        return 'Expected ' + expected + ' but ' + actual + ' found.';
-      }
-      
-      function computeErrorPosition() {
-        /*
-         * The first idea was to use |String.split| to break the input up to the
-         * error position along newlines and derive the line and column from
-         * there. However IE's |split| implementation is so broken that it was
-         * enough to prevent it.
-         */
-        
-        var line = 1;
-        var column = 1;
-        var seenCR = false;
-        
-        for (var i = 0; i <  rightmostMatchFailuresPos; i++) {
-          var ch = input.charAt(i);
-          if (ch === '\n') {
-            if (!seenCR) { line++; }
-            column = 1;
-            seenCR = false;
-          } else if (ch === '\r' | ch === '\u2028' || ch === '\u2029') {
-            line++;
-            column = 1;
-            seenCR = true;
-          } else {
-            column++;
-            seenCR = false;
-          }
-        }
-        
-        return { line: line, column: column };
-      }
-      
-      
-      
-      var result = parseFunctions[startRule]();
-      
-      /*
-       * The parser is now in one of the following three states:
-       *
-       * 1. The parser successfully parsed the whole input.
-       *
-       *    - |result !== null|
-       *    - |pos === input.length|
-       *    - |rightmostMatchFailuresExpected| may or may not contain something
-       *
-       * 2. The parser successfully parsed only a part of the input.
-       *
-       *    - |result !== null|
-       *    - |pos < input.length|
-       *    - |rightmostMatchFailuresExpected| may or may not contain something
-       *
-       * 3. The parser did not successfully parse any part of the input.
-       *
-       *   - |result === null|
-       *   - |pos === 0|
-       *   - |rightmostMatchFailuresExpected| contains at least one failure
-       *
-       * All code following this comment (including called functions) must
-       * handle these states.
-       */
-      if (result === null || pos !== input.length) {
-        var errorPosition = computeErrorPosition();
-        throw new this.SyntaxError(
-          buildErrorMessage(),
-          errorPosition.line,
-          errorPosition.column
-        );
-      }
-      
-      return result;
-    },
-    
-    /* Returns the parser source code. */
-    toSource: function() { return this._source; }
-  };
-  
-  /* Thrown when a parser encounters a syntax error. */
-  
-  result.SyntaxError = function(message, line, column) {
-    this.name = 'SyntaxError';
-    this.message = message;
-    this.line = line;
-    this.column = column;
-  };
-  
-  result.SyntaxError.prototype = Error.prototype;
-  
-  return result;
-})();
deleted file mode 100644
--- a/dom/imported-tests/failures.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-html
-webapps
deleted file mode 100644
--- a/dom/imported-tests/html.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-}
deleted file mode 100644
--- a/dom/imported-tests/html.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-DIRS += \
-  html/tests/submission/Mozilla \
-  $(NULL)
deleted file mode 100644
--- a/dom/imported-tests/html.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-https://dvcs.w3.org/hg/html|html
-tests/submission/Mozilla
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/Makefile.in
+++ /dev/null
@@ -1,31 +0,0 @@
-# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
-
-DEPTH = ../../../../../..
-
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = dom/imported-tests/html/tests/submission/Mozilla
-
-DIRS = \
-  $(NULL)
-
-include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
-
-_TESTS = \
-  test_body-onload.html \
-  test_pageload-image.html \
-  test_pageload-video.html \
-  test_script-for-onload.html \
-  test_window-onerror-parse-error.html \
-  test_window-onerror-runtime-error.html \
-  test_window-onerror-runtime-error-throw.html \
-  $(NULL)
-
-_TESTS += \
-  nested-document-write-external.js \
-  $(NULL)
-
-libs:: $(_TESTS)
-	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/nested-document-write-external.js
+++ /dev/null
@@ -1,1 +0,0 @@
-document.write("w"); document.write("o");
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_body-onload.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<title>HTMLBodyElement.onload</title>
-<link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
-<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-<link rel="help" href="http://www.whatwg.org/html/#handler-window-onload">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-var t = async_test("body.onload should set the window.onload handler")
-window.onload = t.step_func(function() {
-  assert_unreached("This handler should be overwritten.")
-})
-var b = document.createElement("body")
-b.onload = t.step_func(function(e) {
-  assert_equals(e.currentTarget, window,
-                "The event should be fired at the window.")
-  t.done()
-})
-</script>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_pageload-image.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Media documents: image</title>
-  <link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
-  <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-  <link rel="help" href="http://www.whatwg.org/html/#read-media">
-  <script src="/resources/testharness.js"></script>
-  <script src="/resources/testharnessreport.js"></script>
-
-<script>
-  var t = async_test("The document for a standalone media file should have one child in the body.");
-
-  function frameLoaded() {
-    var testframe = document.getElementById('testframe');
-    var testframeChildren = testframe.contentDocument.body.childNodes;
-    assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
-    assert_equals(testframeChildren[0].nodeName, "IMG", "Only child of body must be an <img> element");
-    assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
-                  "Only child of body must be an HTML element");
-    t.done();
-  }
-</script>
-</head>
-<body>
-  <div id="log"></div>
-  <iframe id="testframe" onload="t.step(frameLoaded)"
-   src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oMFgQGMyFwHucAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC"></iframe>
-</body>
-</html>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_pageload-video.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Media documents: video</title>
-  <link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
-  <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-  <link rel="help" href="http://www.whatwg.org/html/#read-media">
-  <script src="/resources/testharness.js"></script>
-  <script src="/resources/testharnessreport.js"></script>
-
-<script>
-  var t = async_test("The document for a standalone media file should have one child in the body.");
-
-  function frameLoaded() {
-    var testframe = document.getElementById('testframe');
-    var testframeChildren = testframe.contentDocument.body.childNodes;
-    assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
-    assert_equals(testframeChildren[0].nodeName, "VIDEO", "Only child of body must be an <video> element");
-    assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
-                  "Only child of body must be an HTML element");
-    t.done();
-  }
-</script>
-</head>
-<body>
-  <div id="log"></div>
-  <iframe id="testframe" onload="t.step(frameLoaded)"
-   src="data:video/webm,"></iframe>
-</body>
-</html>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_script-for-onload.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<title>Script for and onload attributes</title>
-<link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com">
-<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-<link rel="help" href="http://www.whatwg.org/html/#prepare-a-script">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-var t = async_test("Script for and onload attributes");
-</script>
-<script for=" window " event=" onload() ">
-var foo = "bar";
-</script>
-<script for="object" event="handler">
-// This script should fail to run
-foo = "baz";
-t.step(function() { assert_unreached("This script should fail to run."); });
-</script>
-<script>
-t.step(function() { assert_equals(foo, "bar", "Correct script was executed."); });
-t.done();
-</script>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!doctype html>
-<html>
- <head>
-  <title>window.onerror: parse errors</title>
-  <script src="/resources/testharness.js"></script>
-  <script src="/resources/testharnessreport.js"></script>
-  <!--
-
-    In http://dev.w3.org/html5/spec/webappapis.html#creating-scripts ,
-    step 3 describes parsing the script, and step 5 says:
-      # Otherwise, report the error using the onerror event handler of
-      # the script's global object. If the error is still not handled
-      # after this, then the error may be reported to the user.
-    which links to
-    http://dev.w3.org/html5/spec/webappapis.html#report-the-error ,
-    which describes what to do when onerror is a Function.
-
-    -->
- </head>
- <body>
-
-  <div id="log"></div>
-  <script>
-    var error_count = 0;
-    window.onerror = function(msg, url, lineno) {
-      ++error_count;
-      test(function() {assert_equals(url, window.location.href)},
-           "correct url passed to window.onerror");
-      test(function() {assert_equals(lineno, 33)},
-           "correct line number passed to window.onerror");
-    };
-  </script>
-  <script>This script does not parse correctly.</script>
-  <script>
-  test(function() {assert_equals(error_count, 1)},
-       "correct number of calls to window.onerror");
-  </script>
- </body>
-</html>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html
+++ /dev/null
@@ -1,38 +0,0 @@
-<!doctype html>
-<html>
- <head>
-  <title>window.onerror: runtime scripterrors</title>
-  <script src="/resources/testharness.js"></script>
-  <script src="/resources/testharnessreport.js"></script>
-  <!--
-
-    http://www.w3.org/TR/html5/webappapis.html#runtime-script-errors
-    says what to do for uncaught runtime script errors, and just below
-    describes what to do when onerror is a Function.
-
-    -->
- </head>
- <body>
-
-  <div id="log"></div>
-  <script>
-    var error_count = 0;
-    window.onerror = function(msg, url, lineno) {
-      ++error_count;
-    };
-  </script>
-  <script>
-  try {
-    // This error is caught, so it should NOT trigger onerror.
-    throw "foo";
-  } catch (ex) {
-  }
-  // This error is NOT caught, so it should trigger onerror.
-  throw "bar";
-  </script>
-  <script>
-  test(function() {assert_equals(error_count, 1)},
-       "correct number of calls to window.onerror");
-  </script>
- </body>
-</html>
deleted file mode 100644
--- a/dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!doctype html>
-<html>
- <head>
-  <title>window.onerror: runtime scripterrors</title>
-  <script src="/resources/testharness.js"></script>
-  <script src="/resources/testharnessreport.js"></script>
-  <!--
-
-    http://www.w3.org/TR/html5/webappapis.html#runtime-script-errors
-    says what to do for uncaught runtime script errors, and just below
-    describes what to do when onerror is a Function.
-
-    -->
- </head>
- <body>
-
-  <div id="log"></div>
-  <script>
-    var error_count = 0;
-    window.onerror = function(msg, url, lineno) {
-      ++error_count;
-      test(function() {assert_equals(url, window.location.href)},
-           "correct url passed to window.onerror");
-      test(function() {assert_equals(lineno, 35)},
-           "correct line number passed to window.onerror");
-    };
-  </script>
-  <script>
-  try {
-    // This error is caught, so it should NOT trigger onerror.
-    window.nonexistentproperty.oops();
-  } catch (ex) {
-  }
-  // This error is NOT caught, so it should trigger onerror.
-  window.nonexistentproperty.oops();
-  </script>
-  <script>
-  test(function() {assert_equals(error_count, 1)},
-       "correct number of calls to window.onerror");
-  </script>
- </body>
-</html>
deleted file mode 100644
--- a/dom/imported-tests/idlharness.js
+++ /dev/null
@@ -1,1487 +0,0 @@
-/*
-Distributed under both the W3C Test Suite License [1] and the W3C
-3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
-policies and contribution forms [3].
-
-[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
-[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
-[3] http://www.w3.org/2004/10/27-testcases
-*/
-
-/*
- * This file automatically generates browser tests for WebIDL interfaces, using
- * the testharness.js framework.  To use, first include the following:
- *
- *   <script src=/resources/testharness.js></script>
- *   <script src=/resources/testharnessreport.js></script>
- *   <script src=/resources/WebIDLParser.js></script>
- *   <script src=/resources/idlharness.js></script>
- *
- * Then you'll need some type of IDLs.  Here's some script that can be run on a
- * spec written in HTML, which will grab all the elements with class="idl",
- * concatenate them, and replace the body so you can copy-paste:
- *
-     var s = "";
-     [].forEach.call(document.getElementsByClassName("idl"), function(idl) {
-       //https://www.w3.org/Bugs/Public/show_bug.cgi?id=14914
-       if (!idl.classList.contains("extract"))
-       {
-         s += idl.textContent + "\n\n";
-       }
-     });
-     document.body.innerHTML = '<pre></pre>';
-     document.body.firstChild.textContent = s;
- *
- * (TODO: write this in Python or something so that it can be done from the
- * command line instead.)
- *
- * Once you have that, put it in your script somehow.  The easiest way is to
- * embed it literally in an HTML file with <script type=text/plain> or similar,
- * so that you don't have to do any escaping.  Another possibility is to put it
- * in a separate .idl file that's fetched via XHR or similar.  Sample usage:
- *
- *   var idl_array = new IdlArray();
- *   idl_array.add_untested_idls("interface Node { readonly attribute DOMString nodeName; };");
- *   idl_array.add_idls("interface Document : Node { readonly attribute DOMString URL; };");
- *   idl_array.add_objects({Document: ["document"]});
- *   idl_array.test();
- *
- * This tests that window.Document exists and meets all the requirements of
- * WebIDL.  It also tests that window.document (the result of evaluating the
- * string "document") has URL and nodeName properties that behave as they
- * should, and otherwise meets WebIDL's requirements for an object whose
- * primary interface is Document.  It does not test that window.Node exists,
- * which is what you want if the Node interface is already tested in some other
- * specification's suite and your specification only extends or refers to it.
- * Of course, each IDL string can define many different things, and calls to
- * add_objects() can register many different objects for different interfaces:
- * this is a very simple example.
- *
- * TODO: Write assert_writable, assert_enumerable, assert_configurable and
- * their inverses, and use those instead of just checking
- * getOwnPropertyDescriptor.
- *
- * == Public methods of IdlArray ==
- *
- * IdlArray objects can be obtained with new IdlArray().  Anything not
- * documented in this section should be considered an implementation detail,
- * and outside callers should not use it.
- *
- * add_idls(idl_string):
- *   Parses idl_string (throwing on parse error) and adds the results to the
- *   IdlArray.  All the definitions will be tested when you run test().  If
- *   some of the definitions refer to other definitions, those must be present
- *   too.  For instance, if idl_string says that Document inherits from Node,
- *   the Node interface must also have been provided in some call to add_idls()
- *   or add_untested_idls().
- *
- * add_untested_idls(idl_string):
- *   Like add_idls(), but the definitions will not be tested.  If an untested
- *   interface is added and then extended with a tested partial interface, the
- *   members of the partial interface will still be tested.  Also, all the
- *   members will still be tested for objects added with add_objects(), because
- *   you probably want to test that (for instance) window.document has all the
- *   properties from Node, not just Document, even if the Node interface itself
- *   is tested in a different test suite.
- *
- * add_objects(dict):
- *   dict should be an object whose keys are the names of interfaces or
- *   exceptions, and whose values are arrays of strings.  When an interface or
- *   exception is tested, every string registered for it with add_objects()
- *   will be evaluated, and tests will be run on the result to verify that it
- *   correctly implements that interface or exception.  This is the only way to
- *   test anything about [NoInterfaceObject] interfaces, and there are many
- *   tests that can't be run on any interface without an object to fiddle with.
- *
- *   The interface has to be the *primary* interface of all the objects
- *   provided.  For example, don't pass {Node: ["document"]}, but rather
- *   {Document: ["document"]}.  Assuming the Document interface was declared to
- *   inherit from Node, this will automatically test that document implements
- *   the Node interface too.
- *
- *   Warning: methods will be called on any provided objects, in a manner that
- *   WebIDL requires be safe.  For instance, if a method has mandatory
- *   arguments, the test suite will try calling it with too few arguments to
- *   see if it throws an exception.  If an implementation incorrectly runs the
- *   function instead of throwing, this might have side effects, possibly even
- *   preventing the test suite from running correctly.
- *
- * prevent_multiple_testing(name):
- *   This is a niche method for use in case you're testing many objects that
- *   implement the same interfaces, and don't want to retest the same
- *   interfaces every single time.  For instance, HTML defines many interfaces
- *   that all inherit from HTMLElement, so the HTML test suite has something
- *   like
- *     .add_objects({
- *         HTMLHtmlElement: ['document.documentElement'],
- *         HTMLHeadElement: ['document.head'],
- *         HTMLBodyElement: ['document.body'],
- *         ...
- *     })
- *   and so on for dozens of element types.  This would mean that it would
- *   retest that each and every one of those elements implements HTMLElement,
- *   Element, and Node, which would be thousands of basically redundant tests.
- *   The test suite therefore calls prevent_multiple_testing("HTMLElement").
- *   This means that once one object has been tested to implement HTMLElement
- *   and its ancestors, no other object will be.  Thus in the example code
- *   above, the harness would test that document.documentElement correctly
- *   implements HTMLHtmlElement, HTMLElement, Element, and Node; but
- *   document.head would only be tested for HTMLHeadElement, and so on for
- *   further objects.
- *
- * test():
- *   Run all tests.  This should be called after you've called all other
- *   methods to add IDLs and objects.
- */
-"use strict";
-(function(){
-/// IdlArray ///
-//Entry point
-window.IdlArray = function()
-//@{
-{
-    this.members = {};
-    this.objects = {};
-    // When adding multiple collections of IDLs one at a time, an earlier one
-    // might contain a partial interface or implements statement that depends
-    // on a later one.  Save these up and handle them right before we run
-    // tests.
-    this.partials = [];
-    this.implements = {};
-}
-
-//@}
-IdlArray.prototype.add_idls = f