Bug 1655413 [wpt PR 24763] - Make CSP default-src without 'unsafe-eval' block eval...
[gecko.git] / dom / workers / RegisterBindings.cpp
blobd871949d44bf3855e35b440f1bc3f120a236f408
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "WorkerPrivate.h"
8 #include "ChromeWorkerScope.h"
9 #include "RuntimeService.h"
11 #include "jsapi.h"
12 #include "mozilla/dom/DebuggerNotificationObserverBinding.h"
13 #include "mozilla/dom/RegisterWorkerBindings.h"
14 #include "mozilla/dom/RegisterWorkerDebuggerBindings.h"
15 #include "mozilla/OSFileConstants.h"
17 using namespace mozilla::dom;
19 bool WorkerPrivate::RegisterBindings(JSContext* aCx,
20 JS::Handle<JSObject*> aGlobal) {
21 // Init Web IDL bindings
22 if (!RegisterWorkerBindings(aCx, aGlobal)) {
23 return false;
26 if (IsChromeWorker()) {
27 if (!DefineChromeWorkerFunctions(aCx, aGlobal)) {
28 return false;
31 RefPtr<OSFileConstantsService> service =
32 OSFileConstantsService::GetOrCreate();
33 if (!service->DefineOSFileConstants(aCx, aGlobal)) {
34 return false;
38 return true;
41 bool WorkerPrivate::RegisterDebuggerBindings(JSContext* aCx,
42 JS::Handle<JSObject*> aGlobal) {
43 // Init Web IDL bindings
44 if (!RegisterWorkerDebuggerBindings(aCx, aGlobal)) {
45 return false;
48 if (!ChromeUtils_Binding::GetConstructorObject(aCx)) {
49 return false;
52 if (!DebuggerNotificationObserver_Binding::GetConstructorObject(aCx)) {
53 return false;
56 if (!JS_DefineDebuggerObject(aCx, aGlobal)) {
57 return false;
60 return true;