Bug 1257919 part 2. Make nsIException and nsIStackFrame builtinclass, so we can start using [implicit_jscontext] on them. r=khuey
☠☠ backed out by f5962f5a4e3f ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 22 Mar 2016 13:50:31 -0400
changeset 289816 8bb1cce4804df9375940783c502aba7855c7dee2
parent 289815 2603e80db18ff6a5a4080fd3f578a7447ee0d3f0
child 289817 6403c45366e0746c40a594b29eae7e38516bda83
push id30110
push userkwierso@gmail.com
push dateTue, 22 Mar 2016 23:45:51 +0000
treeherdermozilla-central@3381aa98edf7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1257919
milestone48.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 1257919 part 2. Make nsIException and nsIStackFrame builtinclass, so we can start using [implicit_jscontext] on them. r=khuey
js/xpconnect/idl/xpcexception.idl
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/tests/unit/test_bug641378.js
js/xpconnect/tests/unit/xpcshell.ini
xpcom/base/nsIException.idl
--- a/js/xpconnect/idl/xpcexception.idl
+++ b/js/xpconnect/idl/xpcexception.idl
@@ -2,17 +2,17 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIException.idl"
 
-[scriptable, uuid(875e6645-e762-4da6-9ec8-bf19ab0050df)]
+[scriptable, builtinclass, uuid(875e6645-e762-4da6-9ec8-bf19ab0050df)]
 interface nsIXPCException : nsIException
 {
     // inherits methods from nsIException
 
     void initialize(in AUTF8String      aMessage,
                     in nsresult         aResult,
                     in AUTF8String      aName,
                     in nsIStackFrame    aLocation,
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -1106,39 +1106,16 @@ XPCConvert::JSValToXPCException(MutableH
                 JSAutoByteString message;
                 JSString* str;
                 if (nullptr != (str = ToString(cx, s)))
                     message.encodeLatin1(cx, str);
                 return JSErrorToXPCException(message.ptr(), ifaceName,
                                              methodName, report, exceptn);
             }
 
-
-            bool found;
-
-            // heuristic to see if it might be usable as an xpcexception
-            if (!JS_HasProperty(cx, obj, "message", &found))
-                return NS_ERROR_FAILURE;
-
-            if (found && !JS_HasProperty(cx, obj, "result", &found))
-                return NS_ERROR_FAILURE;
-
-            if (found) {
-                // lets try to build a wrapper around the JSObject
-                nsXPCWrappedJS* jswrapper;
-                nsresult rv =
-                    nsXPCWrappedJS::GetNewOrUsed(obj, NS_GET_IID(nsIException), &jswrapper);
-                if (NS_FAILED(rv))
-                    return rv;
-
-                *exceptn = static_cast<nsIException*>(jswrapper->GetXPTCStub());
-                return NS_OK;
-            }
-
-
             // XXX we should do a check against 'js_ErrorClass' here and
             // do the right thing - even though it has no JSErrorReport,
             // The fact that it is a JSError exceptions means we can extract
             // particular info and our 'result' should reflect that.
 
             // otherwise we'll just try to convert it to a string
 
             JSString* str = ToString(cx, s);
deleted file mode 100644
--- a/js/xpconnect/tests/unit/test_bug641378.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-var timer;
-
-// This test XPConnect's ability to deal with a certain type of exception. In
-// particular, bug 641378 meant that if an exception had both 'message' and
-// 'result' properties, then it wouldn't successfully read the 'result' field
-// out of the exception (and sometimes crash).
-//
-// In order to make the test not fail completely on a negative result, we use
-// a timer. The first time through the timer, we throw our special exception.
-// Then, the second time through, we can test to see if XPConnect properly
-// dealt with our exception.
-var exception = {
-  message: "oops, something failed!",
-
-  tries: 0,
-  get result() {
-    ++this.tries;
-    return 3;
-  }
-};
-
-var callback = {
-  tries: 0,
-  notify: function (timer) {
-    if (++this.tries === 1)
-      throw exception;
-
-    try {
-        do_check_true(exception.tries >= 1);
-    } finally {
-        timer.cancel();
-        timer = null;
-        do_test_finished();
-    }
-  }
-};
-
-function run_test() {
-  do_test_pending();
-
-  timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-  timer.initWithCallback(callback, 0, timer.TYPE_REPEATING_SLACK);
-}
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -18,17 +18,16 @@ support-files =
   recursive_importB.jsm
   syntax_error.jsm
 
 [test_allowWaivers.js]
 [test_bogus_files.js]
 [test_bug408412.js]
 [test_bug451678.js]
 [test_bug604362.js]
-[test_bug641378.js]
 [test_bug677864.js]
 [test_bug711404.js]
 [test_bug742444.js]
 [test_bug778409.js]
 [test_bug780370.js]
 [test_bug809652.js]
 [test_bug809674.js]
 [test_bug813901.js]
--- a/xpcom/base/nsIException.idl
+++ b/xpcom/base/nsIException.idl
@@ -5,17 +5,17 @@
 
 /*
  * Interfaces for representing cross-language exceptions and stack traces.
  */
 
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(28bfb2a2-5ea6-4738-918b-049dc4d51f0b)]
+[scriptable, builtinclass, uuid(28bfb2a2-5ea6-4738-918b-049dc4d51f0b)]
 interface nsIStackFrame : nsISupports
 {
     // see nsIProgrammingLanguage for list of language consts
     readonly attribute uint32_t                language;
     readonly attribute AUTF8String             languageName;
     readonly attribute AString                 filename;
     readonly attribute AString                 name;
     // Valid line numbers begin at '1'. '0' indicates unknown.
@@ -33,17 +33,17 @@ interface nsIStackFrame : nsISupports
 
     // Returns the underlying SavedFrame object for native JavaScript stacks,
     // or null if this is not a native JavaScript stack frame.
     readonly attribute jsval                   nativeSavedFrame;
 
     AUTF8String toString();
 };
 
-[scriptable, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
+[scriptable, builtinclass, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
 interface nsIException : nsISupports
 {
     // A custom message set by the thrower.
     [binaryname(MessageMoz)] readonly attribute AUTF8String message;
     // The nsresult associated with this exception.
     readonly attribute nsresult                result;
     // The name of the error code (ie, a string repr of |result|)
     readonly attribute AUTF8String             name;