Bug 1257919 part 2. Make nsIException and nsIStackFrame builtinclass, so we can start using [implicit_jscontext] on them. r=khuey

This commit is contained in:
Boris Zbarsky 2016-03-22 13:50:31 -04:00
parent 272f9d9fba
commit 44088b97d0
5 changed files with 3 additions and 73 deletions

View File

@ -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

View File

@ -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<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

View File

@ -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);
}

View File

@ -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]

View File

@ -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.