diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp index 323eed4a8b3c..7cecf9f3e55c 100644 --- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -15,6 +15,7 @@ #include "nsGlobalWindow.h" #include "nsJSUtils.h" #include "nsPerformance.h" +#include "ScriptSettings.h" #include "WorkerPrivate.h" #include "WorkerRunnable.h" #include "xpcprivate.h" @@ -323,7 +324,8 @@ private: wp = wp->GetParent(); } - AutoPushJSContext cx(wp->ParentJSContext()); + AutoJSAPI jsapi; + JSContext* cx = jsapi.cx(); ClearException ce(cx); nsPIDOMWindow* window = wp->GetWindow(); @@ -332,6 +334,8 @@ private: nsRefPtr win = static_cast(window); NS_ENSURE_TRUE_VOID(win); + JSAutoCompartment ac(cx, win->GetWrapperPreserveColor()); + ErrorResult error; nsRefPtr console = win->GetConsole(error); if (error.Failed()) {