Bug 1552632 - Resolve globalThis when querying all properties of the global object. r=jandem

globalThis was already handled specially in JS_ResolveStandardClass,
JS_MayResolveStandardClass, and various other places, but not in
JS_NewEnumerateStandardClasses.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Orendorff 2019-05-30 17:55:14 +00:00
Родитель cf20f54068
Коммит 3961c47023
2 изменённых файлов: 15 добавлений и 0 удалений

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

@ -972,6 +972,16 @@ static bool EnumerateStandardClasses(JSContext* cx, JS::HandleObject obj,
return false;
}
bool resolved = false;
if (!GlobalObject::maybeResolveGlobalThis(cx, global, &resolved)) {
return false;
}
if (resolved || includeResolved) {
if (!properties.append(NameToId(cx->names().globalThis))) {
return false;
}
}
if (!EnumerateStandardClassesInTable(cx, global, properties,
standard_class_names, includeResolved)) {
return false;

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

@ -0,0 +1,5 @@
assertEq(Object.getOwnPropertyNames(this).includes('globalThis'), true);
if (typeof reportCompare === "function") {
reportCompare(0, 0);
}