Bug 1000947 - Console::Methods must not throw exceptions, r=bz

This commit is contained in:
Andrea Marchesini 2014-04-29 07:49:57 +01:00
Родитель 4cbf0ef630
Коммит a6fb3eb7dd
3 изменённых файлов: 15 добавлений и 33 удалений

Просмотреть файл

@ -476,10 +476,7 @@ private:
arguments.AppendElement(value);
}
console->ProfileMethod(cx, mAction, arguments, error);
if (error.Failed()) {
NS_WARNING("Failed to call call profile() method to the ConsoleAPI.");
}
console->ProfileMethod(cx, mAction, arguments);
}
private:
@ -662,23 +659,20 @@ Console::TimeEnd(JSContext* aCx, const JS::Handle<JS::Value> aTime)
}
void
Console::Profile(JSContext* aCx, const Sequence<JS::Value>& aData,
ErrorResult& aRv)
Console::Profile(JSContext* aCx, const Sequence<JS::Value>& aData)
{
ProfileMethod(aCx, NS_LITERAL_STRING("profile"), aData, aRv);
ProfileMethod(aCx, NS_LITERAL_STRING("profile"), aData);
}
void
Console::ProfileEnd(JSContext* aCx, const Sequence<JS::Value>& aData,
ErrorResult& aRv)
Console::ProfileEnd(JSContext* aCx, const Sequence<JS::Value>& aData)
{
ProfileMethod(aCx, NS_LITERAL_STRING("profileEnd"), aData, aRv);
ProfileMethod(aCx, NS_LITERAL_STRING("profileEnd"), aData);
}
void
Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
const Sequence<JS::Value>& aData,
ErrorResult& aRv)
const Sequence<JS::Value>& aData)
{
if (!NS_IsMainThread()) {
// Here we are in a worker thread.
@ -688,6 +682,8 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
return;
}
ClearException ce(aCx);
RootedDictionary<ConsoleProfileEvent> event(aCx);
event.mAction = aAction;
@ -700,15 +696,14 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
JS::Rooted<JS::Value> eventValue(aCx);
if (!event.ToObject(aCx, &eventValue)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
JS::Rooted<JSObject*> eventObj(aCx, &eventValue.toObject());
MOZ_ASSERT(eventObj);
if (!JS_DefineProperty(aCx, eventObj, "wrappedJSObject", eventValue, JSPROP_ENUMERATE)) {
aRv.Throw(NS_ERROR_FAILURE);
if (!JS_DefineProperty(aCx, eventObj, "wrappedJSObject", eventValue,
JSPROP_ENUMERATE)) {
return;
}
@ -717,7 +712,6 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
const nsIID& iid = NS_GET_IID(nsISupports);
if (NS_FAILED(xpc->WrapJS(aCx, eventObj, iid, getter_AddRefs(wrapper)))) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
@ -836,13 +830,14 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
ConsoleCallData* callData = new ConsoleCallData();
mQueuedCalls.insertBack(callData);
ClearException ce(aCx);
callData->Initialize(aCx, aMethodName, aMethodString, aData);
RAII raii(mQueuedCalls);
if (mWindow) {
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
if (!webNav) {
Throw(aCx, NS_ERROR_FAILURE);
return;
}
@ -857,7 +852,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
nsCOMPtr<nsIStackFrame> stack = CreateStack(aCx, maxDepth);
if (!stack) {
Throw(aCx, NS_ERROR_FAILURE);
return;
}
@ -866,7 +860,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
uint32_t language;
nsresult rv = stack->GetLanguage(&language);
if (NS_FAILED(rv)) {
Throw(aCx, rv);
return;
}
@ -877,7 +870,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
callData->mTopStackFrame.ref(),
language);
if (NS_FAILED(rv)) {
Throw(aCx, rv);
return;
}
@ -887,7 +879,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
nsCOMPtr<nsIStackFrame> caller;
rv = stack->GetCaller(getter_AddRefs(caller));
if (NS_FAILED(rv)) {
Throw(aCx, rv);
return;
}
@ -902,7 +893,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
callData->mReifiedStack.construct();
nsresult rv = ReifyStack(stack, callData->mReifiedStack.ref());
if (NS_WARN_IF(NS_FAILED(rv))) {
Throw(aCx, rv);
return;
}
}
@ -915,7 +905,6 @@ Console::Method(JSContext* aCx, MethodName aMethodName,
ErrorResult rv;
nsRefPtr<nsPerformance> performance = win->GetPerformance(rv);
if (rv.Failed()) {
Throw(aCx, rv.ErrorCode());
return;
}
@ -1111,7 +1100,6 @@ Console::ProcessCallData(ConsoleCallData* aData)
JS::Rooted<JS::Value> eventValue(cx);
if (!event.ToObject(cx, &eventValue)) {
Throw(cx, NS_ERROR_FAILURE);
return;
}

Просмотреть файл

@ -87,12 +87,10 @@ public:
TimeEnd(JSContext* aCx, const JS::Handle<JS::Value> aTime);
void
Profile(JSContext* aCx, const Sequence<JS::Value>& aData,
ErrorResult& aRv);
Profile(JSContext* aCx, const Sequence<JS::Value>& aData);
void
ProfileEnd(JSContext* aCx, const Sequence<JS::Value>& aData,
ErrorResult& aRv);
ProfileEnd(JSContext* aCx, const Sequence<JS::Value>& aData);
void
Assert(JSContext* aCx, bool aCondition, const Sequence<JS::Value>& aData);
@ -181,8 +179,7 @@ private:
void
ProfileMethod(JSContext* aCx, const nsAString& aAction,
const Sequence<JS::Value>& aData,
ErrorResult& aRv);
const Sequence<JS::Value>& aData);
JS::Value
IncreaseCounter(JSContext* aCx, const ConsoleStackEntry& aFrame,

Просмотреть файл

@ -20,10 +20,7 @@ interface Console {
void time(optional any time);
void timeEnd(optional any time);
[Throws]
void profile(any... data);
[Throws]
void profileEnd(any... data);
void assert(boolean condition, any... data);