LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - RequestBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 80 772 10.4 %
Date: 2017-07-14 16:53:18 Functions: 6 61 9.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Request.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "FetchController.h"
       5             : #include "FetchObserver.h"
       6             : #include "RequestBinding.h"
       7             : #include "WrapperFactory.h"
       8             : #include "jsapi.h"
       9             : #include "mozilla/OwningNonNull.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/Headers.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/Promise.h"
      16             : #include "mozilla/dom/Request.h"
      17             : #include "mozilla/dom/ScriptSettings.h"
      18             : #include "mozilla/dom/ToJSValue.h"
      19             : #include "mozilla/dom/UnionConversions.h"
      20             : #include "mozilla/dom/XrayExpandoClass.h"
      21             : #include "nsContentUtils.h"
      22             : 
      23             : namespace mozilla {
      24             : namespace dom {
      25             : 
      26             : namespace RequestContextValues {
      27             : extern const EnumEntry strings[33] = {
      28             :   {"audio", 5},
      29             :   {"beacon", 6},
      30             :   {"cspreport", 9},
      31             :   {"download", 8},
      32             :   {"embed", 5},
      33             :   {"eventsource", 11},
      34             :   {"favicon", 7},
      35             :   {"fetch", 5},
      36             :   {"font", 4},
      37             :   {"form", 4},
      38             :   {"frame", 5},
      39             :   {"hyperlink", 9},
      40             :   {"iframe", 6},
      41             :   {"image", 5},
      42             :   {"imageset", 8},
      43             :   {"import", 6},
      44             :   {"internal", 8},
      45             :   {"location", 8},
      46             :   {"manifest", 8},
      47             :   {"object", 6},
      48             :   {"ping", 4},
      49             :   {"plugin", 6},
      50             :   {"prefetch", 8},
      51             :   {"script", 6},
      52             :   {"sharedworker", 12},
      53             :   {"subresource", 11},
      54             :   {"style", 5},
      55             :   {"track", 5},
      56             :   {"video", 5},
      57             :   {"worker", 6},
      58             :   {"xmlhttprequest", 14},
      59             :   {"xslt", 4},
      60             :   { nullptr, 0 }
      61             : };
      62             : } // namespace RequestContextValues
      63             : 
      64             : bool
      65           0 : ToJSValue(JSContext* aCx, RequestContext aArgument, JS::MutableHandle<JS::Value> aValue)
      66             : {
      67           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestContextValues::strings));
      68             :   JSString* resultStr =
      69           0 :     JS_NewStringCopyN(aCx, RequestContextValues::strings[uint32_t(aArgument)].value,
      70           0 :                       RequestContextValues::strings[uint32_t(aArgument)].length);
      71           0 :   if (!resultStr) {
      72           0 :     return false;
      73             :   }
      74           0 :   aValue.setString(resultStr);
      75           0 :   return true;
      76             : }
      77             : 
      78             : 
      79             : namespace RequestModeValues {
      80             : extern const EnumEntry strings[5] = {
      81             :   {"same-origin", 11},
      82             :   {"no-cors", 7},
      83             :   {"cors", 4},
      84             :   {"navigate", 8},
      85             :   { nullptr, 0 }
      86             : };
      87             : } // namespace RequestModeValues
      88             : 
      89             : bool
      90           0 : ToJSValue(JSContext* aCx, RequestMode aArgument, JS::MutableHandle<JS::Value> aValue)
      91             : {
      92           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestModeValues::strings));
      93             :   JSString* resultStr =
      94           0 :     JS_NewStringCopyN(aCx, RequestModeValues::strings[uint32_t(aArgument)].value,
      95           0 :                       RequestModeValues::strings[uint32_t(aArgument)].length);
      96           0 :   if (!resultStr) {
      97           0 :     return false;
      98             :   }
      99           0 :   aValue.setString(resultStr);
     100           0 :   return true;
     101             : }
     102             : 
     103             : 
     104             : namespace RequestCredentialsValues {
     105             : extern const EnumEntry strings[4] = {
     106             :   {"omit", 4},
     107             :   {"same-origin", 11},
     108             :   {"include", 7},
     109             :   { nullptr, 0 }
     110             : };
     111             : } // namespace RequestCredentialsValues
     112             : 
     113             : bool
     114           0 : ToJSValue(JSContext* aCx, RequestCredentials aArgument, JS::MutableHandle<JS::Value> aValue)
     115             : {
     116           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestCredentialsValues::strings));
     117             :   JSString* resultStr =
     118           0 :     JS_NewStringCopyN(aCx, RequestCredentialsValues::strings[uint32_t(aArgument)].value,
     119           0 :                       RequestCredentialsValues::strings[uint32_t(aArgument)].length);
     120           0 :   if (!resultStr) {
     121           0 :     return false;
     122             :   }
     123           0 :   aValue.setString(resultStr);
     124           0 :   return true;
     125             : }
     126             : 
     127             : 
     128             : namespace RequestCacheValues {
     129             : extern const EnumEntry strings[7] = {
     130             :   {"default", 7},
     131             :   {"no-store", 8},
     132             :   {"reload", 6},
     133             :   {"no-cache", 8},
     134             :   {"force-cache", 11},
     135             :   {"only-if-cached", 14},
     136             :   { nullptr, 0 }
     137             : };
     138             : } // namespace RequestCacheValues
     139             : 
     140             : bool
     141           0 : ToJSValue(JSContext* aCx, RequestCache aArgument, JS::MutableHandle<JS::Value> aValue)
     142             : {
     143           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestCacheValues::strings));
     144             :   JSString* resultStr =
     145           0 :     JS_NewStringCopyN(aCx, RequestCacheValues::strings[uint32_t(aArgument)].value,
     146           0 :                       RequestCacheValues::strings[uint32_t(aArgument)].length);
     147           0 :   if (!resultStr) {
     148           0 :     return false;
     149             :   }
     150           0 :   aValue.setString(resultStr);
     151           0 :   return true;
     152             : }
     153             : 
     154             : 
     155             : namespace RequestRedirectValues {
     156             : extern const EnumEntry strings[4] = {
     157             :   {"follow", 6},
     158             :   {"error", 5},
     159             :   {"manual", 6},
     160             :   { nullptr, 0 }
     161             : };
     162             : } // namespace RequestRedirectValues
     163             : 
     164             : bool
     165           0 : ToJSValue(JSContext* aCx, RequestRedirect aArgument, JS::MutableHandle<JS::Value> aValue)
     166             : {
     167           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RequestRedirectValues::strings));
     168             :   JSString* resultStr =
     169           0 :     JS_NewStringCopyN(aCx, RequestRedirectValues::strings[uint32_t(aArgument)].value,
     170           0 :                       RequestRedirectValues::strings[uint32_t(aArgument)].length);
     171           0 :   if (!resultStr) {
     172           0 :     return false;
     173             :   }
     174           0 :   aValue.setString(resultStr);
     175           0 :   return true;
     176             : }
     177             : 
     178             : 
     179             : namespace ReferrerPolicyValues {
     180             : extern const EnumEntry strings[10] = {
     181             :   {"", 0},
     182             :   {"no-referrer", 11},
     183             :   {"no-referrer-when-downgrade", 26},
     184             :   {"origin", 6},
     185             :   {"origin-when-cross-origin", 24},
     186             :   {"unsafe-url", 10},
     187             :   {"same-origin", 11},
     188             :   {"strict-origin", 13},
     189             :   {"strict-origin-when-cross-origin", 31},
     190             :   { nullptr, 0 }
     191             : };
     192             : } // namespace ReferrerPolicyValues
     193             : 
     194             : bool
     195           0 : ToJSValue(JSContext* aCx, ReferrerPolicy aArgument, JS::MutableHandle<JS::Value> aValue)
     196             : {
     197           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ReferrerPolicyValues::strings));
     198             :   JSString* resultStr =
     199           0 :     JS_NewStringCopyN(aCx, ReferrerPolicyValues::strings[uint32_t(aArgument)].value,
     200           0 :                       ReferrerPolicyValues::strings[uint32_t(aArgument)].length);
     201           0 :   if (!resultStr) {
     202           0 :     return false;
     203             :   }
     204           0 :   aValue.setString(resultStr);
     205           0 :   return true;
     206             : }
     207             : 
     208             : 
     209             : void
     210           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningRequestOrUSVString& aUnion, const char* aName, uint32_t aFlags)
     211             : {
     212           0 :   if (aUnion.IsRequest()) {
     213           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsRequest(), "mRequest", aFlags);
     214             :   }
     215           0 : }
     216             : 
     217             : 
     218             : void
     219           0 : ImplCycleCollectionUnlink(OwningRequestOrUSVString& aUnion)
     220             : {
     221           0 :   aUnion.Uninit();
     222           0 : }
     223             : 
     224             : 
     225             : 
     226           1 : RequestInit::RequestInit()
     227             : {
     228             :   // Safe to pass a null context if we pass a null value
     229           1 :   Init(nullptr, JS::NullHandleValue);
     230           1 : }
     231             : 
     232             : 
     233             : bool
     234           1 : RequestInit::InitIds(JSContext* cx, RequestInitAtoms* atomsCache)
     235             : {
     236           1 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     237             : 
     238             :   // Initialize these in reverse order so that any failure leaves the first one
     239             :   // uninitialized.
     240           3 :   if (!atomsCache->signal_id.init(cx, "signal") ||
     241           2 :       !atomsCache->referrerPolicy_id.init(cx, "referrerPolicy") ||
     242           2 :       !atomsCache->referrer_id.init(cx, "referrer") ||
     243           2 :       !atomsCache->redirect_id.init(cx, "redirect") ||
     244           2 :       !atomsCache->observe_id.init(cx, "observe") ||
     245           2 :       !atomsCache->mode_id.init(cx, "mode") ||
     246           2 :       !atomsCache->method_id.init(cx, "method") ||
     247           2 :       !atomsCache->integrity_id.init(cx, "integrity") ||
     248           2 :       !atomsCache->headers_id.init(cx, "headers") ||
     249           2 :       !atomsCache->credentials_id.init(cx, "credentials") ||
     250           3 :       !atomsCache->cache_id.init(cx, "cache") ||
     251           1 :       !atomsCache->body_id.init(cx, "body")) {
     252           0 :     return false;
     253             :   }
     254           1 :   return true;
     255             : }
     256             : 
     257             : bool
     258           2 : RequestInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     259             : {
     260             :   // Passing a null JSContext is OK only if we're initing from null,
     261             :   // Since in that case we will not have to do any property gets
     262             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     263             :   // checkers by static analysis tools
     264           2 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     265           2 :   RequestInitAtoms* atomsCache = nullptr;
     266           2 :   if (cx) {
     267           1 :     atomsCache = GetAtomCache<RequestInitAtoms>(cx);
     268           1 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     269           0 :       return false;
     270             :     }
     271             :   }
     272             : 
     273           2 :   if (!IsConvertibleToDictionary(val)) {
     274           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     275             :   }
     276             : 
     277           2 :   bool isNull = val.isNullOrUndefined();
     278             :   // We only need these if !isNull, in which case we have |cx|.
     279           4 :   Maybe<JS::Rooted<JSObject *> > object;
     280           4 :   Maybe<JS::Rooted<JS::Value> > temp;
     281           2 :   if (!isNull) {
     282           0 :     MOZ_ASSERT(cx);
     283           0 :     object.emplace(cx, &val.toObject());
     284           0 :     temp.emplace(cx);
     285             :   }
     286           2 :   if (!isNull) {
     287           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->body_id, temp.ptr())) {
     288           0 :       return false;
     289             :     }
     290             :   }
     291           2 :   if (!isNull && !temp->isUndefined()) {
     292           0 :     mBody.Construct();
     293           0 :     if (temp.ref().isNullOrUndefined()) {
     294           0 :       (mBody.Value()).SetNull();
     295             :     } else {
     296             :       {
     297           0 :         bool done = false, failed = false, tryNext;
     298           0 :         if (temp.ref().isObject()) {
     299           0 :           done = (failed = !(mBody.Value()).SetValue().TrySetToBlob(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
     300           0 :                  (failed = !(mBody.Value()).SetValue().TrySetToArrayBufferView(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
     301           0 :                  (failed = !(mBody.Value()).SetValue().TrySetToArrayBuffer(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
     302           0 :                  (failed = !(mBody.Value()).SetValue().TrySetToFormData(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
     303           0 :                  (failed = !(mBody.Value()).SetValue().TrySetToURLSearchParams(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
     304             : 
     305             :         }
     306           0 :         if (!done) {
     307             :           do {
     308           0 :             done = (failed = !(mBody.Value()).SetValue().TrySetToUSVString(cx, temp.ref(), tryNext)) || !tryNext;
     309           0 :             break;
     310             :           } while (0);
     311             :         }
     312           0 :         if (failed) {
     313           0 :           return false;
     314             :         }
     315           0 :         if (!done) {
     316           0 :           ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'body' member of RequestInit", "Blob, ArrayBufferView, ArrayBuffer, FormData, URLSearchParams");
     317           0 :           return false;
     318             :         }
     319             :       }
     320             :     }
     321           0 :     mIsAnyMemberPresent = true;
     322             :   }
     323             : 
     324           2 :   if (!isNull) {
     325           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->cache_id, temp.ptr())) {
     326           0 :       return false;
     327             :     }
     328             :   }
     329           2 :   if (!isNull && !temp->isUndefined()) {
     330           0 :     mCache.Construct();
     331             :     {
     332             :       int index;
     333           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestCacheValues::strings, "RequestCache", "'cache' member of RequestInit", &index)) {
     334           0 :         return false;
     335             :       }
     336           0 :       MOZ_ASSERT(index >= 0);
     337           0 :       (mCache.Value()) = static_cast<RequestCache>(index);
     338             :     }
     339           0 :     mIsAnyMemberPresent = true;
     340             :   }
     341             : 
     342           2 :   if (!isNull) {
     343           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->credentials_id, temp.ptr())) {
     344           0 :       return false;
     345             :     }
     346             :   }
     347           2 :   if (!isNull && !temp->isUndefined()) {
     348           0 :     mCredentials.Construct();
     349             :     {
     350             :       int index;
     351           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestCredentialsValues::strings, "RequestCredentials", "'credentials' member of RequestInit", &index)) {
     352           0 :         return false;
     353             :       }
     354           0 :       MOZ_ASSERT(index >= 0);
     355           0 :       (mCredentials.Value()) = static_cast<RequestCredentials>(index);
     356             :     }
     357           0 :     mIsAnyMemberPresent = true;
     358             :   }
     359             : 
     360           2 :   if (!isNull) {
     361           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->headers_id, temp.ptr())) {
     362           0 :       return false;
     363             :     }
     364             :   }
     365           2 :   if (!isNull && !temp->isUndefined()) {
     366           0 :     mHeaders.Construct();
     367             :     {
     368           0 :       bool done = false, failed = false, tryNext;
     369           0 :       if (temp.ref().isObject()) {
     370           0 :         done = (failed = !(mHeaders.Value()).TrySetToHeaders(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
     371             : 
     372           0 :         if (!done) {
     373           0 :           done = (failed = !(mHeaders.Value()).TrySetToByteStringSequenceSequence(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
     374             :         }
     375           0 :         if (!done) {
     376           0 :           done = (failed = !(mHeaders.Value()).TrySetToByteStringByteStringRecord(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
     377             :         }
     378             :       }
     379           0 :       if (failed) {
     380           0 :         return false;
     381             :       }
     382           0 :       if (!done) {
     383           0 :         ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'headers' member of RequestInit", "Headers, ByteStringSequenceSequence, ByteStringByteStringRecord");
     384           0 :         return false;
     385             :       }
     386             :     }
     387           0 :     mIsAnyMemberPresent = true;
     388             :   }
     389             : 
     390           2 :   if (!isNull) {
     391           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->integrity_id, temp.ptr())) {
     392           0 :       return false;
     393             :     }
     394             :   }
     395           2 :   if (!isNull && !temp->isUndefined()) {
     396           0 :     mIntegrity.Construct();
     397           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mIntegrity.Value()))) {
     398           0 :       return false;
     399             :     }
     400           0 :     mIsAnyMemberPresent = true;
     401             :   }
     402             : 
     403           2 :   if (!isNull) {
     404           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->method_id, temp.ptr())) {
     405           0 :       return false;
     406             :     }
     407             :   }
     408           2 :   if (!isNull && !temp->isUndefined()) {
     409           0 :     mMethod.Construct();
     410           0 :     if (!ConvertJSValueToByteString(cx, temp.ref(), false, (mMethod.Value()))) {
     411           0 :       return false;
     412             :     }
     413           0 :     mIsAnyMemberPresent = true;
     414             :   }
     415             : 
     416           2 :   if (!isNull) {
     417           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->mode_id, temp.ptr())) {
     418           0 :       return false;
     419             :     }
     420             :   }
     421           2 :   if (!isNull && !temp->isUndefined()) {
     422           0 :     mMode.Construct();
     423             :     {
     424             :       int index;
     425           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestModeValues::strings, "RequestMode", "'mode' member of RequestInit", &index)) {
     426           0 :         return false;
     427             :       }
     428           0 :       MOZ_ASSERT(index >= 0);
     429           0 :       (mMode.Value()) = static_cast<RequestMode>(index);
     430             :     }
     431           0 :     mIsAnyMemberPresent = true;
     432             :   }
     433             : 
     434           2 :   if (!isNull) {
     435           0 :     if (FetchObserver::IsEnabled(cx, *object)) {
     436           0 :       if (!JS_GetPropertyById(cx, *object, atomsCache->observe_id, temp.ptr())) {
     437           0 :         return false;
     438             :       }
     439             :     } else {
     440           0 :       temp->setUndefined();
     441             :     }
     442             :   }
     443           2 :   if (!isNull && !temp->isUndefined()) {
     444           0 :     mObserve.Construct();
     445           0 :     if (temp.ref().isObject()) {
     446             :       { // scope for tempRoot
     447           0 :         JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject());
     448           0 :         (mObserve.Value()) = new ObserverCallback(cx, tempRoot, GetIncumbentGlobal());
     449             :       }
     450             :     } else {
     451           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'observe' member of RequestInit");
     452           0 :       return false;
     453             :     }
     454           0 :     mIsAnyMemberPresent = true;
     455             :   }
     456             : 
     457           2 :   if (!isNull) {
     458           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->redirect_id, temp.ptr())) {
     459           0 :       return false;
     460             :     }
     461             :   }
     462           2 :   if (!isNull && !temp->isUndefined()) {
     463           0 :     mRedirect.Construct();
     464             :     {
     465             :       int index;
     466           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), RequestRedirectValues::strings, "RequestRedirect", "'redirect' member of RequestInit", &index)) {
     467           0 :         return false;
     468             :       }
     469           0 :       MOZ_ASSERT(index >= 0);
     470           0 :       (mRedirect.Value()) = static_cast<RequestRedirect>(index);
     471             :     }
     472           0 :     mIsAnyMemberPresent = true;
     473             :   }
     474             : 
     475           2 :   if (!isNull) {
     476           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->referrer_id, temp.ptr())) {
     477           0 :       return false;
     478             :     }
     479             :   }
     480           2 :   if (!isNull && !temp->isUndefined()) {
     481           0 :     mReferrer.Construct();
     482           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mReferrer.Value()))) {
     483           0 :       return false;
     484             :     }
     485           0 :     NormalizeUSVString((mReferrer.Value()));
     486           0 :     mIsAnyMemberPresent = true;
     487             :   }
     488             : 
     489           2 :   if (!isNull) {
     490           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->referrerPolicy_id, temp.ptr())) {
     491           0 :       return false;
     492             :     }
     493             :   }
     494           2 :   if (!isNull && !temp->isUndefined()) {
     495           0 :     mReferrerPolicy.Construct();
     496             :     {
     497             :       int index;
     498           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), ReferrerPolicyValues::strings, "ReferrerPolicy", "'referrerPolicy' member of RequestInit", &index)) {
     499           0 :         return false;
     500             :       }
     501           0 :       MOZ_ASSERT(index >= 0);
     502           0 :       (mReferrerPolicy.Value()) = static_cast<ReferrerPolicy>(index);
     503             :     }
     504           0 :     mIsAnyMemberPresent = true;
     505             :   }
     506             : 
     507           2 :   if (!isNull) {
     508           0 :     if (FetchController::IsEnabled(cx, *object)) {
     509           0 :       if (!JS_GetPropertyById(cx, *object, atomsCache->signal_id, temp.ptr())) {
     510           0 :         return false;
     511             :       }
     512             :     } else {
     513           0 :       temp->setUndefined();
     514             :     }
     515             :   }
     516           2 :   if (!isNull && !temp->isUndefined()) {
     517           0 :     mSignal.Construct();
     518           0 :     if (temp.ref().isObject()) {
     519             :       static_assert(IsRefcounted<mozilla::dom::FetchSignal>::value, "We can only store refcounted classes.");{
     520           0 :         nsresult rv = UnwrapObject<prototypes::id::FetchSignal, mozilla::dom::FetchSignal>(temp.ptr(), (mSignal.Value()));
     521           0 :         if (NS_FAILED(rv)) {
     522           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'signal' member of RequestInit", "FetchSignal");
     523           0 :           return false;
     524             :         }
     525             :       }
     526             :     } else {
     527           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'signal' member of RequestInit");
     528           0 :       return false;
     529             :     }
     530           0 :     mIsAnyMemberPresent = true;
     531             :   }
     532           2 :   return true;
     533             : }
     534             : 
     535             : bool
     536           0 : RequestInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     537             : {
     538           0 :   RequestInitAtoms* atomsCache = GetAtomCache<RequestInitAtoms>(cx);
     539           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     540           0 :     return false;
     541             :   }
     542             : 
     543           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     544           0 :   if (!obj) {
     545           0 :     return false;
     546             :   }
     547           0 :   rval.set(JS::ObjectValue(*obj));
     548             : 
     549           0 :   if (mBody.WasPassed()) {
     550             :     do {
     551             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     552           0 :       JS::Rooted<JS::Value> temp(cx);
     553           0 :       Nullable<OwningBlobOrArrayBufferViewOrArrayBufferOrFormDataOrURLSearchParamsOrUSVString > const & currentValue = mBody.InternalValue();
     554           0 :       if (currentValue.IsNull()) {
     555           0 :         temp.setNull();
     556           0 :         if (!JS_DefinePropertyById(cx, obj, atomsCache->body_id, temp, JSPROP_ENUMERATE)) {
     557           0 :           return false;
     558             :         }
     559           0 :         break;
     560             :       }
     561           0 :       if (!currentValue.Value().ToJSVal(cx, obj, &temp)) {
     562           0 :         return false;
     563             :       }
     564           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->body_id, temp, JSPROP_ENUMERATE)) {
     565           0 :         return false;
     566             :       }
     567           0 :       break;
     568             :     } while(0);
     569             :   }
     570             : 
     571           0 :   if (mCache.WasPassed()) {
     572             :     do {
     573             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     574           0 :       JS::Rooted<JS::Value> temp(cx);
     575           0 :       RequestCache const & currentValue = mCache.InternalValue();
     576           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     577           0 :         return false;
     578             :       }
     579           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->cache_id, temp, JSPROP_ENUMERATE)) {
     580           0 :         return false;
     581             :       }
     582           0 :       break;
     583             :     } while(0);
     584             :   }
     585             : 
     586           0 :   if (mCredentials.WasPassed()) {
     587             :     do {
     588             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     589           0 :       JS::Rooted<JS::Value> temp(cx);
     590           0 :       RequestCredentials const & currentValue = mCredentials.InternalValue();
     591           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     592           0 :         return false;
     593             :       }
     594           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->credentials_id, temp, JSPROP_ENUMERATE)) {
     595           0 :         return false;
     596             :       }
     597           0 :       break;
     598             :     } while(0);
     599             :   }
     600             : 
     601           0 :   if (mHeaders.WasPassed()) {
     602             :     do {
     603             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     604           0 :       JS::Rooted<JS::Value> temp(cx);
     605           0 :       OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord const & currentValue = mHeaders.InternalValue();
     606           0 :       if (!currentValue.ToJSVal(cx, obj, &temp)) {
     607           0 :         return false;
     608             :       }
     609           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->headers_id, temp, JSPROP_ENUMERATE)) {
     610           0 :         return false;
     611             :       }
     612           0 :       break;
     613             :     } while(0);
     614             :   }
     615             : 
     616           0 :   if (mIntegrity.WasPassed()) {
     617             :     do {
     618             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     619           0 :       JS::Rooted<JS::Value> temp(cx);
     620           0 :       nsString const & currentValue = mIntegrity.InternalValue();
     621           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     622           0 :         return false;
     623             :       }
     624           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->integrity_id, temp, JSPROP_ENUMERATE)) {
     625           0 :         return false;
     626             :       }
     627           0 :       break;
     628             :     } while(0);
     629             :   }
     630             : 
     631           0 :   if (mMethod.WasPassed()) {
     632             :     do {
     633             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     634           0 :       JS::Rooted<JS::Value> temp(cx);
     635           0 :       nsCString const & currentValue = mMethod.InternalValue();
     636           0 :       if (!NonVoidByteStringToJsval(cx, currentValue, &temp)) {
     637           0 :         return false;
     638             :       }
     639           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->method_id, temp, JSPROP_ENUMERATE)) {
     640           0 :         return false;
     641             :       }
     642           0 :       break;
     643             :     } while(0);
     644             :   }
     645             : 
     646           0 :   if (mMode.WasPassed()) {
     647             :     do {
     648             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     649           0 :       JS::Rooted<JS::Value> temp(cx);
     650           0 :       RequestMode const & currentValue = mMode.InternalValue();
     651           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     652           0 :         return false;
     653             :       }
     654           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->mode_id, temp, JSPROP_ENUMERATE)) {
     655           0 :         return false;
     656             :       }
     657           0 :       break;
     658             :     } while(0);
     659             :   }
     660             : 
     661           0 :   if (FetchObserver::IsEnabled(cx, obj)) {
     662           0 :     if (mObserve.WasPassed()) {
     663             :       do {
     664             :         // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     665           0 :         JS::Rooted<JS::Value> temp(cx);
     666           0 :         OwningNonNull<ObserverCallback> const & currentValue = mObserve.InternalValue();
     667           0 :         temp.setObjectOrNull(GetCallbackFromCallbackObject(currentValue));
     668           0 :         if (!MaybeWrapObjectValue(cx, &temp)) {
     669           0 :           return false;
     670             :         }
     671           0 :         if (!JS_DefinePropertyById(cx, obj, atomsCache->observe_id, temp, JSPROP_ENUMERATE)) {
     672           0 :           return false;
     673             :         }
     674           0 :         break;
     675             :       } while(0);
     676             :     }
     677             :   }
     678             : 
     679           0 :   if (mRedirect.WasPassed()) {
     680             :     do {
     681             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     682           0 :       JS::Rooted<JS::Value> temp(cx);
     683           0 :       RequestRedirect const & currentValue = mRedirect.InternalValue();
     684           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     685           0 :         return false;
     686             :       }
     687           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->redirect_id, temp, JSPROP_ENUMERATE)) {
     688           0 :         return false;
     689             :       }
     690           0 :       break;
     691             :     } while(0);
     692             :   }
     693             : 
     694           0 :   if (mReferrer.WasPassed()) {
     695             :     do {
     696             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     697           0 :       JS::Rooted<JS::Value> temp(cx);
     698           0 :       nsString const & currentValue = mReferrer.InternalValue();
     699           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     700           0 :         return false;
     701             :       }
     702           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->referrer_id, temp, JSPROP_ENUMERATE)) {
     703           0 :         return false;
     704             :       }
     705           0 :       break;
     706             :     } while(0);
     707             :   }
     708             : 
     709           0 :   if (mReferrerPolicy.WasPassed()) {
     710             :     do {
     711             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     712           0 :       JS::Rooted<JS::Value> temp(cx);
     713           0 :       ReferrerPolicy const & currentValue = mReferrerPolicy.InternalValue();
     714           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     715           0 :         return false;
     716             :       }
     717           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->referrerPolicy_id, temp, JSPROP_ENUMERATE)) {
     718           0 :         return false;
     719             :       }
     720           0 :       break;
     721             :     } while(0);
     722             :   }
     723             : 
     724           0 :   if (FetchController::IsEnabled(cx, obj)) {
     725           0 :     if (mSignal.WasPassed()) {
     726             :       do {
     727             :         // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     728           0 :         JS::Rooted<JS::Value> temp(cx);
     729           0 :         OwningNonNull<mozilla::dom::FetchSignal> const & currentValue = mSignal.InternalValue();
     730           0 :         if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     731           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     732           0 :           return false;
     733             :         }
     734           0 :         if (!JS_DefinePropertyById(cx, obj, atomsCache->signal_id, temp, JSPROP_ENUMERATE)) {
     735           0 :           return false;
     736             :         }
     737           0 :         break;
     738             :       } while(0);
     739             :     }
     740             :   }
     741             : 
     742           0 :   return true;
     743             : }
     744             : 
     745             : void
     746           0 : RequestInit::TraceDictionary(JSTracer* trc)
     747             : {
     748           0 :   if (mBody.WasPassed()) {
     749           0 :     if (!mBody.Value().IsNull()) {
     750           0 :       mBody.Value().Value().TraceUnion(trc);
     751             :     }
     752             :   }
     753           0 : }
     754             : 
     755             : namespace binding_detail {
     756             : } // namespace binding_detail
     757             : 
     758             : 
     759             : bool
     760           0 : RequestOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     761             : {
     762           0 :   switch (mType) {
     763             :     case eUninitialized: {
     764           0 :       return false;
     765             :       break;
     766             :     }
     767             :     case eRequest: {
     768           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mRequest.Value(), rval)) {
     769           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     770           0 :         return false;
     771             :       }
     772           0 :       return true;
     773             :       break;
     774             :     }
     775             :     case eUSVString: {
     776           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) {
     777           0 :         return false;
     778             :       }
     779           0 :       return true;
     780             :       break;
     781             :     }
     782             :     default: {
     783           0 :       return false;
     784             :       break;
     785             :     }
     786             :   }
     787             : 
     788             :   return false;
     789             : }
     790             : 
     791             : 
     792             : OwningNonNull<mozilla::dom::Request>&
     793           0 : OwningRequestOrUSVString::RawSetAsRequest()
     794             : {
     795           0 :   if (mType == eRequest) {
     796           0 :     return mValue.mRequest.Value();
     797             :   }
     798           0 :   MOZ_ASSERT(mType == eUninitialized);
     799           0 :   mType = eRequest;
     800           0 :   return mValue.mRequest.SetValue();
     801             : }
     802             : 
     803             : OwningNonNull<mozilla::dom::Request>&
     804           0 : OwningRequestOrUSVString::SetAsRequest()
     805             : {
     806           0 :   if (mType == eRequest) {
     807           0 :     return mValue.mRequest.Value();
     808             :   }
     809           0 :   Uninit();
     810           0 :   mType = eRequest;
     811           0 :   return mValue.mRequest.SetValue();
     812             : }
     813             : 
     814             : bool
     815           0 : OwningRequestOrUSVString::TrySetToRequest(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     816             : {
     817           0 :   tryNext = false;
     818             :   { // scope for memberSlot
     819           0 :     OwningNonNull<mozilla::dom::Request>& memberSlot = RawSetAsRequest();
     820             :     static_assert(IsRefcounted<mozilla::dom::Request>::value, "We can only store refcounted classes.");{
     821           0 :       nsresult rv = UnwrapObject<prototypes::id::Request, mozilla::dom::Request>(value, memberSlot);
     822           0 :       if (NS_FAILED(rv)) {
     823           0 :         DestroyRequest();
     824           0 :         tryNext = true;
     825           0 :         return true;
     826             :       }
     827             :     }
     828             :   }
     829           0 :   return true;
     830             : }
     831             : 
     832             : void
     833           0 : OwningRequestOrUSVString::DestroyRequest()
     834             : {
     835           0 :   MOZ_ASSERT(IsRequest(), "Wrong type!");
     836           0 :   mValue.mRequest.Destroy();
     837           0 :   mType = eUninitialized;
     838           0 : }
     839             : 
     840             : 
     841             : 
     842             : 
     843             : nsString&
     844           0 : OwningRequestOrUSVString::RawSetAsUSVString()
     845             : {
     846           0 :   if (mType == eUSVString) {
     847           0 :     return mValue.mUSVString.Value();
     848             :   }
     849           0 :   MOZ_ASSERT(mType == eUninitialized);
     850           0 :   mType = eUSVString;
     851           0 :   return mValue.mUSVString.SetValue();
     852             : }
     853             : 
     854             : nsString&
     855           0 : OwningRequestOrUSVString::SetAsUSVString()
     856             : {
     857           0 :   if (mType == eUSVString) {
     858           0 :     return mValue.mUSVString.Value();
     859             :   }
     860           0 :   Uninit();
     861           0 :   mType = eUSVString;
     862           0 :   return mValue.mUSVString.SetValue();
     863             : }
     864             : 
     865             : bool
     866           0 : OwningRequestOrUSVString::TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     867             : {
     868           0 :   tryNext = false;
     869             :   { // scope for memberSlot
     870           0 :     nsString& memberSlot = RawSetAsUSVString();
     871           0 :     if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
     872           0 :       return false;
     873             :     }
     874           0 :     NormalizeUSVString(memberSlot);
     875             :   }
     876           0 :   return true;
     877             : }
     878             : 
     879             : 
     880             : void
     881           0 : OwningRequestOrUSVString::DestroyUSVString()
     882             : {
     883           0 :   MOZ_ASSERT(IsUSVString(), "Wrong type!");
     884           0 :   mValue.mUSVString.Destroy();
     885           0 :   mType = eUninitialized;
     886           0 : }
     887             : 
     888             : 
     889             : 
     890             : 
     891             : void
     892           0 : OwningRequestOrUSVString::Uninit()
     893             : {
     894           0 :   switch (mType) {
     895             :     case eUninitialized: {
     896           0 :       break;
     897             :     }
     898             :     case eRequest: {
     899           0 :       DestroyRequest();
     900           0 :       break;
     901             :     }
     902             :     case eUSVString: {
     903           0 :       DestroyUSVString();
     904           0 :       break;
     905             :     }
     906             :   }
     907           0 : }
     908             : 
     909             : bool
     910           0 : OwningRequestOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     911             : {
     912           0 :   switch (mType) {
     913             :     case eUninitialized: {
     914           0 :       return false;
     915             :       break;
     916             :     }
     917             :     case eRequest: {
     918           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mRequest.Value(), rval)) {
     919           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     920           0 :         return false;
     921             :       }
     922           0 :       return true;
     923             :       break;
     924             :     }
     925             :     case eUSVString: {
     926           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) {
     927           0 :         return false;
     928             :       }
     929           0 :       return true;
     930             :       break;
     931             :     }
     932             :     default: {
     933           0 :       return false;
     934             :       break;
     935             :     }
     936             :   }
     937             : 
     938             :   return false;
     939             : }
     940             : 
     941             : void
     942           0 : OwningRequestOrUSVString::TraceUnion(JSTracer* trc)
     943             : {
     944           0 : }
     945             : 
     946             : OwningRequestOrUSVString&
     947           0 : OwningRequestOrUSVString::operator=(const OwningRequestOrUSVString& aOther)
     948             : {
     949           0 :   switch (aOther.mType) {
     950             :     case eUninitialized: {
     951           0 :       MOZ_ASSERT(mType == eUninitialized,
     952             :                  "We need to destroy ourselves?");
     953           0 :       break;
     954             :     }
     955             :     case eRequest: {
     956           0 :       SetAsRequest() = aOther.GetAsRequest();
     957           0 :       break;
     958             :     }
     959             :     case eUSVString: {
     960           0 :       SetAsUSVString() = aOther.GetAsUSVString();
     961           0 :       break;
     962             :     }
     963             :   }
     964           0 :   return *this;
     965             : }
     966             : 
     967             : 
     968             : namespace RequestBinding {
     969             : 
     970             : static bool
     971           0 : get_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
     972             : {
     973           0 :   nsCString result;
     974           0 :   self->GetMethod(result);
     975           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     976           0 :   if (!NonVoidByteStringToJsval(cx, result, args.rval())) {
     977           0 :     return false;
     978             :   }
     979           0 :   return true;
     980             : }
     981             : 
     982             : static const JSJitInfo method_getterinfo = {
     983             :   { (JSJitGetterOp)get_method },
     984             :   { prototypes::id::Request },
     985             :   { PrototypeTraits<prototypes::id::Request>::Depth },
     986             :   JSJitInfo::Getter,
     987             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     988             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     989             :   false,  /* isInfallible. False in setters. */
     990             :   false,  /* isMovable.  Not relevant for setters. */
     991             :   false, /* isEliminatable.  Not relevant for setters. */
     992             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     993             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     994             :   false,  /* isTypedMethod.  Only relevant for methods. */
     995             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     996             : };
     997             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     998             : static_assert(0 < 1, "There is no slot for us");
     999             : 
    1000             : static bool
    1001           0 : get_url(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1002             : {
    1003           0 :   DOMString result;
    1004           0 :   self->GetUrl(result);
    1005           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1006           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1007           0 :     return false;
    1008             :   }
    1009           0 :   return true;
    1010             : }
    1011             : 
    1012             : static const JSJitInfo url_getterinfo = {
    1013             :   { (JSJitGetterOp)get_url },
    1014             :   { prototypes::id::Request },
    1015             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1016             :   JSJitInfo::Getter,
    1017             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1018             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1019             :   false,  /* isInfallible. False in setters. */
    1020             :   false,  /* isMovable.  Not relevant for setters. */
    1021             :   false, /* isEliminatable.  Not relevant for setters. */
    1022             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1023             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1024             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1025             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1026             : };
    1027             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1028             : static_assert(0 < 1, "There is no slot for us");
    1029             : 
    1030             : static bool
    1031           0 : get_headers(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1032             : {
    1033           0 :   auto result(StrongOrRawPtr<mozilla::dom::Headers>(self->Headers_()));
    1034           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1035           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    1036           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1037           0 :     return false;
    1038             :   }
    1039           0 :   return true;
    1040             : }
    1041             : 
    1042             : static const JSJitInfo headers_getterinfo = {
    1043             :   { (JSJitGetterOp)get_headers },
    1044             :   { prototypes::id::Request },
    1045             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1046             :   JSJitInfo::Getter,
    1047             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
    1048             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1049             :   false,  /* isInfallible. False in setters. */
    1050             :   true,  /* isMovable.  Not relevant for setters. */
    1051             :   true, /* isEliminatable.  Not relevant for setters. */
    1052             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1053             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1054             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1055             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1056             : };
    1057             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1058             : static_assert(0 < 1, "There is no slot for us");
    1059             : 
    1060             : static bool
    1061           0 : get_context(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1062             : {
    1063           0 :   RequestContext result(self->Context());
    1064           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1065           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1066           0 :     return false;
    1067             :   }
    1068           0 :   return true;
    1069             : }
    1070             : 
    1071             : static const JSJitInfo context_getterinfo = {
    1072             :   { (JSJitGetterOp)get_context },
    1073             :   { prototypes::id::Request },
    1074             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1075             :   JSJitInfo::Getter,
    1076             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1077             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1078             :   false,  /* isInfallible. False in setters. */
    1079             :   false,  /* isMovable.  Not relevant for setters. */
    1080             :   false, /* isEliminatable.  Not relevant for setters. */
    1081             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1082             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1083             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1084             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1085             : };
    1086             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1087             : static_assert(0 < 1, "There is no slot for us");
    1088             : 
    1089             : static bool
    1090           0 : get_referrer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1091             : {
    1092           0 :   DOMString result;
    1093           0 :   self->GetReferrer(result);
    1094           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1095           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1096           0 :     return false;
    1097             :   }
    1098           0 :   return true;
    1099             : }
    1100             : 
    1101             : static const JSJitInfo referrer_getterinfo = {
    1102             :   { (JSJitGetterOp)get_referrer },
    1103             :   { prototypes::id::Request },
    1104             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1105             :   JSJitInfo::Getter,
    1106             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1107             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1108             :   false,  /* isInfallible. False in setters. */
    1109             :   false,  /* isMovable.  Not relevant for setters. */
    1110             :   false, /* isEliminatable.  Not relevant for setters. */
    1111             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1112             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1113             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1114             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1115             : };
    1116             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1117             : static_assert(0 < 1, "There is no slot for us");
    1118             : 
    1119             : static bool
    1120           0 : get_referrerPolicy(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1121             : {
    1122           0 :   ReferrerPolicy result(self->ReferrerPolicy_());
    1123           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1124           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1125           0 :     return false;
    1126             :   }
    1127           0 :   return true;
    1128             : }
    1129             : 
    1130             : static const JSJitInfo referrerPolicy_getterinfo = {
    1131             :   { (JSJitGetterOp)get_referrerPolicy },
    1132             :   { prototypes::id::Request },
    1133             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1134             :   JSJitInfo::Getter,
    1135             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1136             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1137             :   false,  /* isInfallible. False in setters. */
    1138             :   false,  /* isMovable.  Not relevant for setters. */
    1139             :   false, /* isEliminatable.  Not relevant for setters. */
    1140             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1141             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1142             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1143             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1144             : };
    1145             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1146             : static_assert(0 < 1, "There is no slot for us");
    1147             : 
    1148             : static bool
    1149           0 : get_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1150             : {
    1151           0 :   RequestMode result(self->Mode());
    1152           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1153           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1154           0 :     return false;
    1155             :   }
    1156           0 :   return true;
    1157             : }
    1158             : 
    1159             : static const JSJitInfo mode_getterinfo = {
    1160             :   { (JSJitGetterOp)get_mode },
    1161             :   { prototypes::id::Request },
    1162             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1163             :   JSJitInfo::Getter,
    1164             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1165             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1166             :   false,  /* isInfallible. False in setters. */
    1167             :   false,  /* isMovable.  Not relevant for setters. */
    1168             :   false, /* isEliminatable.  Not relevant for setters. */
    1169             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1170             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1171             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1172             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1173             : };
    1174             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1175             : static_assert(0 < 1, "There is no slot for us");
    1176             : 
    1177             : static bool
    1178           0 : get_credentials(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1179             : {
    1180           0 :   RequestCredentials result(self->Credentials());
    1181           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1182           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1183           0 :     return false;
    1184             :   }
    1185           0 :   return true;
    1186             : }
    1187             : 
    1188             : static const JSJitInfo credentials_getterinfo = {
    1189             :   { (JSJitGetterOp)get_credentials },
    1190             :   { prototypes::id::Request },
    1191             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1192             :   JSJitInfo::Getter,
    1193             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1194             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1195             :   false,  /* isInfallible. False in setters. */
    1196             :   false,  /* isMovable.  Not relevant for setters. */
    1197             :   false, /* isEliminatable.  Not relevant for setters. */
    1198             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1199             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1200             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1201             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1202             : };
    1203             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1204             : static_assert(0 < 1, "There is no slot for us");
    1205             : 
    1206             : static bool
    1207           0 : get_cache(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1208             : {
    1209           0 :   RequestCache result(self->Cache());
    1210           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1211           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1212           0 :     return false;
    1213             :   }
    1214           0 :   return true;
    1215             : }
    1216             : 
    1217             : static const JSJitInfo cache_getterinfo = {
    1218             :   { (JSJitGetterOp)get_cache },
    1219             :   { prototypes::id::Request },
    1220             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1221             :   JSJitInfo::Getter,
    1222             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1223             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1224             :   false,  /* isInfallible. False in setters. */
    1225             :   false,  /* isMovable.  Not relevant for setters. */
    1226             :   false, /* isEliminatable.  Not relevant for setters. */
    1227             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1228             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1229             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1230             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1231             : };
    1232             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1233             : static_assert(0 < 1, "There is no slot for us");
    1234             : 
    1235             : static bool
    1236           0 : get_redirect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1237             : {
    1238           0 :   RequestRedirect result(self->Redirect());
    1239           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1240           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1241           0 :     return false;
    1242             :   }
    1243           0 :   return true;
    1244             : }
    1245             : 
    1246             : static const JSJitInfo redirect_getterinfo = {
    1247             :   { (JSJitGetterOp)get_redirect },
    1248             :   { prototypes::id::Request },
    1249             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1250             :   JSJitInfo::Getter,
    1251             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1252             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1253             :   false,  /* isInfallible. False in setters. */
    1254             :   false,  /* isMovable.  Not relevant for setters. */
    1255             :   false, /* isEliminatable.  Not relevant for setters. */
    1256             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1257             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1258             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1259             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1260             : };
    1261             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1262             : static_assert(0 < 1, "There is no slot for us");
    1263             : 
    1264             : static bool
    1265           0 : get_integrity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1266             : {
    1267           0 :   DOMString result;
    1268           0 :   self->GetIntegrity(result);
    1269           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1270           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
    1271           0 :     return false;
    1272             :   }
    1273           0 :   return true;
    1274             : }
    1275             : 
    1276             : static const JSJitInfo integrity_getterinfo = {
    1277             :   { (JSJitGetterOp)get_integrity },
    1278             :   { prototypes::id::Request },
    1279             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1280             :   JSJitInfo::Getter,
    1281             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1282             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1283             :   false,  /* isInfallible. False in setters. */
    1284             :   false,  /* isMovable.  Not relevant for setters. */
    1285             :   false, /* isEliminatable.  Not relevant for setters. */
    1286             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1287             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1288             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1289             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1290             : };
    1291             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1292             : static_assert(0 < 1, "There is no slot for us");
    1293             : 
    1294             : static bool
    1295           0 : clone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1296             : {
    1297           0 :   binding_detail::FastErrorResult rv;
    1298           0 :   auto result(StrongOrRawPtr<mozilla::dom::Request>(self->Clone(rv)));
    1299           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1300           0 :     return false;
    1301             :   }
    1302           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1303             :   static_assert(!IsPointer<decltype(result)>::value,
    1304             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1305           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
    1306           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1307           0 :     return false;
    1308             :   }
    1309           0 :   return true;
    1310             : }
    1311             : 
    1312             : static const JSJitInfo clone_methodinfo = {
    1313             :   { (JSJitGetterOp)clone },
    1314             :   { prototypes::id::Request },
    1315             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1316             :   JSJitInfo::Method,
    1317             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1318             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1319             :   false,  /* isInfallible. False in setters. */
    1320             :   false,  /* isMovable.  Not relevant for setters. */
    1321             :   false, /* isEliminatable.  Not relevant for setters. */
    1322             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1323             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1324             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1325             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1326             : };
    1327             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1328             : static_assert(0 < 1, "There is no slot for us");
    1329             : 
    1330             : static bool
    1331           0 : overrideContentPolicyType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1332             : {
    1333           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1334           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Request.overrideContentPolicyType");
    1335             :   }
    1336             :   uint32_t arg0;
    1337           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
    1338           0 :     return false;
    1339             :   }
    1340           0 :   self->OverrideContentPolicyType(arg0);
    1341           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1342           0 :   args.rval().setUndefined();
    1343           0 :   return true;
    1344             : }
    1345             : 
    1346             : static const JSJitInfo overrideContentPolicyType_methodinfo = {
    1347             :   { (JSJitGetterOp)overrideContentPolicyType },
    1348             :   { prototypes::id::Request },
    1349             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1350             :   JSJitInfo::Method,
    1351             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1352             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1353             :   false,  /* isInfallible. False in setters. */
    1354             :   false,  /* isMovable.  Not relevant for setters. */
    1355             :   false, /* isEliminatable.  Not relevant for setters. */
    1356             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1357             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1358             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1359             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1360             : };
    1361             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1362             : static_assert(0 < 1, "There is no slot for us");
    1363             : 
    1364             : static bool
    1365           0 : get_bodyUsed(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, JSJitGetterCallArgs args)
    1366             : {
    1367           0 :   bool result(self->BodyUsed());
    1368           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1369           0 :   args.rval().setBoolean(result);
    1370           0 :   return true;
    1371             : }
    1372             : 
    1373             : static const JSJitInfo bodyUsed_getterinfo = {
    1374             :   { (JSJitGetterOp)get_bodyUsed },
    1375             :   { prototypes::id::Request },
    1376             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1377             :   JSJitInfo::Getter,
    1378             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1379             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
    1380             :   true,  /* isInfallible. False in setters. */
    1381             :   false,  /* isMovable.  Not relevant for setters. */
    1382             :   false, /* isEliminatable.  Not relevant for setters. */
    1383             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1384             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1385             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1386             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1387             : };
    1388             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1389             : static_assert(0 < 1, "There is no slot for us");
    1390             : 
    1391             : static bool
    1392           0 : arrayBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1393             : {
    1394           0 :   binding_detail::FastErrorResult rv;
    1395           0 :   auto result(StrongOrRawPtr<Promise>(self->ArrayBuffer(rv)));
    1396           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1397           0 :     return false;
    1398             :   }
    1399           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1400           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1401           0 :     return false;
    1402             :   }
    1403           0 :   return true;
    1404             : }
    1405             : 
    1406             : static bool
    1407           0 : arrayBuffer_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1408             : {
    1409             :   // Make sure to save the callee before someone maybe messes
    1410             :   // with rval().
    1411           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1412           0 :   bool ok = arrayBuffer(cx, obj, self, args);
    1413           0 :   if (ok) {
    1414           0 :     return true;
    1415             :   }
    1416           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1417           0 :                                    args.rval());
    1418             : }
    1419             : 
    1420             : static const JSJitInfo arrayBuffer_methodinfo = {
    1421             :   { (JSJitGetterOp)arrayBuffer_promiseWrapper },
    1422             :   { prototypes::id::Request },
    1423             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1424             :   JSJitInfo::Method,
    1425             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1426             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1427             :   false,  /* isInfallible. False in setters. */
    1428             :   false,  /* isMovable.  Not relevant for setters. */
    1429             :   false, /* isEliminatable.  Not relevant for setters. */
    1430             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1431             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1432             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1433             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1434             : };
    1435             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1436             : static_assert(0 < 1, "There is no slot for us");
    1437             : 
    1438             : static bool
    1439           0 : blob(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1440             : {
    1441           0 :   binding_detail::FastErrorResult rv;
    1442           0 :   auto result(StrongOrRawPtr<Promise>(self->Blob(rv)));
    1443           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1444           0 :     return false;
    1445             :   }
    1446           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1447           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1448           0 :     return false;
    1449             :   }
    1450           0 :   return true;
    1451             : }
    1452             : 
    1453             : static bool
    1454           0 : blob_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1455             : {
    1456             :   // Make sure to save the callee before someone maybe messes
    1457             :   // with rval().
    1458           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1459           0 :   bool ok = blob(cx, obj, self, args);
    1460           0 :   if (ok) {
    1461           0 :     return true;
    1462             :   }
    1463           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1464           0 :                                    args.rval());
    1465             : }
    1466             : 
    1467             : static const JSJitInfo blob_methodinfo = {
    1468             :   { (JSJitGetterOp)blob_promiseWrapper },
    1469             :   { prototypes::id::Request },
    1470             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1471             :   JSJitInfo::Method,
    1472             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1473             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1474             :   false,  /* isInfallible. False in setters. */
    1475             :   false,  /* isMovable.  Not relevant for setters. */
    1476             :   false, /* isEliminatable.  Not relevant for setters. */
    1477             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1478             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1479             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1480             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1481             : };
    1482             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1483             : static_assert(0 < 1, "There is no slot for us");
    1484             : 
    1485             : static bool
    1486           0 : formData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1487             : {
    1488           0 :   binding_detail::FastErrorResult rv;
    1489           0 :   auto result(StrongOrRawPtr<Promise>(self->FormData(rv)));
    1490           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1491           0 :     return false;
    1492             :   }
    1493           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1494           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1495           0 :     return false;
    1496             :   }
    1497           0 :   return true;
    1498             : }
    1499             : 
    1500             : static bool
    1501           0 : formData_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1502             : {
    1503             :   // Make sure to save the callee before someone maybe messes
    1504             :   // with rval().
    1505           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1506           0 :   bool ok = formData(cx, obj, self, args);
    1507           0 :   if (ok) {
    1508           0 :     return true;
    1509             :   }
    1510           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1511           0 :                                    args.rval());
    1512             : }
    1513             : 
    1514             : static const JSJitInfo formData_methodinfo = {
    1515             :   { (JSJitGetterOp)formData_promiseWrapper },
    1516             :   { prototypes::id::Request },
    1517             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1518             :   JSJitInfo::Method,
    1519             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1520             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1521             :   false,  /* isInfallible. False in setters. */
    1522             :   false,  /* isMovable.  Not relevant for setters. */
    1523             :   false, /* isEliminatable.  Not relevant for setters. */
    1524             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1525             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1526             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1527             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1528             : };
    1529             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1530             : static_assert(0 < 1, "There is no slot for us");
    1531             : 
    1532             : static bool
    1533           0 : json(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1534             : {
    1535           0 :   binding_detail::FastErrorResult rv;
    1536           0 :   auto result(StrongOrRawPtr<Promise>(self->Json(rv)));
    1537           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1538           0 :     return false;
    1539             :   }
    1540           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1541           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1542           0 :     return false;
    1543             :   }
    1544           0 :   return true;
    1545             : }
    1546             : 
    1547             : static bool
    1548           0 : json_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1549             : {
    1550             :   // Make sure to save the callee before someone maybe messes
    1551             :   // with rval().
    1552           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1553           0 :   bool ok = json(cx, obj, self, args);
    1554           0 :   if (ok) {
    1555           0 :     return true;
    1556             :   }
    1557           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1558           0 :                                    args.rval());
    1559             : }
    1560             : 
    1561             : static const JSJitInfo json_methodinfo = {
    1562             :   { (JSJitGetterOp)json_promiseWrapper },
    1563             :   { prototypes::id::Request },
    1564             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1565             :   JSJitInfo::Method,
    1566             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1567             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1568             :   false,  /* isInfallible. False in setters. */
    1569             :   false,  /* isMovable.  Not relevant for setters. */
    1570             :   false, /* isEliminatable.  Not relevant for setters. */
    1571             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1572             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1573             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1574             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1575             : };
    1576             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1577             : static_assert(0 < 1, "There is no slot for us");
    1578             : 
    1579             : static bool
    1580           0 : text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1581             : {
    1582           0 :   binding_detail::FastErrorResult rv;
    1583           0 :   auto result(StrongOrRawPtr<Promise>(self->Text(rv)));
    1584           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1585           0 :     return false;
    1586             :   }
    1587           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1588           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1589           0 :     return false;
    1590             :   }
    1591           0 :   return true;
    1592             : }
    1593             : 
    1594             : static bool
    1595           0 : text_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Request* self, const JSJitMethodCallArgs& args)
    1596             : {
    1597             :   // Make sure to save the callee before someone maybe messes
    1598             :   // with rval().
    1599           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
    1600           0 :   bool ok = text(cx, obj, self, args);
    1601           0 :   if (ok) {
    1602           0 :     return true;
    1603             :   }
    1604           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
    1605           0 :                                    args.rval());
    1606             : }
    1607             : 
    1608             : static const JSJitInfo text_methodinfo = {
    1609             :   { (JSJitGetterOp)text_promiseWrapper },
    1610             :   { prototypes::id::Request },
    1611             :   { PrototypeTraits<prototypes::id::Request>::Depth },
    1612             :   JSJitInfo::Method,
    1613             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1614             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1615             :   false,  /* isInfallible. False in setters. */
    1616             :   false,  /* isMovable.  Not relevant for setters. */
    1617             :   false, /* isEliminatable.  Not relevant for setters. */
    1618             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1619             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1620             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1621             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1622             : };
    1623             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1624             : static_assert(0 < 1, "There is no slot for us");
    1625             : 
    1626             : static bool
    1627           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1628             : {
    1629           0 :   mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj);
    1630             :   // We don't want to preserve if we don't have a wrapper, and we
    1631             :   // obviously can't preserve if we're not initialized.
    1632           0 :   if (self && self->GetWrapperPreserveColor()) {
    1633           0 :     PreserveWrapper(self);
    1634             :   }
    1635           0 :   return true;
    1636             : }
    1637             : 
    1638             : static void
    1639           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1640             : {
    1641           0 :   mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj);
    1642           0 :   if (self) {
    1643           0 :     ClearWrapper(self, self, obj);
    1644           0 :     AddForDeferredFinalization<mozilla::dom::Request>(self);
    1645             :   }
    1646           0 : }
    1647             : 
    1648             : static void
    1649           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1650             : {
    1651           0 :   mozilla::dom::Request* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Request>(obj);
    1652           0 :   if (self) {
    1653           0 :     UpdateWrapper(self, self, obj, old);
    1654             :   }
    1655           0 : }
    1656             : 
    1657             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1658             : #if defined(__clang__)
    1659             : #pragma clang diagnostic push
    1660             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1661             : #endif
    1662             : static const JSFunctionSpec sMethods_specs[] = {
    1663             :   JS_FNSPEC("clone", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clone_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1664             :   JS_FNSPEC("arrayBuffer", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&arrayBuffer_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1665             :   JS_FNSPEC("blob", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&blob_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1666             :   JS_FNSPEC("formData", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&formData_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1667             :   JS_FNSPEC("json", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&json_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1668             :   JS_FNSPEC("text", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&text_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1669             :   JS_FS_END
    1670             : };
    1671             : #if defined(__clang__)
    1672             : #pragma clang diagnostic pop
    1673             : #endif
    1674             : 
    1675             : 
    1676             : // Can't be const because the pref-enabled boolean needs to be writable
    1677             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1678             :   { nullptr, &sMethods_specs[0] },
    1679             :   { nullptr, nullptr }
    1680             : };
    1681             : 
    1682             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1683             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1684             : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1685             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1686             : 
    1687             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1688             : #if defined(__clang__)
    1689             : #pragma clang diagnostic push
    1690             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1691             : #endif
    1692             : static const JSFunctionSpec sChromeMethods_specs[] = {
    1693             :   JS_FNSPEC("overrideContentPolicyType", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&overrideContentPolicyType_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1694             :   JS_FS_END
    1695             : };
    1696             : #if defined(__clang__)
    1697             : #pragma clang diagnostic pop
    1698             : #endif
    1699             : 
    1700             : 
    1701             : // Can't be const because the pref-enabled boolean needs to be writable
    1702             : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
    1703             :   { nullptr, &sChromeMethods_specs[0] },
    1704             :   { nullptr, nullptr }
    1705             : };
    1706             : 
    1707             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1708             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1709             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1710             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1711             : 
    1712             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1713             : #if defined(__clang__)
    1714             : #pragma clang diagnostic push
    1715             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1716             : #endif
    1717             : static const JSPropertySpec sAttributes_specs[] = {
    1718             :   { "method", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &method_getterinfo, nullptr, nullptr },
    1719             :   { "url", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &url_getterinfo, nullptr, nullptr },
    1720             :   { "headers", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &headers_getterinfo, nullptr, nullptr },
    1721             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1722             :   { "context", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &context_getterinfo, nullptr, nullptr },
    1723             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
    1724             :   { "referrer", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &referrer_getterinfo, nullptr, nullptr },
    1725             :   { "referrerPolicy", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &referrerPolicy_getterinfo, nullptr, nullptr },
    1726             :   { "mode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mode_getterinfo, nullptr, nullptr },
    1727             :   { "credentials", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &credentials_getterinfo, nullptr, nullptr },
    1728             :   { "cache", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &cache_getterinfo, nullptr, nullptr },
    1729             :   { "redirect", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &redirect_getterinfo, nullptr, nullptr },
    1730             :   { "integrity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &integrity_getterinfo, nullptr, nullptr },
    1731             :   { "bodyUsed", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &bodyUsed_getterinfo, nullptr, nullptr },
    1732             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1733             : };
    1734             : #if defined(__clang__)
    1735             : #pragma clang diagnostic pop
    1736             : #endif
    1737             : 
    1738             : static PrefableDisablers sAttributes_disablers4 = {
    1739             :   true, false, 0, &mozilla::dom::Request::RequestContextEnabled
    1740             : };
    1741             : 
    1742             : // Can't be const because the pref-enabled boolean needs to be writable
    1743             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1744             :   { nullptr, &sAttributes_specs[0] },
    1745             :   { &sAttributes_disablers4, &sAttributes_specs[4] },
    1746             :   { nullptr, &sAttributes_specs[6] },
    1747             :   { nullptr, nullptr }
    1748             : };
    1749             : 
    1750             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1751             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1752             : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1753             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1754             : 
    1755             : 
    1756             : static uint16_t sNativeProperties_sortedPropertyIndices[18];
    1757             : static PropertyInfo sNativeProperties_propertyInfos[18];
    1758             : 
    1759             : static const NativePropertiesN<2> sNativeProperties = {
    1760             :   false, 0,
    1761             :   false, 0,
    1762             :   true,  0 /* sMethods */,
    1763             :   true,  1 /* sAttributes */,
    1764             :   false, 0,
    1765             :   false, 0,
    1766             :   false, 0,
    1767             :   -1,
    1768             :   18,
    1769             :   sNativeProperties_sortedPropertyIndices,
    1770             :   {
    1771             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1772             :     { sAttributes, &sNativeProperties_propertyInfos[6] }
    1773             :   }
    1774             : };
    1775             : static_assert(18 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1776             :     "We have a property info count that is oversized");
    1777             : 
    1778             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    1779             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    1780             : 
    1781             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    1782             :   false, 0,
    1783             :   false, 0,
    1784             :   true,  0 /* sChromeMethods */,
    1785             :   false, 0,
    1786             :   false, 0,
    1787             :   false, 0,
    1788             :   false, 0,
    1789             :   -1,
    1790             :   1,
    1791             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    1792             :   {
    1793             :     { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
    1794             :   }
    1795             : };
    1796             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    1797             :     "We have a property info count that is oversized");
    1798             : 
    1799             : static bool
    1800           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1801             : {
    1802           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1803           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1804           0 :   if (!args.isConstructing()) {
    1805             :     // XXXbz wish I could get the name from the callee instead of
    1806             :     // Adding more relocations
    1807           0 :     return ThrowConstructorWithoutNew(cx, "Request");
    1808             :   }
    1809             : 
    1810           0 :   GlobalObject global(cx, obj);
    1811           0 :   if (global.Failed()) {
    1812           0 :     return false;
    1813             :   }
    1814             : 
    1815           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    1816           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1817           0 :     return false;
    1818             :   }
    1819             : 
    1820           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1821           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Request");
    1822             :   }
    1823           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1824           0 :   RequestOrUSVString arg0;
    1825           0 :   RequestOrUSVStringArgument arg0_holder(arg0);
    1826             :   {
    1827           0 :     bool done = false, failed = false, tryNext;
    1828           0 :     if (args[0].isObject()) {
    1829           0 :       done = (failed = !arg0_holder.TrySetToRequest(cx, args[0], tryNext, false)) || !tryNext;
    1830             : 
    1831             :     }
    1832           0 :     if (!done) {
    1833             :       do {
    1834           0 :         done = (failed = !arg0_holder.TrySetToUSVString(cx, args[0], tryNext)) || !tryNext;
    1835           0 :         break;
    1836             :       } while (0);
    1837             :     }
    1838           0 :     if (failed) {
    1839           0 :       return false;
    1840             :     }
    1841           0 :     if (!done) {
    1842           0 :       ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of Request.constructor", "Request");
    1843           0 :       return false;
    1844             :     }
    1845             :   }
    1846           0 :   RootedDictionary<binding_detail::FastRequestInit> arg1(cx);
    1847           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of Request.constructor", false)) {
    1848           0 :     return false;
    1849             :   }
    1850           0 :   Maybe<JSAutoCompartment> ac;
    1851           0 :   if (objIsXray) {
    1852           0 :     obj = js::CheckedUnwrap(obj);
    1853           0 :     if (!obj) {
    1854           0 :       return false;
    1855             :     }
    1856           0 :     ac.emplace(cx, obj);
    1857           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    1858           0 :       return false;
    1859             :     }
    1860           0 :     if (arg1.mBody.WasPassed()) {
    1861           0 :       if (arg1.mBody.Value().Value().IsArrayBufferView()) {
    1862           0 :         if (!arg1.mBody.Value().Value().GetAsArrayBufferView().WrapIntoNewCompartment(cx)) {
    1863           0 :           return false;
    1864             :         }
    1865             :       }
    1866           0 :       else if (arg1.mBody.Value().Value().IsArrayBuffer()) {
    1867           0 :         if (!arg1.mBody.Value().Value().GetAsArrayBuffer().WrapIntoNewCompartment(cx)) {
    1868           0 :           return false;
    1869             :         }
    1870             :       }
    1871             :     }
    1872             :   }
    1873           0 :   binding_detail::FastErrorResult rv;
    1874           0 :   auto result(StrongOrRawPtr<mozilla::dom::Request>(mozilla::dom::Request::Constructor(global, Constify(arg0), Constify(arg1), rv)));
    1875           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1876           0 :     return false;
    1877             :   }
    1878           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1879             :   static_assert(!IsPointer<decltype(result)>::value,
    1880             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1881           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1882           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1883           0 :     return false;
    1884             :   }
    1885           0 :   return true;
    1886             : }
    1887             : 
    1888             : static const js::ClassOps sInterfaceObjectClassOps = {
    1889             :     nullptr,               /* addProperty */
    1890             :     nullptr,               /* delProperty */
    1891             :     nullptr,               /* getProperty */
    1892             :     nullptr,               /* setProperty */
    1893             :     nullptr,               /* enumerate */
    1894             :     nullptr,               /* newEnumerate */
    1895             :     nullptr,               /* resolve */
    1896             :     nullptr,               /* mayResolve */
    1897             :     nullptr,               /* finalize */
    1898             :     _constructor, /* call */
    1899             :     nullptr,               /* hasInstance */
    1900             :     _constructor, /* construct */
    1901             :     nullptr,               /* trace */
    1902             : };
    1903             : 
    1904             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1905             :   {
    1906             :     "Function",
    1907             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1908             :     &sInterfaceObjectClassOps,
    1909             :     JS_NULL_CLASS_SPEC,
    1910             :     JS_NULL_CLASS_EXT,
    1911             :     &sInterfaceObjectClassObjectOps
    1912             :   },
    1913             :   eInterface,
    1914             :   true,
    1915             :   prototypes::id::Request,
    1916             :   PrototypeTraits<prototypes::id::Request>::Depth,
    1917             :   sNativePropertyHooks,
    1918             :   "function Request() {\n    [native code]\n}",
    1919             :   JS::GetRealmFunctionPrototype
    1920             : };
    1921             : 
    1922             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1923             :   {
    1924             :     "RequestPrototype",
    1925             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1926             :     JS_NULL_CLASS_OPS,
    1927             :     JS_NULL_CLASS_SPEC,
    1928             :     JS_NULL_CLASS_EXT,
    1929             :     JS_NULL_OBJECT_OPS
    1930             :   },
    1931             :   eInterfacePrototype,
    1932             :   false,
    1933             :   prototypes::id::Request,
    1934             :   PrototypeTraits<prototypes::id::Request>::Depth,
    1935             :   sNativePropertyHooks,
    1936             :   "[object RequestPrototype]",
    1937             :   JS::GetRealmObjectPrototype
    1938             : };
    1939             : 
    1940             : JSObject*
    1941           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1942             : {
    1943           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1944             : }
    1945             : 
    1946             : static const js::ClassOps sClassOps = {
    1947             :   _addProperty, /* addProperty */
    1948             :   nullptr,               /* delProperty */
    1949             :   nullptr,               /* getProperty */
    1950             :   nullptr,               /* setProperty */
    1951             :   nullptr,               /* enumerate */
    1952             :   nullptr, /* newEnumerate */
    1953             :   nullptr, /* resolve */
    1954             :   nullptr, /* mayResolve */
    1955             :   _finalize, /* finalize */
    1956             :   nullptr, /* call */
    1957             :   nullptr,               /* hasInstance */
    1958             :   nullptr,               /* construct */
    1959             :   nullptr, /* trace */
    1960             : };
    1961             : 
    1962             : static const js::ClassExtension sClassExtension = {
    1963             :   nullptr, /* weakmapKeyDelegateOp */
    1964             :   _objectMoved /* objectMovedOp */
    1965             : };
    1966             : 
    1967             : static const DOMJSClass sClass = {
    1968             :   { "Request",
    1969             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1970             :     &sClassOps,
    1971             :     JS_NULL_CLASS_SPEC,
    1972             :     &sClassExtension,
    1973             :     JS_NULL_OBJECT_OPS
    1974             :   },
    1975             :   { prototypes::id::Request, 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 },
    1976             :   IsBaseOf<nsISupports, mozilla::dom::Request >::value,
    1977             :   sNativePropertyHooks,
    1978             :   FindAssociatedGlobalForNative<mozilla::dom::Request>::Get,
    1979             :   GetProtoObjectHandle,
    1980             :   GetCCParticipant<mozilla::dom::Request>::Get()
    1981             : };
    1982             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1983             :               "Must have the right minimal number of reserved slots.");
    1984             : static_assert(1 >= 1,
    1985             :               "Must have enough reserved slots.");
    1986             : 
    1987             : const JSClass*
    1988           0 : GetJSClass()
    1989             : {
    1990           0 :   return sClass.ToJSClass();
    1991             : }
    1992             : 
    1993             : bool
    1994           0 : Wrap(JSContext* aCx, mozilla::dom::Request* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1995             : {
    1996             :   MOZ_ASSERT(static_cast<mozilla::dom::Request*>(aObject) ==
    1997             :              reinterpret_cast<mozilla::dom::Request*>(aObject),
    1998             :              "Multiple inheritance for mozilla::dom::Request is broken.");
    1999           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2000           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2001           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2002             :              "You should probably not be using Wrap() directly; use "
    2003             :              "GetOrCreateDOMReflector instead");
    2004             : 
    2005           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2006             :              "nsISupports must be on our primary inheritance chain");
    2007             : 
    2008           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2009           0 :   if (!global) {
    2010           0 :     return false;
    2011             :   }
    2012           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2013           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2014             : 
    2015             :   // That might have ended up wrapping us already, due to the wonders
    2016             :   // of XBL.  Check for that, and bail out as needed.
    2017           0 :   aReflector.set(aCache->GetWrapper());
    2018           0 :   if (aReflector) {
    2019             : #ifdef DEBUG
    2020           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2021             : #endif // DEBUG
    2022           0 :     return true;
    2023             :   }
    2024             : 
    2025           0 :   JSAutoCompartment ac(aCx, global);
    2026           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2027           0 :   if (!canonicalProto) {
    2028           0 :     return false;
    2029             :   }
    2030           0 :   JS::Rooted<JSObject*> proto(aCx);
    2031           0 :   if (aGivenProto) {
    2032           0 :     proto = aGivenProto;
    2033             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2034             :     // coming in, we changed compartments to that of "parent" so may need
    2035             :     // to wrap the proto here.
    2036           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2037           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2038           0 :         return false;
    2039             :       }
    2040             :     }
    2041             :   } else {
    2042           0 :     proto = canonicalProto;
    2043             :   }
    2044             : 
    2045           0 :   BindingJSObjectCreator<mozilla::dom::Request> creator(aCx);
    2046           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2047           0 :   if (!aReflector) {
    2048           0 :     return false;
    2049             :   }
    2050             : 
    2051           0 :   aCache->SetWrapper(aReflector);
    2052           0 :   creator.InitializationSucceeded();
    2053             : 
    2054           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2055             :              aCache->GetWrapperPreserveColor() == aReflector);
    2056             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2057             :   // otherwise we won't be able to properly recreate it later, since
    2058             :   // we won't know what proto to use.  Note that we don't check
    2059             :   // aGivenProto here, since it's entirely possible (and even
    2060             :   // somewhat common) to have a non-null aGivenProto which is the
    2061             :   // same as canonicalProto.
    2062           0 :   if (proto != canonicalProto) {
    2063           0 :     PreserveWrapper(aObject);
    2064             :   }
    2065             : 
    2066           0 :   return true;
    2067             : }
    2068             : 
    2069             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2070             :   nullptr,
    2071             :   nullptr,
    2072             :   nullptr,
    2073             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    2074             :   prototypes::id::Request,
    2075             :   constructors::id::Request,
    2076             :   nullptr,
    2077             :   &DefaultXrayExpandoObjectClass
    2078             : } };
    2079             : 
    2080             : void
    2081           4 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2082             : {
    2083           8 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    2084           4 :   if (!parentProto) {
    2085           0 :     return;
    2086             :   }
    2087             : 
    2088           8 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    2089           4 :   if (!constructorProto) {
    2090           0 :     return;
    2091             :   }
    2092             : 
    2093             :   static bool sIdsInited = false;
    2094           4 :   if (!sIdsInited && NS_IsMainThread()) {
    2095           1 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2096           0 :       return;
    2097             :     }
    2098           1 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    2099           0 :       return;
    2100             :     }
    2101           1 :     sIdsInited = true;
    2102             :   }
    2103             : 
    2104           4 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Request);
    2105           4 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Request);
    2106          12 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2107             :                               &sPrototypeClass.mBase, protoCache,
    2108             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    2109             :                               interfaceCache,
    2110             :                               sNativeProperties.Upcast(),
    2111           4 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    2112             :                               "Request", aDefineOnGlobal,
    2113             :                               nullptr,
    2114           4 :                               false);
    2115             : }
    2116             : 
    2117             : JS::Handle<JSObject*>
    2118           0 : GetProtoObjectHandle(JSContext* aCx)
    2119             : {
    2120             :   /* Get the interface prototype object for this class.  This will create the
    2121             :      object as needed. */
    2122           0 :   bool aDefineOnGlobal = true;
    2123             : 
    2124             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2125           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2126           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2127           0 :     return nullptr;
    2128             :   }
    2129             : 
    2130             :   /* Check to see whether the interface objects are already installed */
    2131           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2132           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Request)) {
    2133           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2134           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2135             :   }
    2136             : 
    2137             :   /*
    2138             :    * The object might _still_ be null, but that's OK.
    2139             :    *
    2140             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2141             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2142             :    * changed after they have been set.
    2143             :    *
    2144             :    * Calling address() avoids the read read barrier that does gray
    2145             :    * unmarking, but it's not possible for the object to be gray here.
    2146             :    */
    2147             : 
    2148           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Request);
    2149           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2150           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2151             : }
    2152             : 
    2153             : JS::Handle<JSObject*>
    2154           4 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2155             : {
    2156             :   /* Get the interface object for this class.  This will create the object as
    2157             :      needed. */
    2158             : 
    2159             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2160           4 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2161           4 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2162           0 :     return nullptr;
    2163             :   }
    2164             : 
    2165             :   /* Check to see whether the interface objects are already installed */
    2166           4 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2167           4 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Request)) {
    2168           8 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2169           4 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2170             :   }
    2171             : 
    2172             :   /*
    2173             :    * The object might _still_ be null, but that's OK.
    2174             :    *
    2175             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2176             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2177             :    * changed after they have been set.
    2178             :    *
    2179             :    * Calling address() avoids the read read barrier that does gray
    2180             :    * unmarking, but it's not possible for the object to be gray here.
    2181             :    */
    2182             : 
    2183           4 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Request);
    2184           4 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2185           4 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2186             : }
    2187             : 
    2188             : JSObject*
    2189           4 : GetConstructorObject(JSContext* aCx)
    2190             : {
    2191           4 :   return GetConstructorObjectHandle(aCx);
    2192             : }
    2193             : 
    2194             : } // namespace RequestBinding
    2195             : 
    2196             : 
    2197             : 
    2198             : } // namespace dom
    2199             : } // namespace mozilla

Generated by: LCOV version 1.13