diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 9cdcd26ae933..4bc3c8360bba 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -12321,8 +12321,15 @@ class CGDictionary(CGThing): "Init", "bool", [Argument('const nsAString&', 'aJSON')], body=dedent(""" - MOZ_ASSERT(NS_IsMainThread()); - AutoSafeJSContext cx; + AutoJSAPI jsapi; + JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); + if (!cleanGlobal) { + return false; + } + if (!jsapi.Init(cleanGlobal)) { + return false; + } + JSContext* cx = jsapi.cx(); JS::Rooted json(cx); bool ok = ParseJSON(cx, aJSON, &json); NS_ENSURE_TRUE(ok, false); @@ -13401,6 +13408,8 @@ class CGBindingRoot(CGThing): return any(m.getExtendedAttribute("UseCounter") for m in iface.members) bindingHeaders["mozilla/UseCounter.h"] = any( descriptorRequiresTelemetry(d) for d in descriptors) + bindingHeaders["mozilla/dom/SimpleGlobalObject.h"] = any( + CGDictionary.dictionarySafeToJSONify(d) for d in dictionaries) cgthings.extend(traverseMethods) cgthings.extend(unlinkMethods)