Bug 1916990 - Part 5: Assert WithEnvironmentObject::withThis doesn't return a Window object. r=spidermonkey-reviewers,sfink

Differential Revision: https://phabricator.services.mozilla.com/D221211
This commit is contained in:
André Bargull 2024-09-09 06:16:17 +00:00
Родитель e5af89333d
Коммит d071d1a7b1
1 изменённых файлов: 9 добавлений и 3 удалений

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

@ -1222,8 +1222,8 @@ ClassBodyLexicalEnvironmentObject::createWithoutEnclosing(
JSObject* ExtensibleLexicalEnvironmentObject::thisObject() const { JSObject* ExtensibleLexicalEnvironmentObject::thisObject() const {
JSObject* obj = &getReservedSlot(THIS_VALUE_OR_SCOPE_SLOT).toObject(); JSObject* obj = &getReservedSlot(THIS_VALUE_OR_SCOPE_SLOT).toObject();
// Windows must never be exposed to script. setWindowProxyThisValue should // Windows must never be exposed to script. initThisObject should have set
// have set this to the WindowProxy. // this to the WindowProxy.
MOZ_ASSERT(!IsWindow(obj)); MOZ_ASSERT(!IsWindow(obj));
// WarpBuilder relies on the return value not being nursery-allocated for the // WarpBuilder relies on the return value not being nursery-allocated for the
@ -3438,7 +3438,13 @@ JSObject& WithEnvironmentObject::object() const {
} }
JSObject* WithEnvironmentObject::withThis() const { JSObject* WithEnvironmentObject::withThis() const {
return &getReservedSlot(THIS_SLOT).toObject(); JSObject* obj = &getReservedSlot(THIS_SLOT).toObject();
// Windows must never be exposed to script. WithEnvironmentObject::create
// should have set this to the WindowProxy.
MOZ_ASSERT(!IsWindow(obj));
return obj;
} }
bool WithEnvironmentObject::isSyntactic() const { bool WithEnvironmentObject::isSyntactic() const {