Bug 997285 part 3. Make DOMException [ExceptionClass]. r=peterv,jorendorff
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 05 May 2014 16:01:57 -0400
changeset 181839 bceaeae2f7af4302b63b9092a7a729f24faa924b
parent 181838 3a949414f5bcf52f7b02b065a734b9a52abdd83e
child 181840 1ef41f4b806d9723e609fa04a6f86ac48df70afc
push id43150
push userbzbarsky@mozilla.com
push dateTue, 06 May 2014 20:53:55 +0000
treeherdermozilla-inbound@1ef41f4b806d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, jorendorff
bugs997285
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 997285 part 3. Make DOMException [ExceptionClass]. r=peterv,jorendorff
dom/imptests/failures/html/dom/test_interfaces.html.json
dom/webidl/DOMException.webidl
js/src/jsexn.cpp
--- a/dom/imptests/failures/html/dom/test_interfaces.html.json
+++ b/dom/imptests/failures/html/dom/test_interfaces.html.json
@@ -1,10 +1,9 @@
 {
-  "DOMException exception: existence and properties of exception interface prototype object": true,
   "DOMException exception: existence and properties of exception interface prototype object's \"name\" property": true,
   "CustomEvent interface: existence and properties of interface object": true,
   "EventListener interface: existence and properties of interface prototype object": true,
   "EventListener interface: existence and properties of interface prototype object's \"constructor\" property": true,
   "EventListener interface: operation handleEvent(Event)": true,
   "MutationObserver interface: operation observe(Node,MutationObserverInit)": true,
   "Node interface: existence and properties of interface object": true,
   "Document interface: existence and properties of interface object": true,
--- a/dom/webidl/DOMException.webidl
+++ b/dom/webidl/DOMException.webidl
@@ -57,16 +57,17 @@ interface ExceptionMembers
 [NoInterfaceObject]
 interface Exception {
 };
 
 Exception implements ExceptionMembers;
 
 // XXXkhuey this is an 'exception', not an interface, but we don't have any
 // parser or codegen mechanisms for dealing with exceptions.
+[ExceptionClass]
 interface DOMException {
   const unsigned short INDEX_SIZE_ERR = 1;
   const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
   const unsigned short HIERARCHY_REQUEST_ERR = 3;
   const unsigned short WRONG_DOCUMENT_ERR = 4;
   const unsigned short INVALID_CHARACTER_ERR = 5;
   const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
   const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -701,18 +701,18 @@ static bool
 IsDuckTypedErrorObject(JSContext *cx, HandleObject exnObject, const char **filename_strp)
 {
     bool found;
     if (!JS_HasProperty(cx, exnObject, js_message_str, &found) || !found)
         return false;
 
     const char *filename_str = *filename_strp;
     if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found) {
-        /* DOMException duck quacks "filename" (all lowercase) */
-        filename_str = "filename";
+        /* Now try "fileName", in case this quacks like an Error */
+        filename_str = js_fileName_str;
         if (!JS_HasProperty(cx, exnObject, filename_str, &found) || !found)
             return false;
     }
 
     if (!JS_HasProperty(cx, exnObject, js_lineNumber_str, &found) || !found)
         return false;
 
     *filename_strp = filename_str;
@@ -773,18 +773,23 @@ js_ReportUncaughtException(JSContext *cx
         str = ErrorReportToString(cx, reportp);
     else
         str = ToString<CanGC>(cx, exn);
 
     JSErrorReport report;
 
     // If js_ErrorFromException didn't get us a JSErrorReport, then the object
     // was not an ErrorObject, security-wrapped or otherwise. However, it might
-    // still quack like one. Give duck-typing a chance.
-    const char *filename_str = js_fileName_str;
+    // still quack like one. Give duck-typing a chance.  We start by looking for
+    // "filename" (all lowercase), since that's where DOMExceptions store their
+    // filename.  Then we check "fileName", which is where Errors store it.  We
+    // have to do it in that order, because DOMExceptions have Error.prototype
+    // on their proto chain, and hence also have a "fileName" property, but its
+    // value is "".
+    const char *filename_str = "filename";
     JSAutoByteString filename;
     if (!reportp && exnObject && IsDuckTypedErrorObject(cx, exnObject, &filename_str))
     {
         // Temporary value for pulling properties off of duck-typed objects.
         RootedValue val(cx);
 
         RootedString name(cx);
         if (JS_GetProperty(cx, exnObject, js_name_str, &val) && val.isString())