From ca80197a2ffd80afd2b2c180aedb8ac2c0725e1f Mon Sep 17 00:00:00 2001 From: Daniel Varga Date: Fri, 17 Apr 2020 13:49:04 +0300 Subject: [PATCH] Backed out 4 changesets (bug 1605209) for causing browser-chrome failures at dom/ipc/tests/JSWindowActor/browser_crash_report.js CLOSED TREE Backed out changeset 6eb1cc169dbf (bug 1605209) Backed out changeset d81b566ad94f (bug 1605209) Backed out changeset e0e6dbf1d48d (bug 1605209) Backed out changeset 289f5bbac1ae (bug 1605209) --- docshell/base/nsDocShell.cpp | 2 +- dom/base/ChromeUtils.cpp | 4 +- dom/base/ChromeUtils.h | 4 +- dom/base/nsWindowRoot.cpp | 2 +- dom/chrome-webidl/ChromeUtils.webidl | 4 +- dom/chrome-webidl/WindowGlobalActors.webidl | 4 +- dom/ipc/BrowserChild.cpp | 2 +- dom/ipc/BrowserParent.cpp | 2 +- dom/ipc/ContentChild.cpp | 2 +- dom/ipc/ContentChild.h | 2 +- dom/ipc/JSWindowActor.cpp | 43 ++------ dom/ipc/JSWindowActor.h | 6 +- dom/ipc/JSWindowActorChild.cpp | 2 +- dom/ipc/JSWindowActorChild.h | 2 +- dom/ipc/JSWindowActorParent.cpp | 2 +- dom/ipc/JSWindowActorParent.h | 2 +- dom/ipc/JSWindowActorService.cpp | 15 +-- dom/ipc/JSWindowActorService.h | 14 +-- dom/ipc/PContent.ipdl | 4 +- dom/ipc/PWindowGlobal.ipdl | 2 +- dom/ipc/WindowGlobalActor.cpp | 14 ++- dom/ipc/WindowGlobalActor.h | 2 +- dom/ipc/WindowGlobalChild.cpp | 4 +- dom/ipc/WindowGlobalChild.h | 4 +- dom/ipc/WindowGlobalParent.cpp | 4 +- dom/ipc/WindowGlobalParent.h | 4 +- dom/ipc/nsQueryActor.h | 16 +-- dom/ipc/tests/JSWindowActor/browser.ini | 1 - .../JSWindowActor/browser_crash_report.js | 104 ------------------ .../BrowserTestUtils/BrowserTestUtils.jsm | 3 - .../BrowserTestUtilsChild.jsm | 12 +- toolkit/crashreporter/CrashAnnotations.yaml | 12 -- xpfe/appshell/nsContentTreeOwner.cpp | 2 +- 33 files changed, 76 insertions(+), 226 deletions(-) delete mode 100644 dom/ipc/tests/JSWindowActor/browser_crash_report.js diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b14a2cb3a8be..767985c0cf45 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2011,7 +2011,7 @@ nsDocShell::GetLoadURIDelegate(nsILoadURIDelegate** aLoadURIDelegate) { already_AddRefed nsDocShell::GetLoadURIDelegate() { if (nsCOMPtr result = - do_QueryActor("LoadURIDelegate", GetWindow())) { + do_QueryActor(u"LoadURIDelegate", GetWindow())) { return result.forget(); } diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index cbe140940551..c06e5ee70956 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -1198,7 +1198,7 @@ void ChromeUtils::ResetLastExternalProtocolIframeAllowed( /* static */ void ChromeUtils::RegisterWindowActor(const GlobalObject& aGlobal, - const nsACString& aName, + const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv) { MOZ_ASSERT(XRE_IsParentProcess()); @@ -1209,7 +1209,7 @@ void ChromeUtils::RegisterWindowActor(const GlobalObject& aGlobal, /* static */ void ChromeUtils::UnregisterWindowActor(const GlobalObject& aGlobal, - const nsACString& aName) { + const nsAString& aName) { MOZ_ASSERT(XRE_IsParentProcess()); RefPtr service = JSWindowActorService::GetSingleton(); diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index 25ed218c1727..79882e2c6e3c 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -193,12 +193,12 @@ class ChromeUtils { static void ResetLastExternalProtocolIframeAllowed(GlobalObject& aGlobal); static void RegisterWindowActor(const GlobalObject& aGlobal, - const nsACString& aName, + const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv); static void UnregisterWindowActor(const GlobalObject& aGlobal, - const nsACString& aName); + const nsAString& aName); static bool IsClassifierBlockingErrorCode(GlobalObject& aGlobal, uint32_t aError); diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index cfa9f6eaecf1..13165fb203de 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -205,7 +205,7 @@ nsresult nsWindowRoot::GetControllerForCommand(const char* aCommand, // At this point, it is known that a child process is focused, so ask // its Controllers actor if the command is supported. nsCOMPtr controller = - do_QueryActor("Controllers", canonicalFocusedBC); + do_QueryActor(u"Controllers", canonicalFocusedBC); if (controller) { bool supported; controller->SupportsCommand(aCommand, &supported); diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index 5d774c293c1c..c1b86eaab1ff 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -441,10 +441,10 @@ partial namespace ChromeUtils { * See JSWindowActor.webidl for WindowActorOptions fields documentation. */ [ChromeOnly, Throws] - void registerWindowActor(UTF8String aName, optional WindowActorOptions aOptions = {}); + void registerWindowActor(DOMString aName, optional WindowActorOptions aOptions = {}); [ChromeOnly] - void unregisterWindowActor(UTF8String aName); + void unregisterWindowActor(DOMString aName); [ChromeOnly] // aError should a nsresult. diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl index 7143af80011f..055353ff580b 100644 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -68,7 +68,7 @@ interface WindowGlobalParent : WindowContext { * customize actor creation. */ [Throws] - JSWindowActorParent getActor(UTF8String name); + JSWindowActorParent getActor(DOMString name); /** * Renders a region of the frame into an image bitmap. @@ -130,5 +130,5 @@ interface WindowGlobalChild { * customize actor creation. */ [Throws] - JSWindowActorChild getActor(UTF8String name); + JSWindowActorChild getActor(DOMString name); }; diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 5cfca3207433..1c8a6e0fdbd3 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -2919,7 +2919,7 @@ NS_IMETHODIMP BrowserChild::GetWebBrowserChrome(nsIWebBrowserChrome3** aWebBrowserChrome) { nsCOMPtr outer = do_GetInterface(WebNavigation()); if (nsCOMPtr chrome = - do_QueryActor("WebBrowserChrome", outer)) { + do_QueryActor(u"WebBrowserChrome", outer)) { chrome.forget(aWebBrowserChrome); } else { // TODO: remove fallback diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index 3a54b873f70c..0335555069a1 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -2346,7 +2346,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvEnableDisableCommands( } nsCOMPtr browserController = - do_QueryActor("Controllers", aContext.get_canonical()); + do_QueryActor(u"Controllers", aContext.get_canonical()); if (browserController) { browserController->EnableDisableCommands(aAction, aEnabledCommands, aDisabledCommands); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index edbe19e1a126..3c0986316baf 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2653,7 +2653,7 @@ mozilla::ipc::IPCResult ContentChild::RecvInitJSWindowActorInfos( } mozilla::ipc::IPCResult ContentChild::RecvUnregisterJSWindowActor( - const nsCString& aName) { + const nsString& aName) { RefPtr actSvc = JSWindowActorService::GetSingleton(); actSvc->UnregisterWindowActor(aName); return IPC_OK(); diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index f7882b098213..9fb3e32b4ea1 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -408,7 +408,7 @@ class ContentChild final mozilla::ipc::IPCResult RecvInitJSWindowActorInfos( nsTArray&& aInfos); - mozilla::ipc::IPCResult RecvUnregisterJSWindowActor(const nsCString& aName); + mozilla::ipc::IPCResult RecvUnregisterJSWindowActor(const nsString& aName); mozilla::ipc::IPCResult RecvLastPrivateDocShellDestroyed(); diff --git a/dom/ipc/JSWindowActor.cpp b/dom/ipc/JSWindowActor.cpp index df5361bb902e..eacd18c450d5 100644 --- a/dom/ipc/JSWindowActor.cpp +++ b/dom/ipc/JSWindowActor.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/JSWindowActor.h" #include "mozilla/dom/JSWindowActorBinding.h" -#include "mozilla/Attributes.h" #include "mozilla/Telemetry.h" #include "mozilla/dom/ClonedErrorHolder.h" #include "mozilla/dom/ClonedErrorHolderBinding.h" @@ -19,7 +18,6 @@ #include "js/Promise.h" #include "xpcprivate.h" #include "nsASCIIMask.h" -#include "nsICrashReporter.h" namespace mozilla { namespace dom { @@ -49,33 +47,11 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(JSWindowActor) JSWindowActor::JSWindowActor() : mNextQueryId(0) {} -// RAII class to ensure that, if we crash while handling a message, the -// crash will be annotated with the name of the actor and the message. -struct MOZ_RAII AutoAnnotateMessageInCaseOfCrash { - AutoAnnotateMessageInCaseOfCrash(const nsCString& aActorName, - const nsCString& aMessageName) { - CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::JSActorName, - aActorName); - CrashReporter::AnnotateCrashReport( - CrashReporter::Annotation::JSActorMessage, aMessageName); - } - ~AutoAnnotateMessageInCaseOfCrash() { - CrashReporter::RemoveCrashReportAnnotation( - CrashReporter::Annotation::JSActorMessage); - CrashReporter::RemoveCrashReportAnnotation( - CrashReporter::Annotation::JSActorName); - } -}; - void JSWindowActor::StartDestroy() { - AutoAnnotateMessageInCaseOfCrash guard(/* aActorName = */ mName, - NS_LITERAL_CSTRING("")); InvokeCallback(CallbackFunction::WillDestroy); } void JSWindowActor::AfterDestroy() { - AutoAnnotateMessageInCaseOfCrash guard(/* aActorName = */ mName, - NS_LITERAL_CSTRING("")); InvokeCallback(CallbackFunction::DidDestroy); // Clear out & reject mPendingQueries RejectPendingQueries(); @@ -155,7 +131,7 @@ bool JSWindowActor::AllowMessage(const JSWindowActorMessageMeta& aMetadata, return true; } - nsAutoString messageName(NS_ConvertUTF8toUTF16(aMetadata.actorName())); + nsAutoString messageName(aMetadata.actorName()); messageName.AppendLiteral("::"); messageName.Append(aMetadata.messageName()); @@ -170,7 +146,7 @@ bool JSWindowActor::AllowMessage(const JSWindowActorMessageMeta& aMetadata, return false; } -void JSWindowActor::SetName(const nsACString& aName) { +void JSWindowActor::SetName(const nsAString& aName) { MOZ_ASSERT(mName.IsEmpty(), "Cannot set name twice!"); mName = aName; } @@ -268,9 +244,6 @@ void JSWindowActor::ReceiveRawMessage(const JSWindowActorMessageMeta& aMetadata, ipc::StructuredCloneData&& aData, ipc::StructuredCloneData&& aStack) { MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - AutoAnnotateMessageInCaseOfCrash guard( - /* aActorName = */ mName, - NS_LossyConvertUTF16toASCII(aMetadata.messageName())); AutoEntryScript aes(GetParentObject(), "JSWindowActor message handler"); JSContext* cx = aes.cx(); @@ -468,15 +441,17 @@ void JSWindowActor::QueryHandler::ResolvedCallback( IgnoredErrorResult error; data.Write(aCx, aValue, error); if (NS_WARN_IF(error.Failed())) { - nsAutoCString msg; + // We failed to serialize the message over IPC. Report this error to the + // console, and send a reject reply. + nsAutoString msg; msg.Append(mActor->Name()); msg.Append(':'); - msg.Append(NS_LossyConvertUTF16toASCII(mMessageName)); + msg.Append(mMessageName); msg.AppendLiteral(": message reply cannot be cloned."); - auto exc = MakeRefPtr(msg, NS_ERROR_FAILURE, - NS_LITERAL_CSTRING("DataCloneError"), - nullptr, nullptr); + auto exc = MakeRefPtr( + NS_ConvertUTF16toUTF8(msg), NS_ERROR_FAILURE, + NS_LITERAL_CSTRING("DataCloneError"), nullptr, nullptr); JS::Rooted val(aCx); if (ToJSValue(aCx, exc, &val)) { diff --git a/dom/ipc/JSWindowActor.h b/dom/ipc/JSWindowActor.h index aad3e90ae02b..3e4b9a791012 100644 --- a/dom/ipc/JSWindowActor.h +++ b/dom/ipc/JSWindowActor.h @@ -45,7 +45,7 @@ class JSWindowActor : public nsISupports, public nsWrapperCache { enum class Type { Parent, Child }; enum class CallbackFunction { WillDestroy, DidDestroy, ActorCreated }; - const nsCString& Name() const { return mName; } + const nsString& Name() const { return mName; } void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName, JS::Handle aObj, ErrorResult& aRv); @@ -79,7 +79,7 @@ class JSWindowActor : public nsISupports, public nsWrapperCache { virtual ~JSWindowActor() = default; - void SetName(const nsACString& aName); + void SetName(const nsAString& aName); void StartDestroy(); @@ -130,7 +130,7 @@ class JSWindowActor : public nsISupports, public nsWrapperCache { }; nsCOMPtr mWrappedJS; - nsCString mName; + nsString mName; nsRefPtrHashtable mPendingQueries; uint64_t mNextQueryId; }; diff --git a/dom/ipc/JSWindowActorChild.cpp b/dom/ipc/JSWindowActorChild.cpp index f5324584aef2..5684558e1053 100644 --- a/dom/ipc/JSWindowActorChild.cpp +++ b/dom/ipc/JSWindowActorChild.cpp @@ -30,7 +30,7 @@ JSObject* JSWindowActorChild::WrapObject(JSContext* aCx, WindowGlobalChild* JSWindowActorChild::GetManager() const { return mManager; } -void JSWindowActorChild::Init(const nsACString& aName, +void JSWindowActorChild::Init(const nsAString& aName, WindowGlobalChild* aManager) { MOZ_ASSERT(!mManager, "Cannot Init() a JSWindowActorChild twice!"); SetName(aName); diff --git a/dom/ipc/JSWindowActorChild.h b/dom/ipc/JSWindowActorChild.h index 9520c919a4a1..2a2e883bd602 100644 --- a/dom/ipc/JSWindowActorChild.h +++ b/dom/ipc/JSWindowActorChild.h @@ -52,7 +52,7 @@ class JSWindowActorChild final : public JSWindowActor { } WindowGlobalChild* GetManager() const; - void Init(const nsACString& aName, WindowGlobalChild* aManager); + void Init(const nsAString& aName, WindowGlobalChild* aManager); void StartDestroy(); void AfterDestroy(); Document* GetDocument(ErrorResult& aRv); diff --git a/dom/ipc/JSWindowActorParent.cpp b/dom/ipc/JSWindowActorParent.cpp index a6f9ed04e4a9..f6cec04ffd14 100644 --- a/dom/ipc/JSWindowActorParent.cpp +++ b/dom/ipc/JSWindowActorParent.cpp @@ -26,7 +26,7 @@ JSObject* JSWindowActorParent::WrapObject(JSContext* aCx, WindowGlobalParent* JSWindowActorParent::GetManager() const { return mManager; } -void JSWindowActorParent::Init(const nsACString& aName, +void JSWindowActorParent::Init(const nsAString& aName, WindowGlobalParent* aManager) { MOZ_ASSERT(!mManager, "Cannot Init() a JSWindowActorParent twice!"); SetName(aName); diff --git a/dom/ipc/JSWindowActorParent.h b/dom/ipc/JSWindowActorParent.h index ad1d66e367b7..c5bf0db2263c 100644 --- a/dom/ipc/JSWindowActorParent.h +++ b/dom/ipc/JSWindowActorParent.h @@ -43,7 +43,7 @@ class JSWindowActorParent final : public JSWindowActor { nsIGlobalObject* GetParentObject() const override; WindowGlobalParent* GetManager() const; - void Init(const nsACString& aName, WindowGlobalParent* aManager); + void Init(const nsAString& aName, WindowGlobalParent* aManager); void StartDestroy(); void AfterDestroy(); CanonicalBrowsingContext* GetBrowsingContext(ErrorResult& aRv); diff --git a/dom/ipc/JSWindowActorService.cpp b/dom/ipc/JSWindowActorService.cpp index 0f1f203a99d0..aadce59a5ecb 100644 --- a/dom/ipc/JSWindowActorService.cpp +++ b/dom/ipc/JSWindowActorService.cpp @@ -94,7 +94,7 @@ JSWindowActorInfo JSWindowActorProtocol::ToIPC() { } already_AddRefed -JSWindowActorProtocol::FromWebIDLOptions(const nsACString& aName, +JSWindowActorProtocol::FromWebIDLOptions(const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv) { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); @@ -395,15 +395,16 @@ already_AddRefed JSWindowActorService::GetSingleton() { } void JSWindowActorService::RegisterWindowActor( - const nsACString& aName, const WindowActorOptions& aOptions, + const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(XRE_IsParentProcess()); auto entry = mDescriptors.LookupForAdd(aName); if (entry) { - aRv.ThrowNotSupportedError(nsPrintfCString( - "'%s' actor is already registered.", PromiseFlatCString(aName).get())); + aRv.ThrowNotSupportedError( + nsPrintfCString("'%s' actor is already registered.", + NS_ConvertUTF16toUTF8(aName).get())); return; } @@ -433,8 +434,8 @@ void JSWindowActorService::RegisterWindowActor( proto->AddObservers(); } -void JSWindowActorService::UnregisterWindowActor(const nsACString& aName) { - nsAutoCString name(aName); +void JSWindowActorService::UnregisterWindowActor(const nsAString& aName) { + nsAutoString name(aName); RefPtr proto; if (mDescriptors.Remove(aName, getter_AddRefs(proto))) { @@ -506,7 +507,7 @@ void JSWindowActorService::UnregisterChromeEventTarget(EventTarget* aTarget) { } already_AddRefed JSWindowActorService::GetProtocol( - const nsACString& aName) { + const nsAString& aName) { return mDescriptors.Get(aName); } diff --git a/dom/ipc/JSWindowActorService.h b/dom/ipc/JSWindowActorService.h index 1f2192d17104..73b9fc227f48 100644 --- a/dom/ipc/JSWindowActorService.h +++ b/dom/ipc/JSWindowActorService.h @@ -47,7 +47,7 @@ class JSWindowActorProtocol final : public nsIObserver, JSWindowActorInfo ToIPC(); static already_AddRefed FromWebIDLOptions( - const nsACString& aName, const WindowActorOptions& aOptions, + const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv); struct Sided { @@ -78,13 +78,13 @@ class JSWindowActorProtocol final : public nsIObserver, const nsAString& aRemoteType); private: - explicit JSWindowActorProtocol(const nsACString& aName) : mName(aName) {} + explicit JSWindowActorProtocol(const nsAString& aName) : mName(aName) {} extensions::MatchPatternSet* GetURIMatcher(); bool RemoteTypePrefixMatches(const nsDependentSubstring& aRemoteType); bool MessageManagerGroupMatches(BrowsingContext* aBrowsingContext); ~JSWindowActorProtocol() = default; - nsCString mName; + nsString mName; bool mAllFrames = false; bool mIncludeChrome = false; nsTArray mMatches; @@ -103,11 +103,11 @@ class JSWindowActorService final { static already_AddRefed GetSingleton(); - void RegisterWindowActor(const nsACString& aName, + void RegisterWindowActor(const nsAString& aName, const WindowActorOptions& aOptions, ErrorResult& aRv); - void UnregisterWindowActor(const nsACString& aName); + void UnregisterWindowActor(const nsAString& aName); // Register child's Window Actor from JSWindowActorInfos for content process. void LoadJSWindowActorInfos(nsTArray& aInfos); @@ -122,14 +122,14 @@ class JSWindowActorService final { // NOTE: This method is static, as it may be called during shutdown. static void UnregisterChromeEventTarget(EventTarget* aTarget); - already_AddRefed GetProtocol(const nsACString& aName); + already_AddRefed GetProtocol(const nsAString& aName); private: JSWindowActorService(); ~JSWindowActorService(); nsTArray mChromeEventTargets; - nsRefPtrHashtable mDescriptors; + nsRefPtrHashtable mDescriptors; }; } // namespace dom diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index d06a04934a06..0efdd6658270 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -244,7 +244,7 @@ struct JSWindowActorEventDecl struct JSWindowActorInfo { - nsCString name; + nsString name; bool allFrames; nsCString? url; @@ -618,7 +618,7 @@ child: /** * Unregister a previously registered JSWindowActor in the child process. */ - async UnregisterJSWindowActor(nsCString name); + async UnregisterJSWindowActor(nsString name); async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit, StructuredCloneData initialData, diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl index 86439207fea8..863692fc9641 100644 --- a/dom/ipc/PWindowGlobal.ipdl +++ b/dom/ipc/PWindowGlobal.ipdl @@ -25,7 +25,7 @@ namespace mozilla { namespace dom { struct JSWindowActorMessageMeta { - nsCString actorName; + nsString actorName; nsString messageName; uint64_t queryId; JSWindowActorMessageKind kind; diff --git a/dom/ipc/WindowGlobalActor.cpp b/dom/ipc/WindowGlobalActor.cpp index 57895ea3e621..e96bf993490e 100644 --- a/dom/ipc/WindowGlobalActor.cpp +++ b/dom/ipc/WindowGlobalActor.cpp @@ -37,7 +37,7 @@ WindowGlobalInit WindowGlobalActor::AboutBlankInitializer( outerWindowId); } -void WindowGlobalActor::ConstructActor(const nsACString& aName, +void WindowGlobalActor::ConstructActor(const nsAString& aName, JS::MutableHandleObject aActor, ErrorResult& aRv) { MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); @@ -113,17 +113,19 @@ void WindowGlobalActor::ConstructActor(const nsACString& aName, // Load the specific property from our module. JS::RootedValue ctor(cx); - nsAutoCString ctorName(aName); - ctorName.AppendASCII(actorType == JSWindowActor::Type::Parent ? "Parent" - : "Child"); - if (!JS_GetProperty(cx, exports, ctorName.get(), &ctor)) { + nsAutoString ctorName(aName); + ctorName.Append(actorType == JSWindowActor::Type::Parent + ? NS_LITERAL_STRING("Parent") + : NS_LITERAL_STRING("Child")); + if (!JS_GetUCProperty(cx, exports, ctorName.get(), ctorName.Length(), + &ctor)) { aRv.NoteJSContextException(cx); return; } if (NS_WARN_IF(!ctor.isObject())) { nsPrintfCString message("Could not find actor constructor '%s'", - ctorName.get()); + NS_ConvertUTF16toUTF8(ctorName).get()); aRv.ThrowNotFoundError(message); return; } diff --git a/dom/ipc/WindowGlobalActor.h b/dom/ipc/WindowGlobalActor.h index a2f3bc5cc5c6..3ad7056372f8 100644 --- a/dom/ipc/WindowGlobalActor.h +++ b/dom/ipc/WindowGlobalActor.h @@ -30,7 +30,7 @@ class WindowGlobalActor : public nsISupports { // Load the module for the named Window Actor and contruct it. // This method will not initialize the actor or set its manager, // which is handled by callers. - void ConstructActor(const nsACString& aName, JS::MutableHandleObject aActor, + void ConstructActor(const nsAString& aName, JS::MutableHandleObject aActor, ErrorResult& aRv); virtual nsIURI* GetDocumentURI() = 0; virtual const nsAString& GetRemoteType() = 0; diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index 156cf6860d1e..8376646c9063 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -471,7 +471,7 @@ const nsAString& WindowGlobalChild::GetRemoteType() { } already_AddRefed WindowGlobalChild::GetActor( - const nsACString& aName, ErrorResult& aRv) { + const nsAString& aName, ErrorResult& aRv) { if (!CanSend()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; @@ -513,7 +513,7 @@ void WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) { #endif // Destroy our JSWindowActors, and reject any pending queries. - nsRefPtrHashtable windowActors; + nsRefPtrHashtable windowActors; mWindowActors.SwapElements(windowActors); for (auto iter = windowActors.Iter(); !iter.Done(); iter.Next()) { iter.Data()->RejectPendingQueries(); diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index 8dc99e826af7..96bf99ee6c84 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -94,7 +94,7 @@ class WindowGlobalChild final : public WindowGlobalActor, ipc::StructuredCloneData&& aStack); // Get a JS actor object by name. - already_AddRefed GetActor(const nsACString& aName, + already_AddRefed GetActor(const nsAString& aName, ErrorResult& aRv); // Create and initialize the WindowGlobalChild object. @@ -150,7 +150,7 @@ class WindowGlobalChild final : public WindowGlobalActor, RefPtr mWindowGlobal; RefPtr mBrowsingContext; RefPtr mWindowContext; - nsRefPtrHashtable mWindowActors; + nsRefPtrHashtable mWindowActors; nsCOMPtr mDocumentPrincipal; nsCOMPtr mDocumentURI; uint64_t mInnerWindowId; diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 4f7237e4dfb0..b0bb5e227e7f 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -414,7 +414,7 @@ void WindowGlobalParent::NotifyContentBlockingEvent( } already_AddRefed WindowGlobalParent::GetActor( - const nsACString& aName, ErrorResult& aRv) { + const nsAString& aName, ErrorResult& aRv) { if (!CanSend()) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; @@ -671,7 +671,7 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) { } // Destroy our JSWindowActors, and reject any pending queries. - nsRefPtrHashtable windowActors; + nsRefPtrHashtable windowActors; mWindowActors.SwapElements(windowActors); for (auto iter = windowActors.Iter(); !iter.Done(); iter.Next()) { iter.Data()->RejectPendingQueries(); diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 7f591586588b..f5e8d40be726 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -74,7 +74,7 @@ class WindowGlobalParent final : public WindowContext, already_AddRefed GetChildActor(); // Get a JS actor object by name. - already_AddRefed GetActor(const nsACString& aName, + already_AddRefed GetActor(const nsAString& aName, ErrorResult& aRv); // Get this actor's manager if it is not an in-process actor. Returns @@ -233,7 +233,7 @@ class WindowGlobalParent final : public WindowContext, nsCOMPtr mDocumentURI; nsString mDocumentTitle; - nsRefPtrHashtable mWindowActors; + nsRefPtrHashtable mWindowActors; bool mInProcess; bool mIsInitialDocument; diff --git a/dom/ipc/nsQueryActor.h b/dom/ipc/nsQueryActor.h index a1d4539f73e1..ff261f6f787e 100644 --- a/dom/ipc/nsQueryActor.h +++ b/dom/ipc/nsQueryActor.h @@ -17,7 +17,7 @@ // only has any use within a child process. class MOZ_STACK_CLASS nsQueryActorChild final : public nsCOMPtr_helper { public: - nsQueryActorChild(const nsLiteralCString aActorName, + nsQueryActorChild(const nsLiteralString aActorName, nsPIDOMWindowOuter* aWindow) : mActorName(aActorName), mWindow(aWindow) {} @@ -43,21 +43,21 @@ class MOZ_STACK_CLASS nsQueryActorChild final : public nsCOMPtr_helper { } private: - const nsLiteralCString mActorName; + const nsLiteralString mActorName; nsPIDOMWindowOuter* mWindow; }; template -inline nsQueryActorChild do_QueryActor(const char (&aActorName)[length], +inline nsQueryActorChild do_QueryActor(const char16_t (&aActorName)[length], nsPIDOMWindowOuter* aWindow) { - return nsQueryActorChild(nsLiteralCString(aActorName), aWindow); + return nsQueryActorChild(nsLiteralString(aActorName), aWindow); } // This type is used to get an actor given a CanonicalBrowsingContext. It // is only useful in the parent process. class MOZ_STACK_CLASS nsQueryActorParent final : public nsCOMPtr_helper { public: - nsQueryActorParent(nsLiteralCString aActorName, + nsQueryActorParent(nsLiteralString aActorName, mozilla::dom::CanonicalBrowsingContext* aBrowsingContext) : mActorName(aActorName), mBrowsingContext(aBrowsingContext) {} @@ -83,15 +83,15 @@ class MOZ_STACK_CLASS nsQueryActorParent final : public nsCOMPtr_helper { } private: - const nsLiteralCString mActorName; + const nsLiteralString mActorName; mozilla::dom::CanonicalBrowsingContext* mBrowsingContext; }; template inline nsQueryActorParent do_QueryActor( - const char (&aActorName)[length], + const char16_t (&aActorName)[length], mozilla::dom::CanonicalBrowsingContext* aBrowsingContext) { - return nsQueryActorParent(nsLiteralCString(aActorName), aBrowsingContext); + return nsQueryActorParent(nsLiteralString(aActorName), aBrowsingContext); } #endif // defined nsQueryActor_h diff --git a/dom/ipc/tests/JSWindowActor/browser.ini b/dom/ipc/tests/JSWindowActor/browser.ini index e69b89df4243..5c23349037fe 100644 --- a/dom/ipc/tests/JSWindowActor/browser.ini +++ b/dom/ipc/tests/JSWindowActor/browser.ini @@ -2,7 +2,6 @@ support-files = head.js -[browser_crash_report.js] [browser_destroy_callbacks.js] [browser_event_listener.js] [browser_getActor.js] diff --git a/dom/ipc/tests/JSWindowActor/browser_crash_report.js b/dom/ipc/tests/JSWindowActor/browser_crash_report.js deleted file mode 100644 index 28f4344f0d1e..000000000000 --- a/dom/ipc/tests/JSWindowActor/browser_crash_report.js +++ /dev/null @@ -1,104 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -declTest("crash actor", { - allFrames: true, - - async test(browser) { - if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) { - info("Cannot test crash annotations without a crash reporter"); - return; - } - - { - info("Creating a new tab."); - let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); - let newTabBrowser = newTab.linkedBrowser; - - let parent = newTabBrowser.browsingContext.currentWindowGlobal.getActor( - "Test" - ); - ok(parent, "JSWindowActorParent should have value."); - - await SpecialPowers.spawn(newTabBrowser, [], async function() { - let child = content.windowGlobalChild; - ok(child, "WindowGlobalChild should have value."); - is( - child.isInProcess, - false, - "Actor should be loaded in the content process." - ); - // Make sure that the actor is loaded. - let actorChild = child.getActor("Test"); - is(actorChild.show(), "TestChild", "actor show should have value."); - is( - actorChild.manager, - child, - "manager should match WindowGlobalChild." - ); - }); - - info( - "Crashing from withing an actor. We should have an actor name and a message name." - ); - let report = await BrowserTestUtils.crashFrame( - newTabBrowser, - /* shouldShowTabCrashPage = */ false, - /* shouldClearMinidumps = */ true, - /* browsingContext = */ null, - { asyncCrash: false } - ); - - is(report.JSActorName, "BrowserTestUtils"); - is(report.JSActorMessage, "BrowserTestUtils:CrashFrame"); - - BrowserTestUtils.removeTab(newTab); - } - - { - info("Creating a new tab for async crash"); - let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); - let newTabBrowser = newTab.linkedBrowser; - - let parent = newTabBrowser.browsingContext.currentWindowGlobal.getActor( - "Test" - ); - ok(parent, "JSWindowActorParent should have value."); - - await SpecialPowers.spawn(newTabBrowser, [], async function() { - let child = content.windowGlobalChild; - ok(child, "WindowGlobalChild should have value."); - is( - child.isInProcess, - false, - "Actor should be loaded in the content process." - ); - // Make sure that the actor is loaded. - let actorChild = child.getActor("Test"); - is(actorChild.show(), "TestChild", "actor show should have value."); - is( - actorChild.manager, - child, - "manager should match WindowGlobalChild." - ); - }); - - info( - "Crashing from without an actor. We should have neither an actor name nor a message name." - ); - let report = await BrowserTestUtils.crashFrame( - newTabBrowser, - /* shouldShowTabCrashPage = */ false, - /* shouldClearMinidumps = */ true, - /* browsingContext = */ null, - { asyncCrash: true } - ); - - is(report.JSActorName, null); - is(report.JSActorMessage, null); - - BrowserTestUtils.removeTab(newTab); - } - }, -}); diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index 3d42445241a3..bc42c85be845 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -1632,8 +1632,6 @@ var BrowserTestUtils = { * An object with any of the following fields: * crashType: "CRASH_INVALID_POINTER_DEREF" | "CRASH_OOM" * The type of crash. If unspecified, default to "CRASH_INVALID_POINTER_DEREF" - * asyncCrash: bool - * If specified and `true`, cause the crash asynchronously. * * @returns (Promise) * @resolves An Object with key-value pairs representing the data from the @@ -1781,7 +1779,6 @@ var BrowserTestUtils = { "BrowserTestUtils:CrashFrame", { crashType: options.crashType || "", - asyncCrash: options.asyncCrash || false, } ); diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtilsChild.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtilsChild.jsm index e63858510bee..5f5d9d31382e 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtilsChild.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtilsChild.jsm @@ -219,7 +219,6 @@ class BrowserTestUtilsChild extends JSWindowActorChild { ); let dies = function() { - dump("\nEt tu, Brute?\n"); ChromeUtils.privateNoteIntentionalCrash(); switch (aMessage.data.crashType) { @@ -243,15 +242,8 @@ class BrowserTestUtilsChild extends JSWindowActorChild { } }; - if (aMessage.data.asyncCrash) { - let { setTimeout } = ChromeUtils.import( - "resource://gre/modules/Timer.jsm" - ); - // Get out of the stack. - setTimeout(dies, 0); - } else { - dies(); - } + dump("\nEt tu, Brute?\n"); + dies(); } } diff --git a/toolkit/crashreporter/CrashAnnotations.yaml b/toolkit/crashreporter/CrashAnnotations.yaml index 767badf42a6e..678ea5566b32 100644 --- a/toolkit/crashreporter/CrashAnnotations.yaml +++ b/toolkit/crashreporter/CrashAnnotations.yaml @@ -553,18 +553,6 @@ JavaStackTrace: uncaught Java exception. type: string -JSActorMessage: - description: > - If an actor is currently treating a message, this is the name of the message. - Otherwise, empty. - type: string - -JSActorName: - description: > - If an actor is currently treating a message, this is the name of the actor. - Otherwise, empty. - type: string - JSLargeAllocationFailure: description: > A large allocation couldn't be satisfied, check the JSOutOfMemory diff --git a/xpfe/appshell/nsContentTreeOwner.cpp b/xpfe/appshell/nsContentTreeOwner.cpp index ee829bec78e5..d012bd310195 100644 --- a/xpfe/appshell/nsContentTreeOwner.cpp +++ b/xpfe/appshell/nsContentTreeOwner.cpp @@ -84,7 +84,7 @@ nsContentTreeOwner::GetWebBrowserChrome() { nsCOMPtr outer(docShell->GetWindow()); if (nsCOMPtr chrome = - do_QueryActor("WebBrowserChrome", outer)) { + do_QueryActor(u"WebBrowserChrome", outer)) { return chrome.forget(); }