LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - WorkerDebuggerGlobalScopeBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 299 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 24 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM WorkerDebuggerGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "FunctionBinding.h"
       6             : #include "PromiseBinding.h"
       7             : #include "WorkerDebuggerGlobalScopeBinding.h"
       8             : #include "WrapperFactory.h"
       9             : #include "mozilla/OwningNonNull.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/Nullable.h"
      14             : #include "mozilla/dom/WorkerScope.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace WorkerDebuggerGlobalScopeBinding {
      20             : 
      21             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      22             :               "Can't inherit from an interface with a different ownership model.");
      23             : 
      24             : static bool
      25           0 : get_global(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, JSJitGetterCallArgs args)
      26             : {
      27           0 :   binding_detail::FastErrorResult rv;
      28           0 :   JS::Rooted<JSObject*> result(cx);
      29           0 :   self->GetGlobal(cx, &result, rv);
      30           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      31           0 :     return false;
      32             :   }
      33           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      34           0 :   JS::ExposeObjectToActiveJS(result);
      35           0 :   args.rval().setObject(*result);
      36           0 :   if (!MaybeWrapObjectValue(cx, args.rval())) {
      37           0 :     return false;
      38             :   }
      39           0 :   return true;
      40             : }
      41             : 
      42             : static const JSJitInfo global_getterinfo = {
      43             :   { (JSJitGetterOp)get_global },
      44             :   { prototypes::id::WorkerDebuggerGlobalScope },
      45             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
      46             :   JSJitInfo::Getter,
      47             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      48             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      49             :   false,  /* isInfallible. False in setters. */
      50             :   false,  /* isMovable.  Not relevant for setters. */
      51             :   false, /* isEliminatable.  Not relevant for setters. */
      52             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      53             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      54             :   false,  /* isTypedMethod.  Only relevant for methods. */
      55             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      56             : };
      57             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      58             : static_assert(0 < 1, "There is no slot for us");
      59             : 
      60             : static bool
      61           0 : createSandbox(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
      62             : {
      63           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
      64           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.createSandbox");
      65             :   }
      66           0 :   binding_detail::FakeString arg0;
      67           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
      68           0 :     return false;
      69             :   }
      70           0 :   JS::Rooted<JSObject*> arg1(cx);
      71           0 :   if (args[1].isObject()) {
      72           0 :     arg1 = &args[1].toObject();
      73             :   } else {
      74           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WorkerDebuggerGlobalScope.createSandbox");
      75           0 :     return false;
      76             :   }
      77           0 :   binding_detail::FastErrorResult rv;
      78           0 :   JS::Rooted<JSObject*> result(cx);
      79           0 :   self->CreateSandbox(cx, NonNullHelper(Constify(arg0)), arg1, &result, rv);
      80           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      81           0 :     return false;
      82             :   }
      83           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      84           0 :   JS::ExposeObjectToActiveJS(result);
      85           0 :   args.rval().setObject(*result);
      86           0 :   if (!MaybeWrapObjectValue(cx, args.rval())) {
      87           0 :     return false;
      88             :   }
      89           0 :   return true;
      90             : }
      91             : 
      92             : static const JSJitInfo createSandbox_methodinfo = {
      93             :   { (JSJitGetterOp)createSandbox },
      94             :   { prototypes::id::WorkerDebuggerGlobalScope },
      95             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
      96             :   JSJitInfo::Method,
      97             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      98             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      99             :   false,  /* isInfallible. False in setters. */
     100             :   false,  /* isMovable.  Not relevant for setters. */
     101             :   false, /* isEliminatable.  Not relevant for setters. */
     102             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     103             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     104             :   false,  /* isTypedMethod.  Only relevant for methods. */
     105             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     106             : };
     107             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     108             : static_assert(0 < 1, "There is no slot for us");
     109             : 
     110             : static bool
     111           0 : loadSubScript(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     112             : {
     113           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     114           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.loadSubScript");
     115             :   }
     116           0 :   binding_detail::FakeString arg0;
     117           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     118           0 :     return false;
     119             :   }
     120           0 :   Optional<JS::Handle<JSObject*>> arg1;
     121           0 :   if (args.hasDefined(1)) {
     122           0 :     arg1.Construct(cx);
     123           0 :     if (args[1].isObject()) {
     124           0 :       arg1.Value() = &args[1].toObject();
     125             :     } else {
     126           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WorkerDebuggerGlobalScope.loadSubScript");
     127           0 :       return false;
     128             :     }
     129             :   }
     130           0 :   binding_detail::FastErrorResult rv;
     131           0 :   self->LoadSubScript(cx, NonNullHelper(Constify(arg0)), Constify(arg1), rv);
     132           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     133           0 :     return false;
     134             :   }
     135           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     136           0 :   args.rval().setUndefined();
     137           0 :   return true;
     138             : }
     139             : 
     140             : static const JSJitInfo loadSubScript_methodinfo = {
     141             :   { (JSJitGetterOp)loadSubScript },
     142             :   { prototypes::id::WorkerDebuggerGlobalScope },
     143             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     144             :   JSJitInfo::Method,
     145             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     146             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     147             :   false,  /* isInfallible. False in setters. */
     148             :   false,  /* isMovable.  Not relevant for setters. */
     149             :   false, /* isEliminatable.  Not relevant for setters. */
     150             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     151             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     152             :   false,  /* isTypedMethod.  Only relevant for methods. */
     153             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     154             : };
     155             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     156             : static_assert(0 < 1, "There is no slot for us");
     157             : 
     158             : static bool
     159           0 : enterEventLoop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     160             : {
     161           0 :   self->EnterEventLoop();
     162           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     163           0 :   args.rval().setUndefined();
     164           0 :   return true;
     165             : }
     166             : 
     167             : static const JSJitInfo enterEventLoop_methodinfo = {
     168             :   { (JSJitGetterOp)enterEventLoop },
     169             :   { prototypes::id::WorkerDebuggerGlobalScope },
     170             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     171             :   JSJitInfo::Method,
     172             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     173             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     174             :   true,  /* isInfallible. False in setters. */
     175             :   false,  /* isMovable.  Not relevant for setters. */
     176             :   false, /* isEliminatable.  Not relevant for setters. */
     177             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     178             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     179             :   false,  /* isTypedMethod.  Only relevant for methods. */
     180             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     181             : };
     182             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     183             : static_assert(0 < 1, "There is no slot for us");
     184             : 
     185             : static bool
     186           0 : leaveEventLoop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     187             : {
     188           0 :   self->LeaveEventLoop();
     189           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     190           0 :   args.rval().setUndefined();
     191           0 :   return true;
     192             : }
     193             : 
     194             : static const JSJitInfo leaveEventLoop_methodinfo = {
     195             :   { (JSJitGetterOp)leaveEventLoop },
     196             :   { prototypes::id::WorkerDebuggerGlobalScope },
     197             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     198             :   JSJitInfo::Method,
     199             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     200             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     201             :   true,  /* isInfallible. False in setters. */
     202             :   false,  /* isMovable.  Not relevant for setters. */
     203             :   false, /* isEliminatable.  Not relevant for setters. */
     204             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     205             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     206             :   false,  /* isTypedMethod.  Only relevant for methods. */
     207             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     208             : };
     209             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     210             : static_assert(0 < 1, "There is no slot for us");
     211             : 
     212             : static bool
     213           0 : postMessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     214             : {
     215           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     216           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.postMessage");
     217             :   }
     218           0 :   binding_detail::FakeString arg0;
     219           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     220           0 :     return false;
     221             :   }
     222           0 :   self->PostMessage(NonNullHelper(Constify(arg0)));
     223           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     224           0 :   args.rval().setUndefined();
     225           0 :   return true;
     226             : }
     227             : 
     228             : static const JSJitInfo postMessage_methodinfo = {
     229             :   { (JSJitGetterOp)postMessage },
     230             :   { prototypes::id::WorkerDebuggerGlobalScope },
     231             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     232             :   JSJitInfo::Method,
     233             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     234             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     235             :   false,  /* isInfallible. False in setters. */
     236             :   false,  /* isMovable.  Not relevant for setters. */
     237             :   false, /* isEliminatable.  Not relevant for setters. */
     238             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     239             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     240             :   false,  /* isTypedMethod.  Only relevant for methods. */
     241             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     242             : };
     243             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     244             : static_assert(0 < 1, "There is no slot for us");
     245             : 
     246             : static bool
     247           0 : get_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, JSJitGetterCallArgs args)
     248             : {
     249           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnmessage());
     250           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     251           0 :   if (result) {
     252           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     253           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     254           0 :       return false;
     255             :     }
     256           0 :     return true;
     257             :   } else {
     258           0 :     args.rval().setNull();
     259           0 :     return true;
     260             :   }
     261             : }
     262             : 
     263             : static bool
     264           0 : set_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, JSJitSetterCallArgs args)
     265             : {
     266           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     267           0 :   if (args[0].isObject()) {
     268             :     { // scope for tempRoot
     269           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     270           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     271             :     }
     272             :   } else {
     273           0 :     arg0 = nullptr;
     274             :   }
     275           0 :   self->SetOnmessage(Constify(arg0));
     276           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     277             : 
     278           0 :   return true;
     279             : }
     280             : 
     281             : static const JSJitInfo onmessage_getterinfo = {
     282             :   { (JSJitGetterOp)get_onmessage },
     283             :   { prototypes::id::WorkerDebuggerGlobalScope },
     284             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     285             :   JSJitInfo::Getter,
     286             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     287             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     288             :   false,  /* isInfallible. False in setters. */
     289             :   false,  /* isMovable.  Not relevant for setters. */
     290             :   false, /* isEliminatable.  Not relevant for setters. */
     291             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     292             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     293             :   false,  /* isTypedMethod.  Only relevant for methods. */
     294             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     295             : };
     296             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     297             : static_assert(0 < 1, "There is no slot for us");
     298             : static const JSJitInfo onmessage_setterinfo = {
     299             :   { (JSJitGetterOp)set_onmessage },
     300             :   { prototypes::id::WorkerDebuggerGlobalScope },
     301             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     302             :   JSJitInfo::Setter,
     303             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     304             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     305             :   false,  /* isInfallible. False in setters. */
     306             :   false,  /* isMovable.  Not relevant for setters. */
     307             :   false, /* isEliminatable.  Not relevant for setters. */
     308             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     309             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     310             :   false,  /* isTypedMethod.  Only relevant for methods. */
     311             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     312             : };
     313             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     314             : static_assert(0 < 1, "There is no slot for us");
     315             : 
     316             : static bool
     317           0 : setImmediate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     318             : {
     319           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     320           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.setImmediate");
     321             :   }
     322           0 :   RootedCallback<OwningNonNull<binding_detail::FastFunction>> arg0(cx);
     323           0 :   if (args[0].isObject()) {
     324           0 :     if (JS::IsCallable(&args[0].toObject())) {
     325             :     { // scope for tempRoot
     326           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     327           0 :       arg0 = new binding_detail::FastFunction(tempRoot);
     328             :     }
     329             :     } else {
     330           0 :       ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of WorkerDebuggerGlobalScope.setImmediate");
     331           0 :       return false;
     332             :     }
     333             :   } else {
     334           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WorkerDebuggerGlobalScope.setImmediate");
     335           0 :     return false;
     336             :   }
     337           0 :   binding_detail::FastErrorResult rv;
     338           0 :   self->SetImmediate(NonNullHelper(arg0), rv);
     339           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     340           0 :     return false;
     341             :   }
     342           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     343           0 :   args.rval().setUndefined();
     344           0 :   return true;
     345             : }
     346             : 
     347             : static const JSJitInfo setImmediate_methodinfo = {
     348             :   { (JSJitGetterOp)setImmediate },
     349             :   { prototypes::id::WorkerDebuggerGlobalScope },
     350             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     351             :   JSJitInfo::Method,
     352             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     353             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     354             :   false,  /* isInfallible. False in setters. */
     355             :   false,  /* isMovable.  Not relevant for setters. */
     356             :   false, /* isEliminatable.  Not relevant for setters. */
     357             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     358             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     359             :   false,  /* isTypedMethod.  Only relevant for methods. */
     360             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     361             : };
     362             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     363             : static_assert(0 < 1, "There is no slot for us");
     364             : 
     365             : static bool
     366           0 : reportError(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     367             : {
     368           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     369           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.reportError");
     370             :   }
     371           0 :   binding_detail::FakeString arg0;
     372           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     373           0 :     return false;
     374             :   }
     375           0 :   self->ReportError(cx, NonNullHelper(Constify(arg0)));
     376           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     377           0 :   args.rval().setUndefined();
     378           0 :   return true;
     379             : }
     380             : 
     381             : static const JSJitInfo reportError_methodinfo = {
     382             :   { (JSJitGetterOp)reportError },
     383             :   { prototypes::id::WorkerDebuggerGlobalScope },
     384             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     385             :   JSJitInfo::Method,
     386             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     387             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     388             :   false,  /* isInfallible. False in setters. */
     389             :   false,  /* isMovable.  Not relevant for setters. */
     390             :   false, /* isEliminatable.  Not relevant for setters. */
     391             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     392             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     393             :   false,  /* isTypedMethod.  Only relevant for methods. */
     394             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     395             : };
     396             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     397             : static_assert(0 < 1, "There is no slot for us");
     398             : 
     399             : static bool
     400           0 : retrieveConsoleEvents(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     401             : {
     402           0 :   binding_detail::FastErrorResult rv;
     403           0 :   nsTArray<JS::Value> result;
     404           0 :   SequenceRooter<JS::Value > resultRooter(cx, &result);
     405           0 :   self->RetrieveConsoleEvents(cx, result, rv);
     406           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     407           0 :     return false;
     408             :   }
     409           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     410             : 
     411           0 :   uint32_t length = result.Length();
     412           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     413           0 :   if (!returnArray) {
     414           0 :     return false;
     415             :   }
     416             :   // Scope for 'tmp'
     417             :   {
     418           0 :     JS::Rooted<JS::Value> tmp(cx);
     419           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     420             :       // Control block to let us common up the JS_DefineElement calls when there
     421             :       // are different ways to succeed at wrapping the object.
     422             :       do {
     423           0 :         JS::ExposeValueToActiveJS(result[sequenceIdx0]);
     424           0 :         tmp.set(result[sequenceIdx0]);
     425           0 :         if (!MaybeWrapValue(cx, &tmp)) {
     426           0 :           return false;
     427             :         }
     428           0 :         break;
     429             :       } while (0);
     430           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     431             :                             JSPROP_ENUMERATE)) {
     432           0 :         return false;
     433             :       }
     434             :     }
     435             :   }
     436           0 :   args.rval().setObject(*returnArray);
     437           0 :   return true;
     438             : }
     439             : 
     440             : static const JSJitInfo retrieveConsoleEvents_methodinfo = {
     441             :   { (JSJitGetterOp)retrieveConsoleEvents },
     442             :   { prototypes::id::WorkerDebuggerGlobalScope },
     443             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     444             :   JSJitInfo::Method,
     445             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     446             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     447             :   false,  /* isInfallible. False in setters. */
     448             :   false,  /* isMovable.  Not relevant for setters. */
     449             :   false, /* isEliminatable.  Not relevant for setters. */
     450             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     451             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     452             :   false,  /* isTypedMethod.  Only relevant for methods. */
     453             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     454             : };
     455             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     456             : static_assert(0 < 1, "There is no slot for us");
     457             : 
     458             : static bool
     459           0 : setConsoleEventHandler(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     460             : {
     461           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     462           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope.setConsoleEventHandler");
     463             :   }
     464           0 :   RootedCallback<RefPtr<binding_detail::FastAnyCallback>> arg0(cx);
     465           0 :   if (args[0].isObject()) {
     466           0 :     if (JS::IsCallable(&args[0].toObject())) {
     467             :     { // scope for tempRoot
     468           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     469           0 :       arg0 = new binding_detail::FastAnyCallback(tempRoot);
     470             :     }
     471             :     } else {
     472           0 :       ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of WorkerDebuggerGlobalScope.setConsoleEventHandler");
     473           0 :       return false;
     474             :     }
     475           0 :   } else if (args[0].isNullOrUndefined()) {
     476           0 :     arg0 = nullptr;
     477             :   } else {
     478           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WorkerDebuggerGlobalScope.setConsoleEventHandler");
     479           0 :     return false;
     480             :   }
     481           0 :   binding_detail::FastErrorResult rv;
     482           0 :   self->SetConsoleEventHandler(cx, Constify(arg0), rv);
     483           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     484           0 :     return false;
     485             :   }
     486           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     487           0 :   args.rval().setUndefined();
     488           0 :   return true;
     489             : }
     490             : 
     491             : static const JSJitInfo setConsoleEventHandler_methodinfo = {
     492             :   { (JSJitGetterOp)setConsoleEventHandler },
     493             :   { prototypes::id::WorkerDebuggerGlobalScope },
     494             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     495             :   JSJitInfo::Method,
     496             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     497             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     498             :   false,  /* isInfallible. False in setters. */
     499             :   false,  /* isMovable.  Not relevant for setters. */
     500             :   false, /* isEliminatable.  Not relevant for setters. */
     501             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     502             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     503             :   false,  /* isTypedMethod.  Only relevant for methods. */
     504             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     505             : };
     506             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     507             : static_assert(0 < 1, "There is no slot for us");
     508             : 
     509             : static bool
     510           0 : dump(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerDebuggerGlobalScope* self, const JSJitMethodCallArgs& args)
     511             : {
     512           0 :   Optional<nsAString> arg0;
     513           0 :   binding_detail::FakeString arg0_holder;
     514           0 :   if (args.hasDefined(0)) {
     515           0 :     if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0_holder)) {
     516           0 :       return false;
     517             :     }
     518           0 :     arg0 = &arg0_holder;
     519             :   }
     520           0 :   self->Dump(cx, NonNullHelper(Constify(arg0)));
     521           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     522           0 :   args.rval().setUndefined();
     523           0 :   return true;
     524             : }
     525             : 
     526             : static const JSJitInfo dump_methodinfo = {
     527             :   { (JSJitGetterOp)dump },
     528             :   { prototypes::id::WorkerDebuggerGlobalScope },
     529             :   { PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth },
     530             :   JSJitInfo::Method,
     531             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     532             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     533             :   false,  /* isInfallible. False in setters. */
     534             :   false,  /* isMovable.  Not relevant for setters. */
     535             :   false, /* isEliminatable.  Not relevant for setters. */
     536             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     537             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     538             :   false,  /* isTypedMethod.  Only relevant for methods. */
     539             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     540             : };
     541             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     542             : static_assert(0 < 1, "There is no slot for us");
     543             : 
     544             : static bool
     545           0 : genericMethod(JSContext* cx, unsigned argc, JS::Value* vp)
     546             : {
     547           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     548           0 :   if (!args.thisv().isNullOrUndefined() && !args.thisv().isObject()) {
     549           0 :     return ThrowInvalidThis(cx, args, false, "WorkerDebuggerGlobalScope");
     550             :   }
     551           0 :   JS::Rooted<JSObject*> obj(cx, args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee()));
     552             : 
     553             :   mozilla::dom::WorkerDebuggerGlobalScope* self;
     554           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
     555             :   {
     556           0 :     nsresult rv = UnwrapObject<prototypes::id::WorkerDebuggerGlobalScope, mozilla::dom::WorkerDebuggerGlobalScope>(&rootSelf, self);
     557           0 :     if (NS_FAILED(rv)) {
     558           0 :       return ThrowInvalidThis(cx, args, rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "WorkerDebuggerGlobalScope");
     559             :     }
     560             :   }
     561           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
     562           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Method);
     563           0 :   JSJitMethodOp method = info->method;
     564           0 :   bool ok = method(cx, obj, self, JSJitMethodCallArgs(args));
     565             : #ifdef DEBUG
     566           0 :   if (ok) {
     567           0 :     AssertReturnTypeMatchesJitinfo(info, args.rval());
     568             :   }
     569             : #endif
     570           0 :   return ok;
     571             : }
     572             : 
     573             : static bool
     574           0 : genericGetter(JSContext* cx, unsigned argc, JS::Value* vp)
     575             : {
     576           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     577           0 :   if (!args.thisv().isNullOrUndefined() && !args.thisv().isObject()) {
     578           0 :     return ThrowInvalidThis(cx, args, false, "WorkerDebuggerGlobalScope");
     579             :   }
     580           0 :   JS::Rooted<JSObject*> obj(cx, args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee()));
     581             : 
     582             :   mozilla::dom::WorkerDebuggerGlobalScope* self;
     583           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
     584             :   {
     585           0 :     nsresult rv = UnwrapObject<prototypes::id::WorkerDebuggerGlobalScope, mozilla::dom::WorkerDebuggerGlobalScope>(&rootSelf, self);
     586           0 :     if (NS_FAILED(rv)) {
     587           0 :       return ThrowInvalidThis(cx, args, rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "WorkerDebuggerGlobalScope");
     588             :     }
     589             :   }
     590           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
     591           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Getter);
     592           0 :   JSJitGetterOp getter = info->getter;
     593           0 :   bool ok = getter(cx, obj, self, JSJitGetterCallArgs(args));
     594             : #ifdef DEBUG
     595           0 :   if (ok) {
     596           0 :     AssertReturnTypeMatchesJitinfo(info, args.rval());
     597             :   }
     598             : #endif
     599           0 :   return ok;
     600             : }
     601             : 
     602             : static bool
     603           0 : genericSetter(JSContext* cx, unsigned argc, JS::Value* vp)
     604             : {
     605           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     606           0 :   if (!args.thisv().isNullOrUndefined() && !args.thisv().isObject()) {
     607           0 :     return ThrowInvalidThis(cx, args, false, "WorkerDebuggerGlobalScope");
     608             :   }
     609           0 :   JS::Rooted<JSObject*> obj(cx, args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee()));
     610             : 
     611             :   mozilla::dom::WorkerDebuggerGlobalScope* self;
     612           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
     613             :   {
     614           0 :     nsresult rv = UnwrapObject<prototypes::id::WorkerDebuggerGlobalScope, mozilla::dom::WorkerDebuggerGlobalScope>(&rootSelf, self);
     615           0 :     if (NS_FAILED(rv)) {
     616           0 :       return ThrowInvalidThis(cx, args, rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "WorkerDebuggerGlobalScope");
     617             :     }
     618             :   }
     619           0 :   if (args.length() == 0) {
     620           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WorkerDebuggerGlobalScope attribute setter");
     621             :   }
     622           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
     623           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Setter);
     624           0 :   JSJitSetterOp setter = info->setter;
     625           0 :   if (!setter(cx, obj, self, JSJitSetterCallArgs(args))) {
     626           0 :     return false;
     627             :   }
     628           0 :   args.rval().setUndefined();
     629             : #ifdef DEBUG
     630           0 :   AssertReturnTypeMatchesJitinfo(info, args.rval());
     631             : #endif
     632           0 :   return true;
     633             : }
     634             : 
     635             : static void
     636           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     637             : {
     638           0 :   mozilla::dom::WorkerDebuggerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerDebuggerGlobalScope>(obj);
     639           0 :   if (self) {
     640           0 :     ClearWrapper(self, self, obj);
     641           0 :     mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj);
     642           0 :     AddForDeferredFinalization<mozilla::dom::WorkerDebuggerGlobalScope>(self);
     643             :   }
     644           0 : }
     645             : 
     646             : static void
     647           0 : _objectMoved(JSObject* obj, const JSObject* old)
     648             : {
     649           0 :   mozilla::dom::WorkerDebuggerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerDebuggerGlobalScope>(obj);
     650           0 :   if (self) {
     651           0 :     UpdateWrapper(self, self, obj, old);
     652             :   }
     653           0 : }
     654             : 
     655             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     656             : #if defined(__clang__)
     657             : #pragma clang diagnostic push
     658             : #pragma clang diagnostic ignored "-Wmissing-braces"
     659             : #endif
     660             : static const JSFunctionSpec sMethods_specs[] = {
     661             :   JS_FNSPEC("createSandbox", genericMethod, reinterpret_cast<const JSJitInfo*>(&createSandbox_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     662             :   JS_FNSPEC("loadSubScript", genericMethod, reinterpret_cast<const JSJitInfo*>(&loadSubScript_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     663             :   JS_FNSPEC("enterEventLoop", genericMethod, reinterpret_cast<const JSJitInfo*>(&enterEventLoop_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     664             :   JS_FNSPEC("leaveEventLoop", genericMethod, reinterpret_cast<const JSJitInfo*>(&leaveEventLoop_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     665             :   JS_FNSPEC("postMessage", genericMethod, reinterpret_cast<const JSJitInfo*>(&postMessage_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     666             :   JS_FNSPEC("setImmediate", genericMethod, reinterpret_cast<const JSJitInfo*>(&setImmediate_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     667             :   JS_FNSPEC("reportError", genericMethod, reinterpret_cast<const JSJitInfo*>(&reportError_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     668             :   JS_FNSPEC("retrieveConsoleEvents", genericMethod, reinterpret_cast<const JSJitInfo*>(&retrieveConsoleEvents_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     669             :   JS_FNSPEC("setConsoleEventHandler", genericMethod, reinterpret_cast<const JSJitInfo*>(&setConsoleEventHandler_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     670             :   JS_FNSPEC("dump", genericMethod, reinterpret_cast<const JSJitInfo*>(&dump_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     671             :   JS_FS_END
     672             : };
     673             : #if defined(__clang__)
     674             : #pragma clang diagnostic pop
     675             : #endif
     676             : 
     677             : 
     678             : // Can't be const because the pref-enabled boolean needs to be writable
     679             : static Prefable<const JSFunctionSpec> sMethods[] = {
     680             :   { nullptr, &sMethods_specs[0] },
     681             :   { nullptr, nullptr }
     682             : };
     683             : 
     684             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     685             : #if defined(__clang__)
     686             : #pragma clang diagnostic push
     687             : #pragma clang diagnostic ignored "-Wmissing-braces"
     688             : #endif
     689             : static const JSPropertySpec sAttributes_specs[] = {
     690             :   { "global", JSPROP_SHARED | JSPROP_ENUMERATE, genericGetter, &global_getterinfo, nullptr, nullptr },
     691             :   { "onmessage", JSPROP_SHARED | JSPROP_ENUMERATE, genericGetter, &onmessage_getterinfo, genericSetter, &onmessage_setterinfo },
     692             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     693             : };
     694             : #if defined(__clang__)
     695             : #pragma clang diagnostic pop
     696             : #endif
     697             : 
     698             : 
     699             : // Can't be const because the pref-enabled boolean needs to be writable
     700             : static Prefable<const JSPropertySpec> sAttributes[] = {
     701             :   { nullptr, &sAttributes_specs[0] },
     702             :   { nullptr, nullptr }
     703             : };
     704             : 
     705             : 
     706             : static const NativePropertiesN<2> sNativeProperties = {
     707             :   false, 0,
     708             :   false, 0,
     709             :   true,  0 /* sMethods */,
     710             :   true,  1 /* sAttributes */,
     711             :   false, 0,
     712             :   false, 0,
     713             :   false, 0,
     714             :   -1,
     715             :   0,
     716             :   nullptr,
     717             :   {
     718             :     { sMethods, nullptr },
     719             :     { sAttributes, nullptr }
     720             :   }
     721             : };
     722             : 
     723             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     724             :   {
     725             :     "Function",
     726             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     727             :     &sBoringInterfaceObjectClassClassOps,
     728             :     JS_NULL_CLASS_SPEC,
     729             :     JS_NULL_CLASS_EXT,
     730             :     &sInterfaceObjectClassObjectOps
     731             :   },
     732             :   eInterface,
     733             :   true,
     734             :   prototypes::id::WorkerDebuggerGlobalScope,
     735             :   PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth,
     736             :   &sEmptyNativePropertyHooks,
     737             :   "function WorkerDebuggerGlobalScope() {\n    [native code]\n}",
     738             :   EventTargetBinding::GetConstructorObject
     739             : };
     740             : 
     741             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     742             :   {
     743             :     "WorkerDebuggerGlobalScopePrototype",
     744             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     745             :     JS_NULL_CLASS_OPS,
     746             :     JS_NULL_CLASS_SPEC,
     747             :     JS_NULL_CLASS_EXT,
     748             :     JS_NULL_OBJECT_OPS
     749             :   },
     750             :   eGlobalInterfacePrototype,
     751             :   false,
     752             :   prototypes::id::WorkerDebuggerGlobalScope,
     753             :   PrototypeTraits<prototypes::id::WorkerDebuggerGlobalScope>::Depth,
     754             :   &sEmptyNativePropertyHooks,
     755             :   "[object WorkerDebuggerGlobalScopePrototype]",
     756             :   EventTargetBinding::GetProtoObject
     757             : };
     758             : 
     759             : static const js::ClassOps sClassOps = {
     760             :   nullptr, /* addProperty */
     761             :   nullptr,               /* delProperty */
     762             :   nullptr,               /* getProperty */
     763             :   nullptr,               /* setProperty */
     764             :   nullptr,               /* enumerate */
     765             :   mozilla::dom::EnumerateGlobal, /* newEnumerate */
     766             :   mozilla::dom::ResolveGlobal, /* resolve */
     767             :   mozilla::dom::MayResolveGlobal, /* mayResolve */
     768             :   _finalize, /* finalize */
     769             :   nullptr, /* call */
     770             :   nullptr,               /* hasInstance */
     771             :   nullptr,               /* construct */
     772             :   JS_GlobalObjectTraceHook, /* trace */
     773             : };
     774             : 
     775             : static const js::ClassExtension sClassExtension = {
     776             :   nullptr, /* weakmapKeyDelegateOp */
     777             :   _objectMoved /* objectMovedOp */
     778             : };
     779             : 
     780             : static const DOMJSClass sClass = {
     781             :   { "WorkerDebuggerGlobalScope",
     782             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
     783             :     &sClassOps,
     784             :     JS_NULL_CLASS_SPEC,
     785             :     &sClassExtension,
     786             :     JS_NULL_OBJECT_OPS
     787             :   },
     788             :   { prototypes::id::EventTarget, prototypes::id::WorkerDebuggerGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     789             :   IsBaseOf<nsISupports, mozilla::dom::WorkerDebuggerGlobalScope >::value,
     790             :   &sEmptyNativePropertyHooks,
     791             :   FindAssociatedGlobalForNative<mozilla::dom::WorkerDebuggerGlobalScope>::Get,
     792             :   GetProtoObjectHandle,
     793             :   GetCCParticipant<mozilla::dom::WorkerDebuggerGlobalScope>::Get()
     794             : };
     795             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     796             :               "Must have the right minimal number of reserved slots.");
     797             : static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1,
     798             :               "Must have enough reserved slots.");
     799             : 
     800             : const JSClass*
     801           0 : GetJSClass()
     802             : {
     803           0 :   return sClass.ToJSClass();
     804             : }
     805             : 
     806             : bool
     807           0 : Wrap(JSContext* aCx, mozilla::dom::WorkerDebuggerGlobalScope* aObject, nsWrapperCache* aCache, JS::CompartmentOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector)
     808             : {
     809             :   MOZ_ASSERT(static_cast<mozilla::dom::WorkerDebuggerGlobalScope*>(aObject) ==
     810             :              reinterpret_cast<mozilla::dom::WorkerDebuggerGlobalScope*>(aObject),
     811             :              "Multiple inheritance for mozilla::dom::WorkerDebuggerGlobalScope is broken.");
     812             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     813             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     814             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     815           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     816           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     817             :              "nsISupports must be on our primary inheritance chain");
     818             : 
     819           0 :   if (!CreateGlobal<mozilla::dom::WorkerDebuggerGlobalScope, GetProtoObjectHandle>(aCx,
     820             :                                    aObject,
     821             :                                    aCache,
     822             :                                    sClass.ToJSClass(),
     823             :                                    aOptions,
     824             :                                    aPrincipal,
     825             :                                    aInitStandardClasses,
     826             :                                    aReflector)) {
     827           0 :     aCache->ReleaseWrapper(aObject);
     828           0 :     aCache->ClearWrapper();
     829           0 :     return false;
     830             :   }
     831             : 
     832             :   // aReflector is a new global, so has a new compartment.  Enter it
     833             :   // before doing anything with it.
     834           0 :   JSAutoCompartment ac(aCx, aReflector);
     835             : 
     836           0 :   if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) {
     837           0 :     aCache->ReleaseWrapper(aObject);
     838           0 :     aCache->ClearWrapper();
     839           0 :     return false;
     840             :   }
     841             : 
     842             : 
     843           0 :   return true;
     844             : }
     845             : 
     846             : void
     847           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     848             : {
     849           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     850           0 :   if (!parentProto) {
     851           0 :     return;
     852             :   }
     853             : 
     854           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     855           0 :   if (!constructorProto) {
     856           0 :     return;
     857             :   }
     858             : 
     859           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkerDebuggerGlobalScope);
     860           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WorkerDebuggerGlobalScope);
     861           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     862             :                               &sPrototypeClass.mBase, protoCache,
     863             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     864             :                               interfaceCache,
     865             :                               sNativeProperties.Upcast(),
     866             :                               nullptr,
     867             :                               "WorkerDebuggerGlobalScope", aDefineOnGlobal,
     868             :                               nullptr,
     869           0 :                               true);
     870             : 
     871           0 :   if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkerDebuggerGlobalScope)) {
     872             :     bool succeeded;
     873           0 :     JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
     874           0 :     if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
     875           0 :       *protoCache = nullptr;
     876           0 :       if (interfaceCache) {
     877           0 :         *interfaceCache = nullptr;
     878             :       }
     879           0 :       return;
     880             :     }
     881             : 
     882           0 :     MOZ_ASSERT(succeeded,
     883             :                "making a fresh prototype object's [[Prototype]] "
     884             :                "immutable can internally fail, but it should "
     885             :                "never be unsuccessful");
     886             :   }
     887             : }
     888             : 
     889             : JS::Handle<JSObject*>
     890           0 : GetProtoObjectHandle(JSContext* aCx)
     891             : {
     892             :   /* Get the interface prototype object for this class.  This will create the
     893             :      object as needed. */
     894           0 :   bool aDefineOnGlobal = true;
     895             : 
     896             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     897           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     898           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     899           0 :     return nullptr;
     900             :   }
     901             : 
     902             :   /* Check to see whether the interface objects are already installed */
     903           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     904           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::WorkerDebuggerGlobalScope)) {
     905           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     906           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     907             :   }
     908             : 
     909             :   /*
     910             :    * The object might _still_ be null, but that's OK.
     911             :    *
     912             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     913             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     914             :    * changed after they have been set.
     915             :    *
     916             :    * Calling address() avoids the read read barrier that does gray
     917             :    * unmarking, but it's not possible for the object to be gray here.
     918             :    */
     919             : 
     920           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::WorkerDebuggerGlobalScope);
     921           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     922           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     923             : }
     924             : 
     925             : JS::Handle<JSObject*>
     926           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     927             : {
     928             :   /* Get the interface object for this class.  This will create the object as
     929             :      needed. */
     930             : 
     931             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     932           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     933           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     934           0 :     return nullptr;
     935             :   }
     936             : 
     937             :   /* Check to see whether the interface objects are already installed */
     938           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     939           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::WorkerDebuggerGlobalScope)) {
     940           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     941           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     942             :   }
     943             : 
     944             :   /*
     945             :    * The object might _still_ be null, but that's OK.
     946             :    *
     947             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     948             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     949             :    * changed after they have been set.
     950             :    *
     951             :    * Calling address() avoids the read read barrier that does gray
     952             :    * unmarking, but it's not possible for the object to be gray here.
     953             :    */
     954             : 
     955           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::WorkerDebuggerGlobalScope);
     956           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     957           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     958             : }
     959             : 
     960             : JSObject*
     961           0 : GetConstructorObject(JSContext* aCx)
     962             : {
     963           0 :   return GetConstructorObjectHandle(aCx);
     964             : }
     965             : 
     966             : } // namespace WorkerDebuggerGlobalScopeBinding
     967             : 
     968             : 
     969             : 
     970             : } // namespace dom
     971             : } // namespace mozilla

Generated by: LCOV version 1.13