Skip to content

Commit

Permalink
Backed out 10 changesets (bug 1283710) for osx xpcshell failures a=ba…
Browse files Browse the repository at this point in the history
…ckout

Backed out changeset eb95a12e5d86 (bug 1283710)
Backed out changeset f727edc4be48 (bug 1283710)
Backed out changeset fed60fbf645d (bug 1283710)
Backed out changeset 98339fa564f1 (bug 1283710)
Backed out changeset 51b8d69edca0 (bug 1283710)
Backed out changeset d72527b7d3c0 (bug 1283710)
Backed out changeset ee5215f1a38e (bug 1283710)
Backed out changeset dcedbaefe399 (bug 1283710)
Backed out changeset 61f8250cbe0b (bug 1283710)
Backed out changeset 239382846137 (bug 1283710)
  • Loading branch information
KWierso committed Oct 19, 2016
1 parent 26d4c14 commit 40aa608
Show file tree
Hide file tree
Showing 31 changed files with 378 additions and 388 deletions.
13 changes: 7 additions & 6 deletions dom/base/ScriptSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ AutoJSAPI::~AutoJSAPI()
}

void
WarningOnlyErrorReporter(JSContext* aCx, JSErrorReport* aRep);
WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage,
JSErrorReport* aRep);

void
AutoJSAPI::InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal,
Expand Down Expand Up @@ -519,7 +520,7 @@ AutoJSAPI::Init(nsGlobalWindow* aWindow)
// Eventually, SpiderMonkey will have a special-purpose callback for warnings
// only.
void
WarningOnlyErrorReporter(JSContext* aCx, JSErrorReport* aRep)
WarningOnlyErrorReporter(JSContext* aCx, const char* aMessage, JSErrorReport* aRep)
{
MOZ_ASSERT(JSREPORT_IS_WARNING(aRep->flags));
if (!NS_IsMainThread()) {
Expand All @@ -533,7 +534,7 @@ WarningOnlyErrorReporter(JSContext* aCx, JSErrorReport* aRep)
workers::WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(worker);

worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
worker->ReportError(aCx, aMessage, aRep);
return;
}

Expand All @@ -545,7 +546,7 @@ WarningOnlyErrorReporter(JSContext* aCx, JSErrorReport* aRep)
// DOM Window.
win = xpc::AddonWindowOrNull(JS::CurrentGlobalOrNull(aCx));
}
xpcReport->Init(aRep, nullptr, nsContentUtils::IsCallerChrome(),
xpcReport->Init(aRep, aMessage, nsContentUtils::IsCallerChrome(),
win ? win->AsInner()->WindowID() : 0);
xpcReport->LogToConsole();
}
Expand Down Expand Up @@ -585,7 +586,7 @@ AutoJSAPI::ReportException()
win = xpc::AddonWindowOrNull(errorGlobal);
}
nsPIDOMWindowInner* inner = win ? win->AsInner() : nullptr;
xpcReport->Init(jsReport.report(), jsReport.toStringResult().c_str(),
xpcReport->Init(jsReport.report(), jsReport.message(),
nsContentUtils::IsCallerChrome(),
inner ? inner->WindowID() : 0);
if (inner && jsReport.report()->errorNumber != JSMSG_OUT_OF_MEMORY) {
Expand All @@ -609,7 +610,7 @@ AutoJSAPI::ReportException()
// to get hold of it. After we invoke ReportError, clear the exception on
// cx(), just in case ReportError didn't.
JS_SetPendingException(cx(), exn);
worker->ReportError(cx(), jsReport.toStringResult(), jsReport.report());
worker->ReportError(cx(), jsReport.message(), jsReport.report());
ClearException();
}
} else {
Expand Down
6 changes: 2 additions & 4 deletions dom/promise/Promise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,7 @@ Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise)
bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise))
: GetCurrentThreadWorkerPrivate()->IsChromeWorker();
nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
win ? win->AsInner()->WindowID() : 0);
xpcReport->Init(report.report(), report.message(), isChrome, win ? win->AsInner()->WindowID() : 0);

