/* -*- 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/. */
/* * nsScriptErrorWithStack implementation. * a main-thread-only, cycle-collected subclass of nsScriptErrorBase * that can store a SavedFrame stack trace object.
*/
nsScriptErrorWithStack::nsScriptErrorWithStack(
JS::Handle<mozilla::Maybe<JS::Value>> aException,
JS::Handle<JSObject*> aStack, JS::Handle<JSObject*> aStackGlobal)
: mStack(aStack), mStackGlobal(aStackGlobal) {
MOZ_ASSERT(NS_IsMainThread(), "You can't use this class on workers.");
staticbool IsObjectGlobalDying(JSObject* aObj) { // CCWs are not associated with a single global if (js::IsCrossCompartmentWrapper(aObj)) { returnfalse;
}
already_AddRefed<nsScriptErrorBase> CreateScriptError(
nsGlobalWindowInner* win, JS::Handle<mozilla::Maybe<JS::Value>> aException,
JS::Handle<JSObject*> aStack, JS::Handle<JSObject*> aStackGlobal) { bool createWithStack = true; if (aException.isNothing() && !aStack) { // Neither stack nor exception, do not need nsScriptErrorWithStack.
createWithStack = false;
} elseif (win && (win->IsDying() || !win->WindowID())) { // The window is already dying or we don't have a WindowID, // this means nsConsoleService::ClearMessagesForWindowID // would be unable to cleanup this error.
createWithStack = false;
} elseif ((aStackGlobal && IsObjectGlobalDying(aStackGlobal)) ||
(aException.isSome() && aException.value().isObject() &&
IsObjectGlobalDying(&aException.value().toObject()))) { // Prevent leaks by not creating references to already dying globals.
createWithStack = false;
}
if (!createWithStack) {
RefPtr<nsScriptErrorBase> error = new nsScriptError(); return error.forget();
}
RefPtr<nsScriptErrorBase> error = new nsScriptErrorWithStack(aException, aStack, aStackGlobal); return error.forget();
}
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet)
¤
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.