LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - URLBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 93 479 19.4 %
Date: 2017-07-14 16:53:18 Functions: 7 38 18.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM URL.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMMediaStream.h"
       4             : #include "URLBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/Blob.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/MediaSource.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/Nullable.h"
      13             : #include "mozilla/dom/PrimitiveConversions.h"
      14             : #include "mozilla/dom/URL.h"
      15             : #include "mozilla/dom/URLSearchParams.h"
      16             : #include "mozilla/dom/XrayExpandoClass.h"
      17             : #include "nsContentUtils.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace URLBinding {
      23             : 
      24             : static bool
      25           0 : __stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, const JSJitMethodCallArgs& args)
      26             : {
      27           0 :   binding_detail::FastErrorResult rv;
      28           0 :   DOMString result;
      29           0 :   self->Stringify(result, rv);
      30           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      31           0 :     return false;
      32             :   }
      33           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      34           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      35           0 :     return false;
      36             :   }
      37           0 :   return true;
      38             : }
      39             : 
      40             : static const JSJitInfo __stringifier_methodinfo = {
      41             :   { (JSJitGetterOp)__stringifier },
      42             :   { prototypes::id::URL },
      43             :   { PrototypeTraits<prototypes::id::URL>::Depth },
      44             :   JSJitInfo::Method,
      45             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      46             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      47             :   false,  /* isInfallible. False in setters. */
      48             :   false,  /* isMovable.  Not relevant for setters. */
      49             :   false, /* isEliminatable.  Not relevant for setters. */
      50             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      51             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      52             :   false,  /* isTypedMethod.  Only relevant for methods. */
      53             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      54             : };
      55             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      56             : static_assert(0 < 1, "There is no slot for us");
      57             : 
      58             : static bool
      59           1 : get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
      60             : {
      61           2 :   binding_detail::FastErrorResult rv;
      62           2 :   DOMString result;
      63           1 :   self->GetHref(result, rv);
      64           1 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      65           0 :     return false;
      66             :   }
      67           1 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      68           1 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      69           0 :     return false;
      70             :   }
      71           1 :   return true;
      72             : }
      73             : 
      74             : static bool
      75           0 : set_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
      76             : {
      77           0 :   binding_detail::FakeString arg0;
      78           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
      79           0 :     return false;
      80             :   }
      81           0 :   NormalizeUSVString(arg0);
      82           0 :   binding_detail::FastErrorResult rv;
      83           0 :   self->SetHref(Constify(arg0), rv);
      84           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      85           0 :     return false;
      86             :   }
      87           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      88             : 
      89           0 :   return true;
      90             : }
      91             : 
      92             : static const JSJitInfo href_getterinfo = {
      93             :   { (JSJitGetterOp)get_href },
      94             :   { prototypes::id::URL },
      95             :   { PrototypeTraits<prototypes::id::URL>::Depth },
      96             :   JSJitInfo::Getter,
      97             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      98             :   JSVAL_TYPE_STRING,  /* 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             : static const JSJitInfo href_setterinfo = {
     110             :   { (JSJitGetterOp)set_href },
     111             :   { prototypes::id::URL },
     112             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     113             :   JSJitInfo::Setter,
     114             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     115             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     116             :   false,  /* isInfallible. False in setters. */
     117             :   false,  /* isMovable.  Not relevant for setters. */
     118             :   false, /* isEliminatable.  Not relevant for setters. */
     119             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     120             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     121             :   false,  /* isTypedMethod.  Only relevant for methods. */
     122             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     123             : };
     124             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     125             : static_assert(0 < 1, "There is no slot for us");
     126             : 
     127             : static bool
     128           0 : get_origin(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     129             : {
     130           0 :   binding_detail::FastErrorResult rv;
     131           0 :   DOMString result;
     132           0 :   self->GetOrigin(result, rv);
     133           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     134           0 :     return false;
     135             :   }
     136           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     137           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     138           0 :     return false;
     139             :   }
     140           0 :   return true;
     141             : }
     142             : 
     143             : static const JSJitInfo origin_getterinfo = {
     144             :   { (JSJitGetterOp)get_origin },
     145             :   { prototypes::id::URL },
     146             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     147             :   JSJitInfo::Getter,
     148             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     149             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     150             :   false,  /* isInfallible. False in setters. */
     151             :   false,  /* isMovable.  Not relevant for setters. */
     152             :   false, /* isEliminatable.  Not relevant for setters. */
     153             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     154             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     155             :   false,  /* isTypedMethod.  Only relevant for methods. */
     156             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     157             : };
     158             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     159             : static_assert(0 < 1, "There is no slot for us");
     160             : 
     161             : static bool
     162           0 : get_protocol(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     163             : {
     164           0 :   binding_detail::FastErrorResult rv;
     165           0 :   DOMString result;
     166           0 :   self->GetProtocol(result, rv);
     167           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     168           0 :     return false;
     169             :   }
     170           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     171           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     172           0 :     return false;
     173             :   }
     174           0 :   return true;
     175             : }
     176             : 
     177             : static bool
     178           0 : set_protocol(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     179             : {
     180           0 :   binding_detail::FakeString arg0;
     181           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     182           0 :     return false;
     183             :   }
     184           0 :   NormalizeUSVString(arg0);
     185           0 :   binding_detail::FastErrorResult rv;
     186           0 :   self->SetProtocol(Constify(arg0), rv);
     187           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     188           0 :     return false;
     189             :   }
     190           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     191             : 
     192           0 :   return true;
     193             : }
     194             : 
     195             : static const JSJitInfo protocol_getterinfo = {
     196             :   { (JSJitGetterOp)get_protocol },
     197             :   { prototypes::id::URL },
     198             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     199             :   JSJitInfo::Getter,
     200             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     201             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     202             :   false,  /* isInfallible. False in setters. */
     203             :   false,  /* isMovable.  Not relevant for setters. */
     204             :   false, /* isEliminatable.  Not relevant for setters. */
     205             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     206             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     207             :   false,  /* isTypedMethod.  Only relevant for methods. */
     208             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     209             : };
     210             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     211             : static_assert(0 < 1, "There is no slot for us");
     212             : static const JSJitInfo protocol_setterinfo = {
     213             :   { (JSJitGetterOp)set_protocol },
     214             :   { prototypes::id::URL },
     215             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     216             :   JSJitInfo::Setter,
     217             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     218             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     219             :   false,  /* isInfallible. False in setters. */
     220             :   false,  /* isMovable.  Not relevant for setters. */
     221             :   false, /* isEliminatable.  Not relevant for setters. */
     222             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     223             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     224             :   false,  /* isTypedMethod.  Only relevant for methods. */
     225             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     226             : };
     227             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     228             : static_assert(0 < 1, "There is no slot for us");
     229             : 
     230             : static bool
     231           0 : get_username(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     232             : {
     233           0 :   binding_detail::FastErrorResult rv;
     234           0 :   DOMString result;
     235           0 :   self->GetUsername(result, rv);
     236           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     237           0 :     return false;
     238             :   }
     239           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     240           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     241           0 :     return false;
     242             :   }
     243           0 :   return true;
     244             : }
     245             : 
     246             : static bool
     247           0 : set_username(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     248             : {
     249           0 :   binding_detail::FakeString arg0;
     250           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     251           0 :     return false;
     252             :   }
     253           0 :   NormalizeUSVString(arg0);
     254           0 :   binding_detail::FastErrorResult rv;
     255           0 :   self->SetUsername(Constify(arg0), rv);
     256           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     257           0 :     return false;
     258             :   }
     259           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     260             : 
     261           0 :   return true;
     262             : }
     263             : 
     264             : static const JSJitInfo username_getterinfo = {
     265             :   { (JSJitGetterOp)get_username },
     266             :   { prototypes::id::URL },
     267             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     268             :   JSJitInfo::Getter,
     269             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     270             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     271             :   false,  /* isInfallible. False in setters. */
     272             :   false,  /* isMovable.  Not relevant for setters. */
     273             :   false, /* isEliminatable.  Not relevant for setters. */
     274             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     275             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     276             :   false,  /* isTypedMethod.  Only relevant for methods. */
     277             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     278             : };
     279             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     280             : static_assert(0 < 1, "There is no slot for us");
     281             : static const JSJitInfo username_setterinfo = {
     282             :   { (JSJitGetterOp)set_username },
     283             :   { prototypes::id::URL },
     284             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     285             :   JSJitInfo::Setter,
     286             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     287             :   JSVAL_TYPE_UNDEFINED,  /* 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             : 
     299             : static bool
     300           0 : get_password(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     301             : {
     302           0 :   binding_detail::FastErrorResult rv;
     303           0 :   DOMString result;
     304           0 :   self->GetPassword(result, rv);
     305           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     306           0 :     return false;
     307             :   }
     308           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     309           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     310           0 :     return false;
     311             :   }
     312           0 :   return true;
     313             : }
     314             : 
     315             : static bool
     316           0 : set_password(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     317             : {
     318           0 :   binding_detail::FakeString arg0;
     319           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     320           0 :     return false;
     321             :   }
     322           0 :   NormalizeUSVString(arg0);
     323           0 :   binding_detail::FastErrorResult rv;
     324           0 :   self->SetPassword(Constify(arg0), rv);
     325           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     326           0 :     return false;
     327             :   }
     328           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     329             : 
     330           0 :   return true;
     331             : }
     332             : 
     333             : static const JSJitInfo password_getterinfo = {
     334             :   { (JSJitGetterOp)get_password },
     335             :   { prototypes::id::URL },
     336             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     337             :   JSJitInfo::Getter,
     338             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     339             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     340             :   false,  /* isInfallible. False in setters. */
     341             :   false,  /* isMovable.  Not relevant for setters. */
     342             :   false, /* isEliminatable.  Not relevant for setters. */
     343             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     344             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     345             :   false,  /* isTypedMethod.  Only relevant for methods. */
     346             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     347             : };
     348             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     349             : static_assert(0 < 1, "There is no slot for us");
     350             : static const JSJitInfo password_setterinfo = {
     351             :   { (JSJitGetterOp)set_password },
     352             :   { prototypes::id::URL },
     353             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     354             :   JSJitInfo::Setter,
     355             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     356             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     357             :   false,  /* isInfallible. False in setters. */
     358             :   false,  /* isMovable.  Not relevant for setters. */
     359             :   false, /* isEliminatable.  Not relevant for setters. */
     360             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     361             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     362             :   false,  /* isTypedMethod.  Only relevant for methods. */
     363             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     364             : };
     365             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     366             : static_assert(0 < 1, "There is no slot for us");
     367             : 
     368             : static bool
     369           0 : get_host(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     370             : {
     371           0 :   binding_detail::FastErrorResult rv;
     372           0 :   DOMString result;
     373           0 :   self->GetHost(result, rv);
     374           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     375           0 :     return false;
     376             :   }
     377           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     378           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     379           0 :     return false;
     380             :   }
     381           0 :   return true;
     382             : }
     383             : 
     384             : static bool
     385           0 : set_host(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     386             : {
     387           0 :   binding_detail::FakeString arg0;
     388           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     389           0 :     return false;
     390             :   }
     391           0 :   NormalizeUSVString(arg0);
     392           0 :   binding_detail::FastErrorResult rv;
     393           0 :   self->SetHost(Constify(arg0), rv);
     394           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     395           0 :     return false;
     396             :   }
     397           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     398             : 
     399           0 :   return true;
     400             : }
     401             : 
     402             : static const JSJitInfo host_getterinfo = {
     403             :   { (JSJitGetterOp)get_host },
     404             :   { prototypes::id::URL },
     405             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     406             :   JSJitInfo::Getter,
     407             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     408             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     409             :   false,  /* isInfallible. False in setters. */
     410             :   false,  /* isMovable.  Not relevant for setters. */
     411             :   false, /* isEliminatable.  Not relevant for setters. */
     412             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     413             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     414             :   false,  /* isTypedMethod.  Only relevant for methods. */
     415             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     416             : };
     417             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     418             : static_assert(0 < 1, "There is no slot for us");
     419             : static const JSJitInfo host_setterinfo = {
     420             :   { (JSJitGetterOp)set_host },
     421             :   { prototypes::id::URL },
     422             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     423             :   JSJitInfo::Setter,
     424             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     425             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     426             :   false,  /* isInfallible. False in setters. */
     427             :   false,  /* isMovable.  Not relevant for setters. */
     428             :   false, /* isEliminatable.  Not relevant for setters. */
     429             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     430             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     431             :   false,  /* isTypedMethod.  Only relevant for methods. */
     432             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     433             : };
     434             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     435             : static_assert(0 < 1, "There is no slot for us");
     436             : 
     437             : static bool
     438           0 : get_hostname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     439             : {
     440           0 :   binding_detail::FastErrorResult rv;
     441           0 :   DOMString result;
     442           0 :   self->GetHostname(result, rv);
     443           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     444           0 :     return false;
     445             :   }
     446           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     447           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     448           0 :     return false;
     449             :   }
     450           0 :   return true;
     451             : }
     452             : 
     453             : static bool
     454           0 : set_hostname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     455             : {
     456           0 :   binding_detail::FakeString arg0;
     457           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     458           0 :     return false;
     459             :   }
     460           0 :   NormalizeUSVString(arg0);
     461           0 :   binding_detail::FastErrorResult rv;
     462           0 :   self->SetHostname(Constify(arg0), rv);
     463           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     464           0 :     return false;
     465             :   }
     466           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     467             : 
     468           0 :   return true;
     469             : }
     470             : 
     471             : static const JSJitInfo hostname_getterinfo = {
     472             :   { (JSJitGetterOp)get_hostname },
     473             :   { prototypes::id::URL },
     474             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     475             :   JSJitInfo::Getter,
     476             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     477             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     478             :   false,  /* isInfallible. False in setters. */
     479             :   false,  /* isMovable.  Not relevant for setters. */
     480             :   false, /* isEliminatable.  Not relevant for setters. */
     481             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     482             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     483             :   false,  /* isTypedMethod.  Only relevant for methods. */
     484             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     485             : };
     486             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     487             : static_assert(0 < 1, "There is no slot for us");
     488             : static const JSJitInfo hostname_setterinfo = {
     489             :   { (JSJitGetterOp)set_hostname },
     490             :   { prototypes::id::URL },
     491             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     492             :   JSJitInfo::Setter,
     493             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     494             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     495             :   false,  /* isInfallible. False in setters. */
     496             :   false,  /* isMovable.  Not relevant for setters. */
     497             :   false, /* isEliminatable.  Not relevant for setters. */
     498             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     499             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     500             :   false,  /* isTypedMethod.  Only relevant for methods. */
     501             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     502             : };
     503             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     504             : static_assert(0 < 1, "There is no slot for us");
     505             : 
     506             : static bool
     507           0 : get_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     508             : {
     509           0 :   binding_detail::FastErrorResult rv;
     510           0 :   DOMString result;
     511           0 :   self->GetPort(result, rv);
     512           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     513           0 :     return false;
     514             :   }
     515           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     516           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     517           0 :     return false;
     518             :   }
     519           0 :   return true;
     520             : }
     521             : 
     522             : static bool
     523           0 : set_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     524             : {
     525           0 :   binding_detail::FakeString arg0;
     526           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     527           0 :     return false;
     528             :   }
     529           0 :   NormalizeUSVString(arg0);
     530           0 :   binding_detail::FastErrorResult rv;
     531           0 :   self->SetPort(Constify(arg0), rv);
     532           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     533           0 :     return false;
     534             :   }
     535           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     536             : 
     537           0 :   return true;
     538             : }
     539             : 
     540             : static const JSJitInfo port_getterinfo = {
     541             :   { (JSJitGetterOp)get_port },
     542             :   { prototypes::id::URL },
     543             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     544             :   JSJitInfo::Getter,
     545             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     546             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     547             :   false,  /* isInfallible. False in setters. */
     548             :   false,  /* isMovable.  Not relevant for setters. */
     549             :   false, /* isEliminatable.  Not relevant for setters. */
     550             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     551             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     552             :   false,  /* isTypedMethod.  Only relevant for methods. */
     553             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     554             : };
     555             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     556             : static_assert(0 < 1, "There is no slot for us");
     557             : static const JSJitInfo port_setterinfo = {
     558             :   { (JSJitGetterOp)set_port },
     559             :   { prototypes::id::URL },
     560             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     561             :   JSJitInfo::Setter,
     562             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     563             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     564             :   false,  /* isInfallible. False in setters. */
     565             :   false,  /* isMovable.  Not relevant for setters. */
     566             :   false, /* isEliminatable.  Not relevant for setters. */
     567             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     568             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     569             :   false,  /* isTypedMethod.  Only relevant for methods. */
     570             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     571             : };
     572             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     573             : static_assert(0 < 1, "There is no slot for us");
     574             : 
     575             : static bool
     576           0 : get_pathname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     577             : {
     578           0 :   binding_detail::FastErrorResult rv;
     579           0 :   DOMString result;
     580           0 :   self->GetPathname(result, rv);
     581           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     582           0 :     return false;
     583             :   }
     584           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     585           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     586           0 :     return false;
     587             :   }
     588           0 :   return true;
     589             : }
     590             : 
     591             : static bool
     592           0 : set_pathname(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     593             : {
     594           0 :   binding_detail::FakeString arg0;
     595           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     596           0 :     return false;
     597             :   }
     598           0 :   NormalizeUSVString(arg0);
     599           0 :   binding_detail::FastErrorResult rv;
     600           0 :   self->SetPathname(Constify(arg0), rv);
     601           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     602           0 :     return false;
     603             :   }
     604           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     605             : 
     606           0 :   return true;
     607             : }
     608             : 
     609             : static const JSJitInfo pathname_getterinfo = {
     610             :   { (JSJitGetterOp)get_pathname },
     611             :   { prototypes::id::URL },
     612             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     613             :   JSJitInfo::Getter,
     614             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     615             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     616             :   false,  /* isInfallible. False in setters. */
     617             :   false,  /* isMovable.  Not relevant for setters. */
     618             :   false, /* isEliminatable.  Not relevant for setters. */
     619             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     620             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     621             :   false,  /* isTypedMethod.  Only relevant for methods. */
     622             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     623             : };
     624             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     625             : static_assert(0 < 1, "There is no slot for us");
     626             : static const JSJitInfo pathname_setterinfo = {
     627             :   { (JSJitGetterOp)set_pathname },
     628             :   { prototypes::id::URL },
     629             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     630             :   JSJitInfo::Setter,
     631             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     632             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     633             :   false,  /* isInfallible. False in setters. */
     634             :   false,  /* isMovable.  Not relevant for setters. */
     635             :   false, /* isEliminatable.  Not relevant for setters. */
     636             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     637             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     638             :   false,  /* isTypedMethod.  Only relevant for methods. */
     639             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     640             : };
     641             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     642             : static_assert(0 < 1, "There is no slot for us");
     643             : 
     644             : static bool
     645           0 : get_search(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     646             : {
     647           0 :   binding_detail::FastErrorResult rv;
     648           0 :   DOMString result;
     649           0 :   self->GetSearch(result, rv);
     650           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     651           0 :     return false;
     652             :   }
     653           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     654           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     655           0 :     return false;
     656             :   }
     657           0 :   return true;
     658             : }
     659             : 
     660             : static bool
     661           0 : set_search(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     662             : {
     663           0 :   binding_detail::FakeString arg0;
     664           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     665           0 :     return false;
     666             :   }
     667           0 :   NormalizeUSVString(arg0);
     668           0 :   binding_detail::FastErrorResult rv;
     669           0 :   self->SetSearch(Constify(arg0), rv);
     670           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     671           0 :     return false;
     672             :   }
     673           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     674             : 
     675           0 :   return true;
     676             : }
     677             : 
     678             : static const JSJitInfo search_getterinfo = {
     679             :   { (JSJitGetterOp)get_search },
     680             :   { prototypes::id::URL },
     681             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     682             :   JSJitInfo::Getter,
     683             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     684             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     685             :   false,  /* isInfallible. False in setters. */
     686             :   false,  /* isMovable.  Not relevant for setters. */
     687             :   false, /* isEliminatable.  Not relevant for setters. */
     688             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     689             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     690             :   false,  /* isTypedMethod.  Only relevant for methods. */
     691             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     692             : };
     693             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     694             : static_assert(0 < 1, "There is no slot for us");
     695             : static const JSJitInfo search_setterinfo = {
     696             :   { (JSJitGetterOp)set_search },
     697             :   { prototypes::id::URL },
     698             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     699             :   JSJitInfo::Setter,
     700             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     701             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     702             :   false,  /* isInfallible. False in setters. */
     703             :   false,  /* isMovable.  Not relevant for setters. */
     704             :   false, /* isEliminatable.  Not relevant for setters. */
     705             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     706             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     707             :   false,  /* isTypedMethod.  Only relevant for methods. */
     708             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     709             : };
     710             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     711             : static_assert(0 < 1, "There is no slot for us");
     712             : 
     713             : static bool
     714           0 : get_searchParams(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     715             : {
     716           0 :   auto result(StrongOrRawPtr<mozilla::dom::URLSearchParams>(self->SearchParams()));
     717           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     718           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     719           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     720           0 :     return false;
     721             :   }
     722           0 :   return true;
     723             : }
     724             : 
     725             : static const JSJitInfo searchParams_getterinfo = {
     726             :   { (JSJitGetterOp)get_searchParams },
     727             :   { prototypes::id::URL },
     728             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     729             :   JSJitInfo::Getter,
     730             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     731             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     732             :   false,  /* isInfallible. False in setters. */
     733             :   true,  /* isMovable.  Not relevant for setters. */
     734             :   true, /* isEliminatable.  Not relevant for setters. */
     735             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     736             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     737             :   false,  /* isTypedMethod.  Only relevant for methods. */
     738             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     739             : };
     740             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     741             : static_assert(0 < 1, "There is no slot for us");
     742             : 
     743             : static bool
     744           0 : get_hash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitGetterCallArgs args)
     745             : {
     746           0 :   binding_detail::FastErrorResult rv;
     747           0 :   DOMString result;
     748           0 :   self->GetHash(result, rv);
     749           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     750           0 :     return false;
     751             :   }
     752           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     753           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     754           0 :     return false;
     755             :   }
     756           0 :   return true;
     757             : }
     758             : 
     759             : static bool
     760           0 : set_hash(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, JSJitSetterCallArgs args)
     761             : {
     762           0 :   binding_detail::FakeString arg0;
     763           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     764           0 :     return false;
     765             :   }
     766           0 :   NormalizeUSVString(arg0);
     767           0 :   binding_detail::FastErrorResult rv;
     768           0 :   self->SetHash(Constify(arg0), rv);
     769           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     770           0 :     return false;
     771             :   }
     772           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     773             : 
     774           0 :   return true;
     775             : }
     776             : 
     777             : static const JSJitInfo hash_getterinfo = {
     778             :   { (JSJitGetterOp)get_hash },
     779             :   { prototypes::id::URL },
     780             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     781             :   JSJitInfo::Getter,
     782             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     783             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     784             :   false,  /* isInfallible. False in setters. */
     785             :   false,  /* isMovable.  Not relevant for setters. */
     786             :   false, /* isEliminatable.  Not relevant for setters. */
     787             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     788             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     789             :   false,  /* isTypedMethod.  Only relevant for methods. */
     790             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     791             : };
     792             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     793             : static_assert(0 < 1, "There is no slot for us");
     794             : static const JSJitInfo hash_setterinfo = {
     795             :   { (JSJitGetterOp)set_hash },
     796             :   { prototypes::id::URL },
     797             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     798             :   JSJitInfo::Setter,
     799             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     800             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     801             :   false,  /* isInfallible. False in setters. */
     802             :   false,  /* isMovable.  Not relevant for setters. */
     803             :   false, /* isEliminatable.  Not relevant for setters. */
     804             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     805             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     806             :   false,  /* isTypedMethod.  Only relevant for methods. */
     807             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     808             : };
     809             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     810             : static_assert(0 < 1, "There is no slot for us");
     811             : 
     812             : static bool
     813           0 : toJSON(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URL* self, const JSJitMethodCallArgs& args)
     814             : {
     815           0 :   binding_detail::FastErrorResult rv;
     816           0 :   DOMString result;
     817           0 :   self->ToJSON(result, rv);
     818           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     819           0 :     return false;
     820             :   }
     821           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     822           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     823           0 :     return false;
     824             :   }
     825           0 :   return true;
     826             : }
     827             : 
     828             : static const JSJitInfo toJSON_methodinfo = {
     829             :   { (JSJitGetterOp)toJSON },
     830             :   { prototypes::id::URL },
     831             :   { PrototypeTraits<prototypes::id::URL>::Depth },
     832             :   JSJitInfo::Method,
     833             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     834             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     835             :   false,  /* isInfallible. False in setters. */
     836             :   false,  /* isMovable.  Not relevant for setters. */
     837             :   false, /* isEliminatable.  Not relevant for setters. */
     838             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     839             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     840             :   false,  /* isTypedMethod.  Only relevant for methods. */
     841             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     842             : };
     843             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     844             : static_assert(0 < 1, "There is no slot for us");
     845             : 
     846             : static bool
     847           0 : createObjectURL(JSContext* cx, unsigned argc, JS::Value* vp)
     848             : {
     849           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     850           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     851             : 
     852           0 :   unsigned argcount = std::min(args.length(), 1u);
     853           0 :   switch (argcount) {
     854             :     case 1: {
     855           0 :       if (args[0].isObject()) {
     856             :         do {
     857           0 :           NonNull<mozilla::dom::Blob> arg0;
     858             :           {
     859           0 :             nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
     860           0 :             if (NS_FAILED(rv)) {
     861           0 :               break;
     862             :             }
     863             :           }
     864           0 :           GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     865           0 :           if (global.Failed()) {
     866           0 :             return false;
     867             :           }
     868             : 
     869           0 :           binding_detail::FastErrorResult rv;
     870           0 :           DOMString result;
     871           0 :           mozilla::dom::URL::CreateObjectURL(global, NonNullHelper(arg0), result, rv);
     872           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     873           0 :             return false;
     874             :           }
     875           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     876           0 :           if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     877           0 :             return false;
     878             :           }
     879           0 :           return true;
     880             :         } while (0);
     881             :         do {
     882           0 :           NonNull<mozilla::DOMMediaStream> arg0;
     883             :           {
     884           0 :             nsresult rv = UnwrapObject<prototypes::id::MediaStream, mozilla::DOMMediaStream>(args[0], arg0);
     885           0 :             if (NS_FAILED(rv)) {
     886           0 :               break;
     887             :             }
     888             :           }
     889           0 :           GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     890           0 :           if (global.Failed()) {
     891           0 :             return false;
     892             :           }
     893             : 
     894           0 :           binding_detail::FastErrorResult rv;
     895           0 :           DOMString result;
     896           0 :           mozilla::dom::URL::CreateObjectURL(global, NonNullHelper(arg0), result, rv);
     897           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     898           0 :             return false;
     899             :           }
     900           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     901           0 :           if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     902           0 :             return false;
     903             :           }
     904           0 :           return true;
     905             :         } while (0);
     906             :         do {
     907           0 :           NonNull<mozilla::dom::MediaSource> arg0;
     908             :           {
     909           0 :             nsresult rv = UnwrapObject<prototypes::id::MediaSource, mozilla::dom::MediaSource>(args[0], arg0);
     910           0 :             if (NS_FAILED(rv)) {
     911           0 :               break;
     912             :             }
     913             :           }
     914           0 :           GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     915           0 :           if (global.Failed()) {
     916           0 :             return false;
     917             :           }
     918             : 
     919           0 :           binding_detail::FastErrorResult rv;
     920           0 :           DOMString result;
     921           0 :           mozilla::dom::URL::CreateObjectURL(global, NonNullHelper(arg0), result, rv);
     922           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     923           0 :             return false;
     924             :           }
     925           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     926           0 :           if (!xpc::StringToJsval(cx, result, args.rval())) {
     927           0 :             return false;
     928             :           }
     929           0 :           return true;
     930             :         } while (0);
     931             :       }
     932           0 :       return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "URL.createObjectURL");
     933             :       break;
     934             :     }
     935             :     default: {
     936           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.createObjectURL");
     937             :       break;
     938             :     }
     939             :   }
     940             :   MOZ_CRASH("We have an always-returning default case");
     941             :   return false;
     942             : }
     943             : 
     944             : static bool
     945           0 : revokeObjectURL(JSContext* cx, unsigned argc, JS::Value* vp)
     946             : {
     947           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     948           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     949             : 
     950           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     951           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.revokeObjectURL");
     952             :   }
     953           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     954           0 :   if (global.Failed()) {
     955           0 :     return false;
     956             :   }
     957             : 
     958           0 :   binding_detail::FakeString arg0;
     959           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     960           0 :     return false;
     961             :   }
     962           0 :   binding_detail::FastErrorResult rv;
     963           0 :   mozilla::dom::URL::RevokeObjectURL(global, NonNullHelper(Constify(arg0)), rv);
     964           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     965           0 :     return false;
     966             :   }
     967           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     968           0 :   args.rval().setUndefined();
     969           0 :   return true;
     970             : }
     971             : 
     972             : static bool
     973           0 : isValidURL(JSContext* cx, unsigned argc, JS::Value* vp)
     974             : {
     975           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     976           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     977             : 
     978           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     979           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL.isValidURL");
     980             :   }
     981           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     982           0 :   if (global.Failed()) {
     983           0 :     return false;
     984             :   }
     985             : 
     986           0 :   binding_detail::FakeString arg0;
     987           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     988           0 :     return false;
     989             :   }
     990           0 :   binding_detail::FastErrorResult rv;
     991           0 :   bool result(mozilla::dom::URL::IsValidURL(global, NonNullHelper(Constify(arg0)), rv));
     992           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     993           0 :     return false;
     994             :   }
     995           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     996           0 :   args.rval().setBoolean(result);
     997           0 :   return true;
     998             : }
     999             : 
    1000             : static bool
    1001           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1002             : {
    1003           0 :   mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
    1004             :   // We don't want to preserve if we don't have a wrapper, and we
    1005             :   // obviously can't preserve if we're not initialized.
    1006           0 :   if (self && self->GetWrapperPreserveColor()) {
    1007           0 :     PreserveWrapper(self);
    1008             :   }
    1009           0 :   return true;
    1010             : }
    1011             : 
    1012             : static void
    1013           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1014             : {
    1015           0 :   mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
    1016           0 :   if (self) {
    1017           0 :     ClearWrapper(self, self, obj);
    1018           0 :     AddForDeferredFinalization<mozilla::dom::URL>(self);
    1019             :   }
    1020           0 : }
    1021             : 
    1022             : static void
    1023           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1024             : {
    1025           0 :   mozilla::dom::URL* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URL>(obj);
    1026           0 :   if (self) {
    1027           0 :     UpdateWrapper(self, self, obj, old);
    1028             :   }
    1029           0 : }
    1030             : 
    1031             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1032             : #if defined(__clang__)
    1033             : #pragma clang diagnostic push
    1034             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1035             : #endif
    1036             : static const JSFunctionSpec sStaticMethods_specs[] = {
    1037             :   JS_FNSPEC("createObjectURL", createObjectURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
    1038             :   JS_FNSPEC("revokeObjectURL", revokeObjectURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
    1039             :   JS_FS_END
    1040             : };
    1041             : #if defined(__clang__)
    1042             : #pragma clang diagnostic pop
    1043             : #endif
    1044             : 
    1045             : 
    1046             : // Can't be const because the pref-enabled boolean needs to be writable
    1047             : static Prefable<const JSFunctionSpec> sStaticMethods[] = {
    1048             :   { nullptr, &sStaticMethods_specs[0] },
    1049             :   { nullptr, nullptr }
    1050             : };
    1051             : 
    1052             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1053             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1054             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1055             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1056             : 
    1057             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1058             : #if defined(__clang__)
    1059             : #pragma clang diagnostic push
    1060             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1061             : #endif
    1062             : static const JSFunctionSpec sChromeStaticMethods_specs[] = {
    1063             :   JS_FNSPEC("isValidURL", isValidURL, nullptr, 1, JSPROP_ENUMERATE, nullptr),
    1064             :   JS_FS_END
    1065             : };
    1066             : #if defined(__clang__)
    1067             : #pragma clang diagnostic pop
    1068             : #endif
    1069             : 
    1070             : 
    1071             : // Can't be const because the pref-enabled boolean needs to be writable
    1072             : static Prefable<const JSFunctionSpec> sChromeStaticMethods[] = {
    1073             :   { nullptr, &sChromeStaticMethods_specs[0] },
    1074             :   { nullptr, nullptr }
    1075             : };
    1076             : 
    1077             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1078             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1079             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1080             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1081             : 
    1082             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1083             : #if defined(__clang__)
    1084             : #pragma clang diagnostic push
    1085             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1086             : #endif
    1087             : static const JSFunctionSpec sMethods_specs[] = {
    1088             :   JS_FNSPEC("toJSON", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&toJSON_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1089             :   JS_FNSPEC("toString", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1090             :   JS_FS_END
    1091             : };
    1092             : #if defined(__clang__)
    1093             : #pragma clang diagnostic pop
    1094             : #endif
    1095             : 
    1096             : 
    1097             : // Can't be const because the pref-enabled boolean needs to be writable
    1098             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1099             :   { nullptr, &sMethods_specs[0] },
    1100             :   { nullptr, nullptr }
    1101             : };
    1102             : 
    1103             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1104             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1105             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1106             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1107             : 
    1108             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1109             : #if defined(__clang__)
    1110             : #pragma clang diagnostic push
    1111             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1112             : #endif
    1113             : static const JSPropertySpec sAttributes_specs[] = {
    1114             :   { "href", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &href_getterinfo, GenericBindingSetter, &href_setterinfo },
    1115             :   { "origin", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &origin_getterinfo, nullptr, nullptr },
    1116             :   { "protocol", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &protocol_getterinfo, GenericBindingSetter, &protocol_setterinfo },
    1117             :   { "username", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &username_getterinfo, GenericBindingSetter, &username_setterinfo },
    1118             :   { "password", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &password_getterinfo, GenericBindingSetter, &password_setterinfo },
    1119             :   { "host", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &host_getterinfo, GenericBindingSetter, &host_setterinfo },
    1120             :   { "hostname", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hostname_getterinfo, GenericBindingSetter, &hostname_setterinfo },
    1121             :   { "port", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &port_getterinfo, GenericBindingSetter, &port_setterinfo },
    1122             :   { "pathname", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pathname_getterinfo, GenericBindingSetter, &pathname_setterinfo },
    1123             :   { "search", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &search_getterinfo, GenericBindingSetter, &search_setterinfo },
    1124             :   { "searchParams", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &searchParams_getterinfo, nullptr, nullptr },
    1125             :   { "hash", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hash_getterinfo, GenericBindingSetter, &hash_setterinfo },
    1126             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1127             : };
    1128             : #if defined(__clang__)
    1129             : #pragma clang diagnostic pop
    1130             : #endif
    1131             : 
    1132             : 
    1133             : // Can't be const because the pref-enabled boolean needs to be writable
    1134             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1135             :   { nullptr, &sAttributes_specs[0] },
    1136             :   { nullptr, nullptr }
    1137             : };
    1138             : 
    1139             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1140             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1141             : static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1142             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1143             : 
    1144             : 
    1145             : static uint16_t sNativeProperties_sortedPropertyIndices[16];
    1146             : static PropertyInfo sNativeProperties_propertyInfos[16];
    1147             : 
    1148             : static const NativePropertiesN<3> sNativeProperties = {
    1149             :   true,  0 /* sStaticMethods */,
    1150             :   false, 0,
    1151             :   true,  1 /* sMethods */,
    1152             :   true,  2 /* sAttributes */,
    1153             :   false, 0,
    1154             :   false, 0,
    1155             :   false, 0,
    1156             :   -1,
    1157             :   16,
    1158             :   sNativeProperties_sortedPropertyIndices,
    1159             :   {
    1160             :     { sStaticMethods, &sNativeProperties_propertyInfos[0] },
    1161             :     { sMethods, &sNativeProperties_propertyInfos[2] },
    1162             :     { sAttributes, &sNativeProperties_propertyInfos[4] }
    1163             :   }
    1164             : };
    1165             : static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1166             :     "We have a property info count that is oversized");
    1167             : 
    1168             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    1169             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    1170             : 
    1171             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    1172             :   true,  0 /* sChromeStaticMethods */,
    1173             :   false, 0,
    1174             :   false, 0,
    1175             :   false, 0,
    1176             :   false, 0,
    1177             :   false, 0,
    1178             :   false, 0,
    1179             :   -1,
    1180             :   1,
    1181             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    1182             :   {
    1183             :     { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
    1184             :   }
    1185             : };
    1186             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    1187             :     "We have a property info count that is oversized");
    1188             : 
    1189             : static bool
    1190           3 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1191             : {
    1192           3 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1193           6 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1194           3 :   if (!args.isConstructing()) {
    1195             :     // XXXbz wish I could get the name from the callee instead of
    1196             :     // Adding more relocations
    1197           0 :     return ThrowConstructorWithoutNew(cx, "URL");
    1198             :   }
    1199             : 
    1200           6 :   GlobalObject global(cx, obj);
    1201           3 :   if (global.Failed()) {
    1202           0 :     return false;
    1203             :   }
    1204             : 
    1205           6 :   JS::Rooted<JSObject*> desiredProto(cx);
    1206           3 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1207           0 :     return false;
    1208             :   }
    1209             : 
    1210           3 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1211           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URL");
    1212             :   }
    1213           3 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1214           6 :   binding_detail::FakeString arg0;
    1215           3 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
    1216           0 :     return false;
    1217             :   }
    1218           3 :   NormalizeUSVString(arg0);
    1219           3 :   Optional<nsAString> arg1;
    1220           6 :   binding_detail::FakeString arg1_holder;
    1221           3 :   if (args.hasDefined(1)) {
    1222           0 :     if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
    1223           0 :       return false;
    1224             :     }
    1225           0 :     NormalizeUSVString(arg1_holder);
    1226           0 :     arg1 = &arg1_holder;
    1227             :   }
    1228           6 :   Maybe<JSAutoCompartment> ac;
    1229           3 :   if (objIsXray) {
    1230           0 :     obj = js::CheckedUnwrap(obj);
    1231           0 :     if (!obj) {
    1232           0 :       return false;
    1233             :     }
    1234           0 :     ac.emplace(cx, obj);
    1235           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    1236           0 :       return false;
    1237             :     }
    1238             :   }
    1239           6 :   binding_detail::FastErrorResult rv;
    1240           6 :   auto result(StrongOrRawPtr<mozilla::dom::URL>(mozilla::dom::URL::Constructor(global, Constify(arg0), Constify(arg1), rv)));
    1241           3 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1242           0 :     return false;
    1243             :   }
    1244           3 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1245             :   static_assert(!IsPointer<decltype(result)>::value,
    1246             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1247           3 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1248           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1249           0 :     return false;
    1250             :   }
    1251           3 :   return true;
    1252             : }
    1253             : 
    1254             : static const js::ClassOps sInterfaceObjectClassOps = {
    1255             :     nullptr,               /* addProperty */
    1256             :     nullptr,               /* delProperty */
    1257             :     nullptr,               /* getProperty */
    1258             :     nullptr,               /* setProperty */
    1259             :     nullptr,               /* enumerate */
    1260             :     nullptr,               /* newEnumerate */
    1261             :     nullptr,               /* resolve */
    1262             :     nullptr,               /* mayResolve */
    1263             :     nullptr,               /* finalize */
    1264             :     _constructor, /* call */
    1265             :     nullptr,               /* hasInstance */
    1266             :     _constructor, /* construct */
    1267             :     nullptr,               /* trace */
    1268             : };
    1269             : 
    1270             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1271             :   {
    1272             :     "Function",
    1273             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1274             :     &sInterfaceObjectClassOps,
    1275             :     JS_NULL_CLASS_SPEC,
    1276             :     JS_NULL_CLASS_EXT,
    1277             :     &sInterfaceObjectClassObjectOps
    1278             :   },
    1279             :   eInterface,
    1280             :   true,
    1281             :   prototypes::id::URL,
    1282             :   PrototypeTraits<prototypes::id::URL>::Depth,
    1283             :   sNativePropertyHooks,
    1284             :   "function URL() {\n    [native code]\n}",
    1285             :   JS::GetRealmFunctionPrototype
    1286             : };
    1287             : 
    1288             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1289             :   {
    1290             :     "URLPrototype",
    1291             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1292             :     JS_NULL_CLASS_OPS,
    1293             :     JS_NULL_CLASS_SPEC,
    1294             :     JS_NULL_CLASS_EXT,
    1295             :     JS_NULL_OBJECT_OPS
    1296             :   },
    1297             :   eInterfacePrototype,
    1298             :   false,
    1299             :   prototypes::id::URL,
    1300             :   PrototypeTraits<prototypes::id::URL>::Depth,
    1301             :   sNativePropertyHooks,
    1302             :   "[object URLPrototype]",
    1303             :   JS::GetRealmObjectPrototype
    1304             : };
    1305             : 
    1306             : JSObject*
    1307           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1308             : {
    1309           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1310             : }
    1311             : 
    1312             : static const js::ClassOps sClassOps = {
    1313             :   _addProperty, /* addProperty */
    1314             :   nullptr,               /* delProperty */
    1315             :   nullptr,               /* getProperty */
    1316             :   nullptr,               /* setProperty */
    1317             :   nullptr,               /* enumerate */
    1318             :   nullptr, /* newEnumerate */
    1319             :   nullptr, /* resolve */
    1320             :   nullptr, /* mayResolve */
    1321             :   _finalize, /* finalize */
    1322             :   nullptr, /* call */
    1323             :   nullptr,               /* hasInstance */
    1324             :   nullptr,               /* construct */
    1325             :   nullptr, /* trace */
    1326             : };
    1327             : 
    1328             : static const js::ClassExtension sClassExtension = {
    1329             :   nullptr, /* weakmapKeyDelegateOp */
    1330             :   _objectMoved /* objectMovedOp */
    1331             : };
    1332             : 
    1333             : static const DOMJSClass sClass = {
    1334             :   { "URL",
    1335             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1336             :     &sClassOps,
    1337             :     JS_NULL_CLASS_SPEC,
    1338             :     &sClassExtension,
    1339             :     JS_NULL_OBJECT_OPS
    1340             :   },
    1341             :   { prototypes::id::URL, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1342             :   IsBaseOf<nsISupports, mozilla::dom::URL >::value,
    1343             :   sNativePropertyHooks,
    1344             :   FindAssociatedGlobalForNative<mozilla::dom::URL>::Get,
    1345             :   GetProtoObjectHandle,
    1346             :   GetCCParticipant<mozilla::dom::URL>::Get()
    1347             : };
    1348             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1349             :               "Must have the right minimal number of reserved slots.");
    1350             : static_assert(1 >= 1,
    1351             :               "Must have enough reserved slots.");
    1352             : 
    1353             : const JSClass*
    1354           0 : GetJSClass()
    1355             : {
    1356           0 :   return sClass.ToJSClass();
    1357             : }
    1358             : 
    1359             : bool
    1360           3 : Wrap(JSContext* aCx, mozilla::dom::URL* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1361             : {
    1362             :   MOZ_ASSERT(static_cast<mozilla::dom::URL*>(aObject) ==
    1363             :              reinterpret_cast<mozilla::dom::URL*>(aObject),
    1364             :              "Multiple inheritance for mozilla::dom::URL is broken.");
    1365           3 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1366           3 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1367           3 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1368             :              "You should probably not be using Wrap() directly; use "
    1369             :              "GetOrCreateDOMReflector instead");
    1370             : 
    1371           3 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1372             :              "nsISupports must be on our primary inheritance chain");
    1373             : 
    1374           6 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1375           3 :   if (!global) {
    1376           0 :     return false;
    1377             :   }
    1378           3 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1379           3 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1380             : 
    1381             :   // That might have ended up wrapping us already, due to the wonders
    1382             :   // of XBL.  Check for that, and bail out as needed.
    1383           3 :   aReflector.set(aCache->GetWrapper());
    1384           3 :   if (aReflector) {
    1385             : #ifdef DEBUG
    1386           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1387             : #endif // DEBUG
    1388           0 :     return true;
    1389             :   }
    1390             : 
    1391           6 :   JSAutoCompartment ac(aCx, global);
    1392           3 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1393           3 :   if (!canonicalProto) {
    1394           0 :     return false;
    1395             :   }
    1396           6 :   JS::Rooted<JSObject*> proto(aCx);
    1397           3 :   if (aGivenProto) {
    1398           3 :     proto = aGivenProto;
    1399             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1400             :     // coming in, we changed compartments to that of "parent" so may need
    1401             :     // to wrap the proto here.
    1402           3 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1403           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1404           0 :         return false;
    1405             :       }
    1406             :     }
    1407             :   } else {
    1408           0 :     proto = canonicalProto;
    1409             :   }
    1410             : 
    1411           6 :   BindingJSObjectCreator<mozilla::dom::URL> creator(aCx);
    1412           3 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1413           3 :   if (!aReflector) {
    1414           0 :     return false;
    1415             :   }
    1416             : 
    1417           3 :   aCache->SetWrapper(aReflector);
    1418           3 :   creator.InitializationSucceeded();
    1419             : 
    1420           3 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1421             :              aCache->GetWrapperPreserveColor() == aReflector);
    1422             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1423             :   // otherwise we won't be able to properly recreate it later, since
    1424             :   // we won't know what proto to use.  Note that we don't check
    1425             :   // aGivenProto here, since it's entirely possible (and even
    1426             :   // somewhat common) to have a non-null aGivenProto which is the
    1427             :   // same as canonicalProto.
    1428           3 :   if (proto != canonicalProto) {
    1429           0 :     PreserveWrapper(aObject);
    1430             :   }
    1431             : 
    1432           3 :   return true;
    1433             : }
    1434             : 
    1435             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1436             :   nullptr,
    1437             :   nullptr,
    1438             :   nullptr,
    1439             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    1440             :   prototypes::id::URL,
    1441             :   constructors::id::URL,
    1442             :   nullptr,
    1443             :   &DefaultXrayExpandoObjectClass
    1444             : } };
    1445             : 
    1446             : void
    1447          10 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1448             : {
    1449          20 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1450          10 :   if (!parentProto) {
    1451           0 :     return;
    1452             :   }
    1453             : 
    1454          20 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1455          10 :   if (!constructorProto) {
    1456           0 :     return;
    1457             :   }
    1458             : 
    1459             :   static bool sIdsInited = false;
    1460          10 :   if (!sIdsInited && NS_IsMainThread()) {
    1461           2 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1462           0 :       return;
    1463             :     }
    1464           2 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    1465           0 :       return;
    1466             :     }
    1467           2 :     sIdsInited = true;
    1468             :   }
    1469             : 
    1470          10 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::URL);
    1471          10 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::URL);
    1472          30 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1473             :                               &sPrototypeClass.mBase, protoCache,
    1474             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    1475             :                               interfaceCache,
    1476             :                               sNativeProperties.Upcast(),
    1477          10 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    1478             :                               "URL", aDefineOnGlobal,
    1479             :                               nullptr,
    1480          10 :                               false);
    1481             : }
    1482             : 
    1483             : JS::Handle<JSObject*>
    1484           3 : GetProtoObjectHandle(JSContext* aCx)
    1485             : {
    1486             :   /* Get the interface prototype object for this class.  This will create the
    1487             :      object as needed. */
    1488           3 :   bool aDefineOnGlobal = true;
    1489             : 
    1490             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1491           3 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1492           3 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1493           0 :     return nullptr;
    1494             :   }
    1495             : 
    1496             :   /* Check to see whether the interface objects are already installed */
    1497           3 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1498           3 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::URL)) {
    1499           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1500           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1501             :   }
    1502             : 
    1503             :   /*
    1504             :    * The object might _still_ be null, but that's OK.
    1505             :    *
    1506             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1507             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1508             :    * changed after they have been set.
    1509             :    *
    1510             :    * Calling address() avoids the read read barrier that does gray
    1511             :    * unmarking, but it's not possible for the object to be gray here.
    1512             :    */
    1513             : 
    1514           3 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::URL);
    1515           3 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1516           3 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1517             : }
    1518             : 
    1519             : JS::Handle<JSObject*>
    1520          10 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1521             : {
    1522             :   /* Get the interface object for this class.  This will create the object as
    1523             :      needed. */
    1524             : 
    1525             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1526          10 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1527          10 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1528           0 :     return nullptr;
    1529             :   }
    1530             : 
    1531             :   /* Check to see whether the interface objects are already installed */
    1532          10 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1533          10 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::URL)) {
    1534          20 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1535          10 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1536             :   }
    1537             : 
    1538             :   /*
    1539             :    * The object might _still_ be null, but that's OK.
    1540             :    *
    1541             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1542             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1543             :    * changed after they have been set.
    1544             :    *
    1545             :    * Calling address() avoids the read read barrier that does gray
    1546             :    * unmarking, but it's not possible for the object to be gray here.
    1547             :    */
    1548             : 
    1549          10 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::URL);
    1550          10 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1551          10 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1552             : }
    1553             : 
    1554             : JSObject*
    1555          10 : GetConstructorObject(JSContext* aCx)
    1556             : {
    1557          10 :   return GetConstructorObjectHandle(aCx);
    1558             : }
    1559             : 
    1560             : } // namespace URLBinding
    1561             : 
    1562             : 
    1563             : 
    1564             : } // namespace dom
    1565             : } // namespace mozilla

Generated by: LCOV version 1.13