Bug 1481927. Always pass an object from the "relevant global" to Web IDL APIs that have a non-wrapper-cached "this". r=bholley

Differential Revision: https://phabricator.services.mozilla.com/D4491

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2018-08-29 03:03:46 +00:00
parent 190adbee05
commit 4c0adfa061
2 changed files with 10 additions and 4 deletions

View File

@ -7580,9 +7580,15 @@ class CGPerSignatureCall(CGThing):
elif needScopeObject(returnType, arguments, self.extendedAttributes,
descriptor.wrapperCache, True,
idlNode.getExtendedAttribute("StoreInSlot")):
needsUnwrap = True
needsUnwrappedVar = True
argsPre.append("unwrappedObj ? *unwrappedObj : obj")
# The scope object should always be from the relevant
# global. Make sure to unwrap it as needed.
cgThings.append(CGGeneric(dedent(
"""
JS::Rooted<JSObject*> unwrappedObj(cx, js::CheckedUnwrap(obj));
// Caller should have ensured that "obj" can be unwrapped already.
MOZ_DIAGNOSTIC_ASSERT(unwrappedObj);
""")))
argsPre.append("unwrappedObj")
if needsUnwrap and needsUnwrappedVar:
# We cannot assign into obj because it's a Handle, not a

View File

@ -31,7 +31,7 @@ TextEncoder::Encode(JSContext* aCx,
return;
}
JSAutoRealmAllowCCW ar(aCx, aObj);
JSAutoRealm ar(aCx, aObj);
JSObject* outView = Uint8Array::Create(
aCx, utf8.Length(), reinterpret_cast<const uint8_t*>(utf8.BeginReading()));
if (!outView) {