From 7fa54ccf51475f101508e48ff7c3a72ac30c7980 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 18 Dec 2018 18:42:28 +0000 Subject: [PATCH] Bug 1512655 part 2 - Assert Cu.setWantXrays is never called on system-principal scopes. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D14695 --HG-- extra : moz-landing-system : lando --- js/xpconnect/idl/xpccomponents.idl | 2 ++ js/xpconnect/src/XPCComponents.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/idl/xpccomponents.idl b/js/xpconnect/idl/xpccomponents.idl index 5b6c68340d05..f40a57b143b7 100644 --- a/js/xpconnect/idl/xpccomponents.idl +++ b/js/xpconnect/idl/xpccomponents.idl @@ -458,6 +458,8 @@ interface nsIXPCComponents_Utils : nsISupports * * Enables Xray vision for same-compartment access for the compartment * indicated by |vscope|. All outgoing wrappers are recomputed. + * + * This must not be called on chrome (system-principal) scopes. */ [implicit_jscontext] void setWantXrays(in jsval vscope); diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 80aabf3ae8eb..eeb116e674f9 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1978,9 +1978,8 @@ nsXPCComponents_Utils::SetWantXrays(HandleValue vscope, JSContext* cx) { return NS_ERROR_INVALID_ARG; } JSObject* scopeObj = js::UncheckedUnwrap(&vscope.toObject()); - MOZ_DIAGNOSTIC_ASSERT( - !mozJSComponentLoader::Get()->IsLoaderGlobal(scopeObj), - "Don't call Cu.setWantXrays() in a JSM that shares its global"); + MOZ_RELEASE_ASSERT(!AccessCheck::isChrome(scopeObj), + "Don't call setWantXrays on system-principal scopes"); JS::Compartment* compartment = js::GetObjectCompartment(scopeObj); CompartmentPrivate::Get(scopeObj)->wantXrays = true; bool ok = js::RecomputeWrappers(cx, js::SingleCompartment(compartment),