/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
WorkerDebuggerGlobalScope* globalScope =
aWorkerPrivate->CreateDebuggerGlobalScope(aCx); if (!globalScope) {
NS_WARNING("Failed to make global!"); returnfalse;
}
if (NS_WARN_IF(!aWorkerPrivate->EnsureCSPEventListener())) { returnfalse;
}
ErrorResult rv;
JSAutoRealm ar(aCx, global);
workerinternals::LoadMainScript(aWorkerPrivate, nullptr, mScriptURL,
DebuggerScript, rv, mDocumentEncoding);
rv.WouldReportJSException(); // Explicitly ignore NS_BINDING_ABORTED on rv. Or more precisely, still // return false and don't SetWorkerScriptExecutedSuccessfully() in that // case, but don't throw anything on aCx. The idea is to not dispatch error // events if our load is canceled with that error code. if (rv.ErrorCodeIs(NS_BINDING_ABORTED)) {
rv.SuppressException(); returnfalse;
} // Make sure to propagate exceptions from rv onto aCx, so that they will get // reported after we return. We do this for all failures on rv, because now // we're using rv to track all the state we care about. if (rv.MaybeSetPendingException(aCx)) { returnfalse;
}
returntrue;
}
};
} // namespace
class WorkerDebugger::PostDebuggerMessageRunnable final : public Runnable {
WorkerDebugger* mDebugger;
nsString mMessage;
class WorkerDebugger::ReportDebuggerErrorRunnable final : public Runnable {
WorkerDebugger* mDebugger;
nsCString mFilename;
uint32_t mLineno;
nsString mMessage;
if (!mWorkerPrivate) { return NS_ERROR_UNEXPECTED;
}
// This should be non-null for dedicated workers and null for Shared and // Service workers. All Encoding values are static and will live as long // as the process and the convention is to therefore use raw pointers. const mozilla::Encoding* aDocumentEncoding =
NS_IsMainThread() && !mWorkerPrivate->GetParent() &&
mWorkerPrivate->GetDocument()
? mWorkerPrivate->GetDocument()->GetDocumentCharacterSet().get()
: nullptr;
if (!mIsInitialized) {
RefPtr<CompileDebuggerScriptRunnable> runnable = new CompileDebuggerScriptRunnable(mWorkerPrivate, aURL,
aDocumentEncoding); if (!runnable->Dispatch(mWorkerPrivate)) { return NS_ERROR_FAILURE;
}
RefPtr<PostDebuggerMessageRunnable> runnable = new PostDebuggerMessageRunnable(this, aMessage); if (NS_FAILED(mWorkerPrivate->DispatchToMainThreadForMessaging(
runnable.forget()))) {
NS_WARNING("Failed to post message to debugger on main thread!");
}
}
RefPtr<ReportDebuggerErrorRunnable> runnable = new ReportDebuggerErrorRunnable(this, aFilename, aLineno, aMessage); if (NS_FAILED(mWorkerPrivate->DispatchToMainThreadForMessaging(
runnable.forget()))) {
NS_WARNING("Failed to report error to debugger on main thread!");
}
}
for (constauto& listener : mListeners.Clone()) {
listener->OnError(aFilename, aLineno, aMessage);
}
AutoJSAPI jsapi; // We're only using this context to deserialize a stack to report to the // console, so the scope we use doesn't matter. Stack frame filtering happens // based on the principal encoded into the frame and the caller compartment, // not the compartment of the frame object, and the console reporting code // will not be using our context, and therefore will not care what compartment // it has entered.
DebugOnly<bool> ok = jsapi.Init(xpc::PrivilegedJunkScope());
MOZ_ASSERT(ok, "PrivilegedJunkScope should exist");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.