From 44088b97d092bde6eaaad9bf862691fe774c5967 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 22 Mar 2016 13:50:31 -0400 Subject: [PATCH] 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 | 2 +- js/xpconnect/src/XPCConvert.cpp | 23 ------------ js/xpconnect/tests/unit/test_bug641378.js | 46 ----------------------- js/xpconnect/tests/unit/xpcshell.ini | 1 - xpcom/base/nsIException.idl | 4 +- 5 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 js/xpconnect/tests/unit/test_bug641378.js diff --git a/js/xpconnect/idl/xpcexception.idl b/js/xpconnect/idl/xpcexception.idl index beaeb1bc5766..d9f4c92fdda5 100644 --- a/js/xpconnect/idl/xpcexception.idl +++ b/js/xpconnect/idl/xpcexception.idl @@ -7,7 +7,7 @@ #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 diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 782e2da4dfc5..3b61e512dc98 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -1111,29 +1111,6 @@ XPCConvert::JSValToXPCException(MutableHandleValue s, 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(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 diff --git a/js/xpconnect/tests/unit/test_bug641378.js b/js/xpconnect/tests/unit/test_bug641378.js deleted file mode 100644 index 1c5a2ced181b..000000000000 --- 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); -} diff --git a/js/xpconnect/tests/unit/xpcshell.ini b/js/xpconnect/tests/unit/xpcshell.ini index 80577805f412..871637cbe150 100644 --- a/js/xpconnect/tests/unit/xpcshell.ini +++ b/js/xpconnect/tests/unit/xpcshell.ini @@ -23,7 +23,6 @@ support-files = [test_bug408412.js] [test_bug451678.js] [test_bug604362.js] -[test_bug641378.js] [test_bug677864.js] [test_bug711404.js] [test_bug742444.js] diff --git a/xpcom/base/nsIException.idl b/xpcom/base/nsIException.idl index 99b3cd8af511..c488319f3331 100644 --- a/xpcom/base/nsIException.idl +++ b/xpcom/base/nsIException.idl @@ -10,7 +10,7 @@ #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 @@ -38,7 +38,7 @@ interface nsIStackFrame : nsISupports 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.