// Now post an event to do the real reporting async
NS_DispatchToMainThread(new AsyncErrorReporter(xpcReport));
Expand Down Expand Up @@ -2645,8 +2644,7 @@ Promise::MaybeReportRejected()
if (exp) {
xpcReport->Init(cx, exp, isChrome, windowID);
} else {
xpcReport->Init(report.report(), report.toStringResult(),
isChrome, windowID);
xpcReport->Init(report.report(), report.message(), isChrome, windowID);
}

// Now post an event to do the real reporting async
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ ScriptExecutorRunnable::LogExceptionToConsole(JSContext* aCx,
}

RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
xpcReport->Init(report.report(), report.toStringResult().c_str(),
xpcReport->Init(report.report(), report.message(),
aWorkerPrivate->IsChromeWorker(), aWorkerPrivate->WindowID());

RefPtr<AsyncErrorReporter> r = new AsyncErrorReporter(xpcReport);
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/ServiceWorkerEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ ExtractErrorValues(JSContext* aCx, JS::Handle<JS::Value> aValue,
// this report anywhere.
RefPtr<xpc::ErrorReport> report = new xpc::ErrorReport();
report->Init(err,
"<unknown>", // toString result
"<unknown>", // fallback message
false, // chrome
0); // window ID

Expand Down
19 changes: 6 additions & 13 deletions dom/workers/WorkerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
#include "nsProxyRelease.h"
#include "nsQueryObject.h"
#include "nsSandboxFlags.h"
#include "nsUTF8Utils.h"
#include "prthread.h"
#include "xpcpublic.h"

Expand Down Expand Up @@ -5812,7 +5811,7 @@ WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
}

void
WorkerPrivate::ReportError(JSContext* aCx, JS::ConstUTF8CharsZ aToStringResult,
WorkerPrivate::ReportError(JSContext* aCx, const char* aFallbackMessage,
JSErrorReport* aReport)
{
AssertIsOnWorkerThread();
Expand Down Expand Up @@ -5856,19 +5855,13 @@ WorkerPrivate::ReportError(JSContext* aCx, JS::ConstUTF8CharsZ aToStringResult,
flags = nsIScriptError::errorFlag | nsIScriptError::exceptionFlag;
}

if (message.IsEmpty() && aToStringResult) {
nsDependentCString toStringResult(aToStringResult.c_str());
if (!AppendUTF8toUTF16(toStringResult, message, mozilla::fallible)) {
if (message.IsEmpty()) {
nsDependentCString fallbackMessage(aFallbackMessage);
if (!AppendUTF8toUTF16(fallbackMessage, message, mozilla::fallible)) {
// Try again, with only a 1 KB string. Do this infallibly this time.
// If the user doesn't have 1 KB to spare we're done anyways.
uint32_t index = std::min(uint32_t(1024), toStringResult.Length());

// Drop the last code point that may be cropped.
index = RewindToPriorUTF8Codepoint(toStringResult.BeginReading(), index);

nsDependentCString truncatedToStringResult(aToStringResult.c_str(),
index);
AppendUTF8toUTF16(truncatedToStringResult, message);
nsDependentCString truncatedFallbackMessage(aFallbackMessage, 1024);
AppendUTF8toUTF16(truncatedFallbackMessage, message);
}
}

Expand Down
4 changes: 1 addition & 3 deletions dom/workers/WorkerPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "Workers.h"

#include "js/CharacterEncoding.h"
#include "nsIContentPolicy.h"
#include "nsIContentSecurityPolicy.h"
#include "nsILoadGroup.h"
Expand Down Expand Up @@ -1165,8 +1164,7 @@ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
NotifyInternal(JSContext* aCx, Status aStatus);

void
ReportError(JSContext* aCx, JS::ConstUTF8CharsZ aToStringResult,
JSErrorReport* aReport);
ReportError(JSContext* aCx, const char* aMessage, JSErrorReport* aReport);

static void
ReportErrorToConsole(const char* aMessage);
Expand Down
46 changes: 28 additions & 18 deletions js/src/frontend/TokenStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, uns
void
CompileError::throwError(JSContext* cx)
{
if (JSREPORT_IS_WARNING(flags)) {
CallWarningReporter(cx, this);
if (JSREPORT_IS_WARNING(report.flags)) {
CallWarningReporter(cx, message, &report);
return;
}

Expand All @@ -583,7 +583,17 @@ CompileError::throwError(JSContext* cx)
// as the non-top-level "load", "eval", or "compile" native function
// returns false, the top-level reporter will eventually receive the
// uncaught exception report.
ErrorToException(cx, this, nullptr, nullptr);
ErrorToException(cx, message, &report, nullptr, nullptr);
}

CompileError::~CompileError()
{
js_free((void*)report.linebuf());
js_free((void*)report.ucmessage);
js_free(message);
message = nullptr;

PodZero(&report);
}

bool
Expand All @@ -605,33 +615,33 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
return false;
CompileError& err = *tempErrPtr;

err.flags = flags;
err.errorNumber = errorNumber;
err.filename = filename;
err.isMuted = mutedErrors;
err.report.flags = flags;
err.report.errorNumber = errorNumber;
err.report.filename = filename;
err.report.isMuted = mutedErrors;
if (offset == NoOffset) {
err.lineno = 0;
err.column = 0;
err.report.lineno = 0;
err.report.column = 0;
} else {
err.lineno = srcCoords.lineNum(offset);
err.column = srcCoords.columnIndex(offset);
err.report.lineno = srcCoords.lineNum(offset);
err.report.column = srcCoords.columnIndex(offset);
}

// If we have no location information, try to get one from the caller.
bool callerFilename = false;
if (offset != NoOffset && !err.filename && cx->isJSContext()) {
if (offset != NoOffset && !err.report.filename && cx->isJSContext()) {
NonBuiltinFrameIter iter(cx->asJSContext(),
FrameIter::FOLLOW_DEBUGGER_EVAL_PREV_LINK,
cx->compartment()->principals());
if (!iter.done() && iter.filename()) {
callerFilename = true;
err.filename = iter.filename();
err.lineno = iter.computeLine(&err.column);
err.report.filename = iter.filename();
err.report.lineno = iter.computeLine(&err.report.column);
}
}

if (!ExpandErrorArgumentsVA(cx, GetErrorMessage, nullptr, errorNumber,
nullptr, ArgumentsAreLatin1, &err, args))
if (!ExpandErrorArgumentsVA(cx, GetErrorMessage, nullptr, errorNumber, &err.message,
nullptr, ArgumentsAreLatin1, &err.report, args))
{
return false;
}
Expand All @@ -644,7 +654,7 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
// So we don't even try, leaving report.linebuf and friends zeroed. This
// means that any error involving a multi-line token (e.g. an unterminated
// multi-line string literal) won't have a context printed.
if (offset != NoOffset && err.lineno == lineno && !callerFilename) {
if (offset != NoOffset && err.report.lineno == lineno && !callerFilename) {
// We show only a portion (a "window") of the line around the erroneous
// token -- the first char in the token, plus |windowRadius| chars
// before it and |windowRadius - 1| chars after it. This is because
Expand Down Expand Up @@ -682,7 +692,7 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
if (!linebuf)
return false;

err.initOwnedLinebuf(linebuf.release(), windowLength, offset - windowStart);
err.report.initLinebuf(linebuf.release(), windowLength, offset - windowStart);
}

if (cx->isJSContext())
Expand Down
13 changes: 11 additions & 2 deletions js/src/frontend/TokenStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,18 @@ struct Token
}
};

class CompileError : public JSErrorReport {
public:
struct CompileError {
JSErrorReport report;
char* message;
CompileError() : message(nullptr) {}
~CompileError();
void throwError(JSContext* cx);

private:
// CompileError owns raw allocated memory, so disable assignment and copying
// for safety.
void operator=(const CompileError&) = delete;
CompileError(const CompileError&) = delete;
};

// Ideally, tokenizing would be entirely independent of context. But the
Expand Down
4 changes: 2 additions & 2 deletions js/src/gdb/gdb-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ checkBool(bool success)
}

/* The warning reporter callback. */
void reportWarning(JSContext* cx, JSErrorReport* report)
void reportWarning(JSContext* cx, const char* message, JSErrorReport* report)
{
fprintf(stderr, "%s:%u: %s\n",
report->filename ? report->filename : "<no filename>",
(unsigned int) report->lineno,
report->message().c_str());
message);
}

// prologue.py sets a breakpoint on this function; test functions can call it
Expand Down
2 changes: 1 addition & 1 deletion js/src/jsapi-tests/testParseJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Error(JSContext* cx, const char (&input)[N], uint32_t expectedLine,
CHECK(report.report()->errorNumber == JSMSG_JSON_BAD_PARSE);

const char* lineAndColumnASCII = JS_smprintf("line %d column %d", expectedLine, expectedColumn);
CHECK(strstr(report.toStringResult().c_str(), lineAndColumnASCII) != nullptr);
CHECK(strstr(report.message(), lineAndColumnASCII) != nullptr);
js_free((void*)lineAndColumnASCII);

/* We do not execute JS, so there should be no exception thrown. */
Expand Down
6 changes: 3 additions & 3 deletions js/src/jsapi-tests/testUncaughtSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ GetSymbolExceptionType(JSContext* cx)
js::ErrorReport report(cx);
MOZ_RELEASE_ASSERT(report.init(cx, exn, js::ErrorReport::WithSideEffects));

if (strcmp(report.toStringResult().c_str(), "uncaught exception: Symbol(Symbol.iterator)") == 0)
if (strcmp(report.message(), "uncaught exception: Symbol(Symbol.iterator)") == 0)
return SYMBOL_ITERATOR;
if (strcmp(report.toStringResult().c_str(), "uncaught exception: Symbol(foo)") == 0)
if (strcmp(report.message(), "uncaught exception: Symbol(foo)") == 0)
return SYMBOL_FOO;
if (strcmp(report.toStringResult().c_str(), "uncaught exception: Symbol()") == 0)
if (strcmp(report.message(), "uncaught exception: Symbol()") == 0)
return SYMBOL_EMPTY;
MOZ_CRASH("Unexpected symbol");
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/jsapi-tests/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ class JSAPITest
cx = nullptr;
}

static void reportWarning(JSContext* cx, JSErrorReport* report) {
static void reportWarning(JSContext* cx, const char* message, JSErrorReport* report) {
MOZ_RELEASE_ASSERT(report);
MOZ_RELEASE_ASSERT(JSREPORT_IS_WARNING(report->flags));

fprintf(stderr, "%s:%u:%s\n",
report->filename ? report->filename : "<no filename>",
(unsigned int) report->lineno,
report->message().c_str());
message);
}

virtual const JSClass * getGlobalClass() {
Expand Down
45 changes: 7 additions & 38 deletions js/src/jsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
#include "js/SliceBudget.h"
#include "js/StructuredClone.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"
#include "vm/DateObject.h"
#include "vm/Debugger.h"
#include "vm/EnvironmentObject.h"
Expand Down Expand Up @@ -6130,45 +6129,15 @@ JS_ErrorFromException(JSContext* cx, HandleObject obj)
}

void
JSErrorReport::initBorrowedLinebuf(const char16_t* linebufArg, size_t linebufLengthArg,
size_t tokenOffsetArg)
JSErrorReport::initLinebuf(const char16_t* linebuf, size_t linebufLength, size_t tokenOffset)
{
MOZ_ASSERT(linebufArg);
MOZ_ASSERT(tokenOffsetArg <= linebufLengthArg);
MOZ_ASSERT(linebufArg[linebufLengthArg] == '\0');
MOZ_ASSERT(linebuf);
MOZ_ASSERT(tokenOffset <= linebufLength);
MOZ_ASSERT(linebuf[linebufLength] == '\0');

linebuf_ = linebufArg;
linebufLength_ = linebufLengthArg;
tokenOffset_ = tokenOffsetArg;
}

void
JSErrorReport::freeLinebuf()
{
if (ownsLinebuf_ && linebuf_) {
js_free((void*)linebuf_);
ownsLinebuf_ = false;
}
linebuf_ = nullptr;
}

JSString*
JSErrorReport::newMessageString(JSContext* cx)
{
if (!message_)
return cx->runtime()->emptyString;

return JS_NewStringCopyUTF8Z(cx, message_);
}

void
JSErrorReport::freeMessage()
{
if (ownsMessage_) {
js_free((void*)message_.get());
ownsMessage_ = false;
}
message_ = JS::ConstUTF8CharsZ();
linebuf_ = linebuf;
linebufLength_ = linebufLength;
tokenOffset_ = tokenOffset;
}

JS_PUBLIC_API(bool)
Expand Down
Loading

0 comments on commit 40aa608

Please sign in to comment.