Bug 1277278 part 2 - Remove JS_ReportPendingException and js::ReportUncaughtException. r=luke

--HG--
extra : rebase_source : 7c46e31d178b3d0335924eb561c9a2a2dcb58730
This commit is contained in:
Jan de Mooij 2016-06-07 20:30:48 +02:00
Родитель 66faed38af
Коммит a253d97844
7 изменённых файлов: 3 добавлений и 133 удалений

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

@ -95,7 +95,6 @@ UNIFIED_SOURCES += [
'testToIntWidth.cpp',
'testTypedArrays.cpp',
'testUbiNode.cpp',
'testUncaughtError.cpp',
'testUncaughtSymbol.cpp',
'testUTF8.cpp',
'testWasmLEB128.cpp',

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

@ -1,56 +0,0 @@
/* 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 "jsapi-tests/tests.h"
using JS::CreateError;
using JS::Rooted;
using JS::ObjectValue;
using JS::Value;
static size_t uncaughtCount = 0;
BEGIN_TEST(testUncaughtError)
{
JSErrorReporter old = JS_SetErrorReporter(rt, UncaughtErrorReporter);
CHECK(uncaughtCount == 0);
Rooted<JSString*> empty(cx, JS_GetEmptyString(JS_GetRuntime(cx)));
if (!empty)
return false;
Rooted<Value> err(cx);
if (!CreateError(cx, JSEXN_TYPEERR, nullptr, empty, 0, 0, nullptr, empty, &err))
return false;
Rooted<JSObject*> errObj(cx, &err.toObject());
if (!JS_SetProperty(cx, errObj, "fileName", err))
return false;
if (!JS_SetProperty(cx, errObj, "lineNumber", err))
return false;
if (!JS_SetProperty(cx, errObj, "columnNumber", err))
return false;
if (!JS_SetProperty(cx, errObj, "stack", err))
return false;
if (!JS_SetProperty(cx, errObj, "message", err))
return false;
JS_SetPendingException(cx, err);
JS_ReportPendingException(cx);
CHECK(uncaughtCount == 1);
JS_SetErrorReporter(rt, old);
return true;
}
static void
UncaughtErrorReporter(JSContext* cx, const char* message, JSErrorReport* report)
{
uncaughtCount++;
}
END_TEST(testUncaughtError)

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

@ -5928,18 +5928,6 @@ JS_ClearPendingException(JSContext* cx)
cx->clearPendingException();
}
JS_PUBLIC_API(bool)
JS_ReportPendingException(JSContext* cx)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
// This can only fail due to oom.
bool ok = ReportUncaughtException(cx);
MOZ_ASSERT(!cx->isExceptionPending());
return ok;
}
JS::AutoSaveExceptionState::AutoSaveExceptionState(JSContext* cx)
: context(cx),
wasPropagatingForcedReturn(cx->propagatingForcedReturn_),

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

@ -5413,9 +5413,6 @@ JS_SetPendingException(JSContext* cx, JS::HandleValue v);
extern JS_PUBLIC_API(void)
JS_ClearPendingException(JSContext* cx);
extern JS_PUBLIC_API(bool)
JS_ReportPendingException(JSContext* cx);
namespace JS {
/**

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

@ -661,32 +661,6 @@ ErrorReportToString(JSContext* cx, JSErrorReport* reportp)
return ConcatStrings<CanGC>(cx, str, message);
}
bool
js::ReportUncaughtException(JSContext* cx)
{
if (!cx->isExceptionPending())
return true;
RootedValue exn(cx);
if (!cx->getPendingException(&exn)) {
cx->clearPendingException();
return false;
}
cx->clearPendingException();
ErrorReport err(cx);
if (!err.init(cx, exn, js::ErrorReport::WithSideEffects)) {
cx->clearPendingException();
return false;
}
cx->setPendingException(exn);
CallErrorReporter(cx, err.message(), err.report());
cx->clearPendingException();
return true;
}
ErrorReport::ErrorReport(JSContext* cx)
: reportp(nullptr),
message_(nullptr),

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

@ -54,25 +54,6 @@ extern bool
ErrorToException(JSContext* cx, const char* message, JSErrorReport* reportp,
JSErrorCallback callback, void* userRef);
/*
* Called if a JS API call to js_Execute or js_InternalCall fails; calls the
* error reporter with the error report associated with any uncaught exception
* that has been raised. Returns true if there was an exception pending, and
* the error reporter was actually called.
*
* The JSErrorReport * that the error reporter is called with is currently
* associated with a JavaScript object, and is not guaranteed to persist after
* the object is collected. Any persistent uses of the JSErrorReport contents
* should make their own copy.
*
* The flags field of the JSErrorReport will have the JSREPORT_EXCEPTION flag
* set; embeddings that want to silently propagate JavaScript exceptions to
* other contexts may want to use an error reporter that ignores errors with
* this flag.
*/
extern bool
ReportUncaughtException(JSContext* cx);
extern JSErrorReport*
ErrorFromException(JSContext* cx, HandleObject obj);

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

@ -1210,23 +1210,10 @@ js::PrepareScriptEnvironmentAndInvoke(JSContext* cx, HandleObject scope, ScriptE
{
MOZ_ASSERT(!cx->isExceptionPending());
if (cx->runtime()->scriptEnvironmentPreparer) {
cx->runtime()->scriptEnvironmentPreparer->invoke(scope, closure);
return;
}
MOZ_RELEASE_ASSERT(cx->runtime()->scriptEnvironmentPreparer,
"Embedding needs to set a scriptEnvironmentPreparer callback");
JSAutoCompartment ac(cx, scope);
bool ok = closure(cx);
MOZ_ASSERT_IF(ok, !cx->isExceptionPending());
// NB: This does not affect Gecko, which has a prepareScriptEnvironment
// callback.
if (!ok) {
JS_ReportPendingException(cx);
}
MOZ_ASSERT(!cx->isExceptionPending());
cx->runtime()->scriptEnvironmentPreparer->invoke(scope, closure);
}
JS_FRIEND_API(void)