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
This commit is contained in:
Jan de Mooij 2018-12-18 18:42:28 +00:00
Родитель 84fe725407
Коммит 7fa54ccf51
2 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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),