Bug 1744036 part 2 - Don't use pinned atoms in a few places in DOM bindings. r=jonco,peterv

Differential Revision: https://phabricator.services.mozilla.com/D132689
This commit is contained in:
Jan de Mooij 2021-12-08 08:38:00 +00:00
Родитель 9ad9d5ebb9
Коммит d4cc7e615a
1 изменённых файлов: 10 добавлений и 10 удалений

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

@ -807,13 +807,16 @@ static bool DefineConstructor(JSContext* cx, JS::Handle<JSObject*> global,
static bool DefineConstructor(JSContext* cx, JS::Handle<JSObject*> global,
const char* name,
JS::Handle<JSObject*> constructor) {
PinnedStringId nameStr;
return nameStr.init(cx, name) &&
DefineConstructor(cx, global, nameStr, constructor);
JSString* nameStr = JS_AtomizeString(cx, name);
if (!nameStr) {
return false;
}
JS::Rooted<JS::PropertyKey> nameKey(cx,
JS::PropertyKey::fromNonIntAtom(nameStr));
return DefineConstructor(cx, global, nameKey, constructor);
}
// name must be a pinned string (or JS::PropertyKey::fromPinnedString will
// assert).
// name must be an atom (or JS::PropertyKey::fromNonIntAtom will assert).
static JSObject* CreateInterfaceObject(
JSContext* cx, JS::Handle<JSObject*> global,
JS::Handle<JSObject*> constructorProto, const JSClass* constructorClass,
@ -904,7 +907,7 @@ static JSObject* CreateInterfaceObject(
return nullptr;
}
JS::Rooted<jsid> nameStr(cx, JS::PropertyKey::fromPinnedString(name));
JS::Rooted<jsid> nameStr(cx, JS::PropertyKey::fromNonIntAtom(name));
if (defineOnGlobal && !DefineConstructor(cx, global, nameStr, constructor)) {
return nullptr;
}
@ -1068,10 +1071,7 @@ void CreateInterfaceObjects(
bool isChrome = nsContentUtils::ThreadsafeIsSystemCaller(cx);
// Might as well intern, since we're going to need an atomized
// version of name anyway when we stick our constructor on the
// global.
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeAndPinString(cx, name));
JS::Rooted<JSString*> nameStr(cx, JS_AtomizeString(cx, name));
if (!nameStr) {
return;
}