LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - URLSearchParamsBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 39 614 6.4 %
Date: 2017-07-14 16:53:18 Functions: 4 45 8.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM URLSearchParams.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "URLSearchParamsBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/DOMJSClass.h"
       8             : #include "mozilla/dom/IterableIterator.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/Nullable.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/ToJSValue.h"
      13             : #include "mozilla/dom/URLSearchParams.h"
      14             : #include "mozilla/dom/UnionConversions.h"
      15             : #include "mozilla/dom/XrayExpandoClass.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : bool
      21           0 : USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
      22             : {
      23           0 :   switch (mType) {
      24             :     case eUninitialized: {
      25           0 :       return false;
      26             :       break;
      27             :     }
      28             :     case eUSVStringSequenceSequence: {
      29             : 
      30           0 :       uint32_t length = mValue.mUSVStringSequenceSequence.Value().Length();
      31           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
      32           0 :       if (!returnArray) {
      33           0 :         return false;
      34             :       }
      35             :       // Scope for 'tmp'
      36             :       {
      37           0 :         JS::Rooted<JS::Value> tmp(cx);
      38           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
      39             :           // Control block to let us common up the JS_DefineElement calls when there
      40             :           // are different ways to succeed at wrapping the object.
      41             :           do {
      42             : 
      43           0 :             uint32_t length = mValue.mUSVStringSequenceSequence.Value()[sequenceIdx0].Length();
      44           0 :             JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
      45           0 :             if (!returnArray) {
      46           0 :               return false;
      47             :             }
      48             :             // Scope for 'tmp'
      49             :             {
      50           0 :               JS::Rooted<JS::Value> tmp(cx);
      51           0 :               for (uint32_t sequenceIdx1 = 0; sequenceIdx1 < length; ++sequenceIdx1) {
      52             :                 // Control block to let us common up the JS_DefineElement calls when there
      53             :                 // are different ways to succeed at wrapping the object.
      54             :                 do {
      55           0 :                   if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVStringSequenceSequence.Value()[sequenceIdx0][sequenceIdx1], &tmp)) {
      56           0 :                     return false;
      57             :                   }
      58           0 :                   break;
      59             :                 } while (0);
      60           0 :                 if (!JS_DefineElement(cx, returnArray, sequenceIdx1, tmp,
      61             :                                       JSPROP_ENUMERATE)) {
      62           0 :                   return false;
      63             :                 }
      64             :               }
      65             :             }
      66           0 :             tmp.setObject(*returnArray);
      67           0 :             break;
      68             :           } while (0);
      69           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
      70             :                                 JSPROP_ENUMERATE)) {
      71           0 :             return false;
      72             :           }
      73             :         }
      74             :       }
      75           0 :       rval.setObject(*returnArray);
      76           0 :       return true;
      77             :       break;
      78             :     }
      79             :     case eUSVStringUSVStringRecord: {
      80             : 
      81           0 :       JS::Rooted<JSObject*> returnObj(cx, JS_NewPlainObject(cx));
      82           0 :       if (!returnObj) {
      83           0 :         return false;
      84             :       }
      85             :       // Scope for 'tmp'
      86             :       {
      87           0 :         JS::Rooted<JS::Value> tmp(cx);
      88           0 :         for (auto& entry : mValue.mUSVStringUSVStringRecord.Value().Entries()) {
      89           0 :           auto& recordValue0 = entry.mValue;
      90             :           // Control block to let us common up the JS_DefineUCProperty calls when there
      91             :           // are different ways to succeed at wrapping the value.
      92             :           do {
      93           0 :             if (!xpc::NonVoidStringToJsval(cx, recordValue0, &tmp)) {
      94           0 :               return false;
      95             :             }
      96           0 :             break;
      97             :           } while (0);
      98           0 :           if (!JS_DefineUCProperty(cx, returnObj,
      99             :                                    entry.mKey.BeginReading(),
     100           0 :                                    entry.mKey.Length(), tmp,
     101             :                                    JSPROP_ENUMERATE)) {
     102           0 :             return false;
     103             :           }
     104             :         }
     105             :       }
     106           0 :       rval.setObject(*returnObj);
     107           0 :       return true;
     108             :       break;
     109             :     }
     110             :     case eUSVString: {
     111           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) {
     112           0 :         return false;
     113             :       }
     114           0 :       return true;
     115             :       break;
     116             :     }
     117             :     default: {
     118           0 :       return false;
     119             :       break;
     120             :     }
     121             :   }
     122             : 
     123             :   return false;
     124             : }
     125             : 
     126             : 
     127             : Sequence<Sequence<nsString>>&
     128           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::RawSetAsUSVStringSequenceSequence()
     129             : {
     130           0 :   if (mType == eUSVStringSequenceSequence) {
     131           0 :     return mValue.mUSVStringSequenceSequence.Value();
     132             :   }
     133           0 :   MOZ_ASSERT(mType == eUninitialized);
     134           0 :   mType = eUSVStringSequenceSequence;
     135           0 :   return mValue.mUSVStringSequenceSequence.SetValue();
     136             : }
     137             : 
     138             : Sequence<Sequence<nsString>>&
     139           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::SetAsUSVStringSequenceSequence()
     140             : {
     141           0 :   if (mType == eUSVStringSequenceSequence) {
     142           0 :     return mValue.mUSVStringSequenceSequence.Value();
     143             :   }
     144           0 :   Uninit();
     145           0 :   mType = eUSVStringSequenceSequence;
     146           0 :   return mValue.mUSVStringSequenceSequence.SetValue();
     147             : }
     148             : 
     149             : bool
     150           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TrySetToUSVStringSequenceSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     151             : {
     152           0 :   tryNext = false;
     153             :   { // scope for memberSlot
     154           0 :     Sequence<Sequence<nsString>>& memberSlot = RawSetAsUSVStringSequenceSequence();
     155           0 :     JS::ForOfIterator iter(cx);
     156           0 :     if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) {
     157           0 :       return false;
     158             :     }
     159           0 :     if (!iter.valueIsIterable()) {
     160           0 :       DestroyUSVStringSequenceSequence();
     161           0 :       tryNext = true;
     162           0 :       return true;
     163             :     }
     164           0 :     Sequence<Sequence<nsString>> &arr = memberSlot;
     165           0 :     JS::Rooted<JS::Value> temp(cx);
     166             :     while (true) {
     167             :       bool done;
     168           0 :       if (!iter.next(&temp, &done)) {
     169           0 :         return false;
     170             :       }
     171           0 :       if (done) {
     172           0 :         break;
     173             :       }
     174           0 :       Sequence<nsString>* slotPtr = arr.AppendElement(mozilla::fallible);
     175           0 :       if (!slotPtr) {
     176           0 :         JS_ReportOutOfMemory(cx);
     177           0 :         return false;
     178             :       }
     179           0 :       Sequence<nsString>& slot = *slotPtr;
     180           0 :       if (temp.isObject()) {
     181           0 :         JS::ForOfIterator iter1(cx);
     182           0 :         if (!iter1.init(temp, JS::ForOfIterator::AllowNonIterable)) {
     183           0 :           return false;
     184             :         }
     185           0 :         if (!iter1.valueIsIterable()) {
     186           0 :           ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Element of member of USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString");
     187           0 :           return false;
     188             :         }
     189           0 :         Sequence<nsString> &arr1 = slot;
     190           0 :         JS::Rooted<JS::Value> temp1(cx);
     191             :         while (true) {
     192             :           bool done1;
     193           0 :           if (!iter1.next(&temp1, &done1)) {
     194           0 :             return false;
     195             :           }
     196           0 :           if (done1) {
     197           0 :             break;
     198             :           }
     199           0 :           nsString* slotPtr1 = arr1.AppendElement(mozilla::fallible);
     200           0 :           if (!slotPtr1) {
     201           0 :             JS_ReportOutOfMemory(cx);
     202           0 :             return false;
     203             :           }
     204           0 :           nsString& slot1 = *slotPtr1;
     205           0 :           if (!ConvertJSValueToString(cx, temp1, eStringify, eStringify, slot1)) {
     206           0 :             return false;
     207             :           }
     208           0 :           NormalizeUSVString(slot1);
     209           0 :         }
     210             :       } else {
     211           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Element of member of USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString");
     212           0 :         return false;
     213             :       }
     214           0 :     }
     215             :   }
     216           0 :   return true;
     217             : }
     218             : 
     219             : void
     220           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::DestroyUSVStringSequenceSequence()
     221             : {
     222           0 :   MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
     223           0 :   mValue.mUSVStringSequenceSequence.Destroy();
     224           0 :   mType = eUninitialized;
     225           0 : }
     226             : 
     227             : 
     228             : 
     229             : 
     230             : Record<nsString, nsString>&
     231           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::RawSetAsUSVStringUSVStringRecord()
     232             : {
     233           0 :   if (mType == eUSVStringUSVStringRecord) {
     234           0 :     return mValue.mUSVStringUSVStringRecord.Value();
     235             :   }
     236           0 :   MOZ_ASSERT(mType == eUninitialized);
     237           0 :   mType = eUSVStringUSVStringRecord;
     238           0 :   return mValue.mUSVStringUSVStringRecord.SetValue();
     239             : }
     240             : 
     241             : Record<nsString, nsString>&
     242           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::SetAsUSVStringUSVStringRecord()
     243             : {
     244           0 :   if (mType == eUSVStringUSVStringRecord) {
     245           0 :     return mValue.mUSVStringUSVStringRecord.Value();
     246             :   }
     247           0 :   Uninit();
     248           0 :   mType = eUSVStringUSVStringRecord;
     249           0 :   return mValue.mUSVStringUSVStringRecord.SetValue();
     250             : }
     251             : 
     252             : bool
     253           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TrySetToUSVStringUSVStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     254             : {
     255           0 :   tryNext = false;
     256             :   { // scope for memberSlot
     257           0 :     Record<nsString, nsString>& memberSlot = RawSetAsUSVStringUSVStringRecord();
     258           0 :     auto& recordEntries = memberSlot.Entries();
     259             : 
     260           0 :     JS::Rooted<JSObject*> recordObj(cx, &value.toObject());
     261           0 :     JS::AutoIdVector ids(cx);
     262           0 :     if (!js::GetPropertyKeys(cx, recordObj,
     263             :                              JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &ids)) {
     264           0 :       return false;
     265             :     }
     266           0 :     if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
     267           0 :       JS_ReportOutOfMemory(cx);
     268           0 :       return false;
     269             :     }
     270           0 :     JS::Rooted<JS::Value> propNameValue(cx);
     271           0 :     JS::Rooted<JS::Value> temp(cx);
     272           0 :     JS::Rooted<jsid> curId(cx);
     273           0 :     JS::Rooted<JS::Value> idVal(cx);
     274             :     // Use a hashset to keep track of ids seen, to avoid
     275             :     // introducing nasty O(N^2) behavior scanning for them all the
     276             :     // time.  Ideally we'd use a data structure with O(1) lookup
     277             :     // _and_ ordering for the MozMap, but we don't have one lying
     278             :     // around.
     279           0 :     nsTHashtable<nsStringHashKey> idsSeen;
     280           0 :     for (size_t i = 0; i < ids.length(); ++i) {
     281           0 :       curId = ids[i];
     282             : 
     283           0 :       JS::Rooted<JS::PropertyDescriptor> desc(cx);
     284           0 :       if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
     285             :                                            &desc)) {
     286           0 :         return false;
     287             :       }
     288             : 
     289           0 :       if (!desc.object() /* == undefined in spec terms */ ||
     290           0 :           !desc.enumerable()) {
     291           0 :         continue;
     292             :       }
     293             : 
     294           0 :       idVal = js::IdToValue(curId);
     295           0 :       nsString propName;
     296             :       // This will just throw if idVal is a Symbol, like the spec says
     297             :       // to do.
     298           0 :       if (!ConvertJSValueToUSVString(cx, idVal, propName)) {
     299           0 :         return false;
     300             :       }
     301             : 
     302           0 :       if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
     303           0 :         return false;
     304             :       }
     305             : 
     306             :       Record<nsString, nsString>::EntryType* entry;
     307           0 :       if (!idsSeen.EnsureInserted(propName)) {
     308             :         // Find the existing entry.
     309           0 :         auto idx = recordEntries.IndexOf(propName);
     310           0 :         MOZ_ASSERT(idx != recordEntries.NoIndex,
     311             :                    "Why is it not found?");
     312             :         // Now blow it away to make it look like it was just added
     313             :         // to the array, because it's not obvious that it's
     314             :         // safe to write to its already-initialized mValue via our
     315             :         // normal codegen conversions.  For example, the value
     316             :         // could be a union and this would change its type, but
     317             :         // codegen assumes we won't do that.
     318           0 :         entry = recordEntries.ReconstructElementAt(idx);
     319             :       } else {
     320             :         // Safe to do an infallible append here, because we did a
     321             :         // SetCapacity above to the right capacity.
     322           0 :         entry = recordEntries.AppendElement();
     323             :       }
     324           0 :       entry->mKey = propName;
     325           0 :       nsString& slot = entry->mValue;
     326           0 :       if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
     327           0 :         return false;
     328             :       }
     329           0 :       NormalizeUSVString(slot);
     330             :     }
     331             :   }
     332           0 :   return true;
     333             : }
     334             : 
     335             : void
     336           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::DestroyUSVStringUSVStringRecord()
     337             : {
     338           0 :   MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
     339           0 :   mValue.mUSVStringUSVStringRecord.Destroy();
     340           0 :   mType = eUninitialized;
     341           0 : }
     342             : 
     343             : 
     344             : 
     345             : 
     346             : nsString&
     347           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::RawSetAsUSVString()
     348             : {
     349           0 :   if (mType == eUSVString) {
     350           0 :     return mValue.mUSVString.Value();
     351             :   }
     352           0 :   MOZ_ASSERT(mType == eUninitialized);
     353           0 :   mType = eUSVString;
     354           0 :   return mValue.mUSVString.SetValue();
     355             : }
     356             : 
     357             : nsString&
     358           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::SetAsUSVString()
     359             : {
     360           0 :   if (mType == eUSVString) {
     361           0 :     return mValue.mUSVString.Value();
     362             :   }
     363           0 :   Uninit();
     364           0 :   mType = eUSVString;
     365           0 :   return mValue.mUSVString.SetValue();
     366             : }
     367             : 
     368             : bool
     369           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     370             : {
     371           0 :   tryNext = false;
     372             :   { // scope for memberSlot
     373           0 :     nsString& memberSlot = RawSetAsUSVString();
     374           0 :     if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
     375           0 :       return false;
     376             :     }
     377           0 :     NormalizeUSVString(memberSlot);
     378             :   }
     379           0 :   return true;
     380             : }
     381             : 
     382             : 
     383             : void
     384           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::DestroyUSVString()
     385             : {
     386           0 :   MOZ_ASSERT(IsUSVString(), "Wrong type!");
     387           0 :   mValue.mUSVString.Destroy();
     388           0 :   mType = eUninitialized;
     389           0 : }
     390             : 
     391             : 
     392             : 
     393             : 
     394             : void
     395           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::Uninit()
     396             : {
     397           0 :   switch (mType) {
     398             :     case eUninitialized: {
     399           0 :       break;
     400             :     }
     401             :     case eUSVStringSequenceSequence: {
     402           0 :       DestroyUSVStringSequenceSequence();
     403           0 :       break;
     404             :     }
     405             :     case eUSVStringUSVStringRecord: {
     406           0 :       DestroyUSVStringUSVStringRecord();
     407           0 :       break;
     408             :     }
     409             :     case eUSVString: {
     410           0 :       DestroyUSVString();
     411           0 :       break;
     412             :     }
     413             :   }
     414           0 : }
     415             : 
     416             : bool
     417           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     418             : {
     419           0 :   switch (mType) {
     420             :     case eUninitialized: {
     421           0 :       return false;
     422             :       break;
     423             :     }
     424             :     case eUSVStringSequenceSequence: {
     425             : 
     426           0 :       uint32_t length = mValue.mUSVStringSequenceSequence.Value().Length();
     427           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     428           0 :       if (!returnArray) {
     429           0 :         return false;
     430             :       }
     431             :       // Scope for 'tmp'
     432             :       {
     433           0 :         JS::Rooted<JS::Value> tmp(cx);
     434           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     435             :           // Control block to let us common up the JS_DefineElement calls when there
     436             :           // are different ways to succeed at wrapping the object.
     437             :           do {
     438             : 
     439           0 :             uint32_t length = mValue.mUSVStringSequenceSequence.Value()[sequenceIdx0].Length();
     440           0 :             JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     441           0 :             if (!returnArray) {
     442           0 :               return false;
     443             :             }
     444             :             // Scope for 'tmp'
     445             :             {
     446           0 :               JS::Rooted<JS::Value> tmp(cx);
     447           0 :               for (uint32_t sequenceIdx1 = 0; sequenceIdx1 < length; ++sequenceIdx1) {
     448             :                 // Control block to let us common up the JS_DefineElement calls when there
     449             :                 // are different ways to succeed at wrapping the object.
     450             :                 do {
     451           0 :                   if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVStringSequenceSequence.Value()[sequenceIdx0][sequenceIdx1], &tmp)) {
     452           0 :                     return false;
     453             :                   }
     454           0 :                   break;
     455             :                 } while (0);
     456           0 :                 if (!JS_DefineElement(cx, returnArray, sequenceIdx1, tmp,
     457             :                                       JSPROP_ENUMERATE)) {
     458           0 :                   return false;
     459             :                 }
     460             :               }
     461             :             }
     462           0 :             tmp.setObject(*returnArray);
     463           0 :             break;
     464             :           } while (0);
     465           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     466             :                                 JSPROP_ENUMERATE)) {
     467           0 :             return false;
     468             :           }
     469             :         }
     470             :       }
     471           0 :       rval.setObject(*returnArray);
     472           0 :       return true;
     473             :       break;
     474             :     }
     475             :     case eUSVStringUSVStringRecord: {
     476             : 
     477           0 :       JS::Rooted<JSObject*> returnObj(cx, JS_NewPlainObject(cx));
     478           0 :       if (!returnObj) {
     479           0 :         return false;
     480             :       }
     481             :       // Scope for 'tmp'
     482             :       {
     483           0 :         JS::Rooted<JS::Value> tmp(cx);
     484           0 :         for (auto& entry : mValue.mUSVStringUSVStringRecord.Value().Entries()) {
     485           0 :           auto& recordValue0 = entry.mValue;
     486             :           // Control block to let us common up the JS_DefineUCProperty calls when there
     487             :           // are different ways to succeed at wrapping the value.
     488             :           do {
     489           0 :             if (!xpc::NonVoidStringToJsval(cx, recordValue0, &tmp)) {
     490           0 :               return false;
     491             :             }
     492           0 :             break;
     493             :           } while (0);
     494           0 :           if (!JS_DefineUCProperty(cx, returnObj,
     495             :                                    entry.mKey.BeginReading(),
     496           0 :                                    entry.mKey.Length(), tmp,
     497             :                                    JSPROP_ENUMERATE)) {
     498           0 :             return false;
     499             :           }
     500             :         }
     501             :       }
     502           0 :       rval.setObject(*returnObj);
     503           0 :       return true;
     504             :       break;
     505             :     }
     506             :     case eUSVString: {
     507           0 :       if (!xpc::NonVoidStringToJsval(cx, mValue.mUSVString.Value(), rval)) {
     508           0 :         return false;
     509             :       }
     510           0 :       return true;
     511             :       break;
     512             :     }
     513             :     default: {
     514           0 :       return false;
     515             :       break;
     516             :     }
     517             :   }
     518             : 
     519             :   return false;
     520             : }
     521             : 
     522             : void
     523           0 : OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::TraceUnion(JSTracer* trc)
     524             : {
     525           0 : }
     526             : 
     527             : 
     528             : namespace URLSearchParamsBinding {
     529             : 
     530             : static bool
     531           0 : append(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     532             : {
     533           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     534           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.append");
     535             :   }
     536           0 :   binding_detail::FakeString arg0;
     537           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     538           0 :     return false;
     539             :   }
     540           0 :   NormalizeUSVString(arg0);
     541           0 :   binding_detail::FakeString arg1;
     542           0 :   if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     543           0 :     return false;
     544             :   }
     545           0 :   NormalizeUSVString(arg1);
     546           0 :   self->Append(Constify(arg0), Constify(arg1));
     547           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     548           0 :   args.rval().setUndefined();
     549           0 :   return true;
     550             : }
     551             : 
     552             : static const JSJitInfo append_methodinfo = {
     553             :   { (JSJitGetterOp)append },
     554             :   { prototypes::id::URLSearchParams },
     555             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     556             :   JSJitInfo::Method,
     557             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     558             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     559             :   false,  /* isInfallible. False in setters. */
     560             :   false,  /* isMovable.  Not relevant for setters. */
     561             :   false, /* isEliminatable.  Not relevant for setters. */
     562             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     563             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     564             :   false,  /* isTypedMethod.  Only relevant for methods. */
     565             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     566             : };
     567             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     568             : static_assert(0 < 1, "There is no slot for us");
     569             : 
     570             : static bool
     571           0 : _delete_(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     572             : {
     573           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     574           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.delete");
     575             :   }
     576           0 :   binding_detail::FakeString arg0;
     577           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     578           0 :     return false;
     579             :   }
     580           0 :   NormalizeUSVString(arg0);
     581           0 :   self->Delete(Constify(arg0));
     582           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     583           0 :   args.rval().setUndefined();
     584           0 :   return true;
     585             : }
     586             : 
     587             : static const JSJitInfo delete_methodinfo = {
     588             :   { (JSJitGetterOp)_delete_ },
     589             :   { prototypes::id::URLSearchParams },
     590             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     591             :   JSJitInfo::Method,
     592             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     593             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     594             :   false,  /* isInfallible. False in setters. */
     595             :   false,  /* isMovable.  Not relevant for setters. */
     596             :   false, /* isEliminatable.  Not relevant for setters. */
     597             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     598             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     599             :   false,  /* isTypedMethod.  Only relevant for methods. */
     600             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     601             : };
     602             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     603             : static_assert(0 < 1, "There is no slot for us");
     604             : 
     605             : static bool
     606           0 : get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     607             : {
     608           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     609           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.get");
     610             :   }
     611           0 :   binding_detail::FakeString arg0;
     612           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     613           0 :     return false;
     614             :   }
     615           0 :   NormalizeUSVString(arg0);
     616           0 :   DOMString result;
     617           0 :   self->Get(Constify(arg0), result);
     618           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     619           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
     620           0 :     return false;
     621             :   }
     622           0 :   return true;
     623             : }
     624             : 
     625             : static const JSJitInfo get_methodinfo = {
     626             :   { (JSJitGetterOp)get },
     627             :   { prototypes::id::URLSearchParams },
     628             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     629             :   JSJitInfo::Method,
     630             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     631             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     632             :   false,  /* isInfallible. False in setters. */
     633             :   false,  /* isMovable.  Not relevant for setters. */
     634             :   false, /* isEliminatable.  Not relevant for setters. */
     635             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     636             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     637             :   false,  /* isTypedMethod.  Only relevant for methods. */
     638             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     639             : };
     640             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     641             : static_assert(0 < 1, "There is no slot for us");
     642             : 
     643             : static bool
     644           0 : getAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     645             : {
     646           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     647           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.getAll");
     648             :   }
     649           0 :   binding_detail::FakeString arg0;
     650           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     651           0 :     return false;
     652             :   }
     653           0 :   NormalizeUSVString(arg0);
     654           0 :   nsTArray<nsString> result;
     655           0 :   self->GetAll(Constify(arg0), result);
     656           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     657             : 
     658           0 :   uint32_t length = result.Length();
     659           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     660           0 :   if (!returnArray) {
     661           0 :     return false;
     662             :   }
     663             :   // Scope for 'tmp'
     664             :   {
     665           0 :     JS::Rooted<JS::Value> tmp(cx);
     666           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     667             :       // Control block to let us common up the JS_DefineElement calls when there
     668             :       // are different ways to succeed at wrapping the object.
     669             :       do {
     670           0 :         if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
     671           0 :           return false;
     672             :         }
     673           0 :         break;
     674             :       } while (0);
     675           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     676             :                             JSPROP_ENUMERATE)) {
     677           0 :         return false;
     678             :       }
     679             :     }
     680             :   }
     681           0 :   args.rval().setObject(*returnArray);
     682           0 :   return true;
     683             : }
     684             : 
     685             : static const JSJitInfo getAll_methodinfo = {
     686             :   { (JSJitGetterOp)getAll },
     687             :   { prototypes::id::URLSearchParams },
     688             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     689             :   JSJitInfo::Method,
     690             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     691             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     692             :   false,  /* isInfallible. False in setters. */
     693             :   false,  /* isMovable.  Not relevant for setters. */
     694             :   false, /* isEliminatable.  Not relevant for setters. */
     695             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     696             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     697             :   false,  /* isTypedMethod.  Only relevant for methods. */
     698             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     699             : };
     700             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     701             : static_assert(0 < 1, "There is no slot for us");
     702             : 
     703             : static bool
     704           0 : has(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     705             : {
     706           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     707           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.has");
     708             :   }
     709           0 :   binding_detail::FakeString arg0;
     710           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     711           0 :     return false;
     712             :   }
     713           0 :   NormalizeUSVString(arg0);
     714           0 :   bool result(self->Has(Constify(arg0)));
     715           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     716           0 :   args.rval().setBoolean(result);
     717           0 :   return true;
     718             : }
     719             : 
     720             : static const JSJitInfo has_methodinfo = {
     721             :   { (JSJitGetterOp)has },
     722             :   { prototypes::id::URLSearchParams },
     723             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     724             :   JSJitInfo::Method,
     725             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     726             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     727             :   false,  /* isInfallible. False in setters. */
     728             :   false,  /* isMovable.  Not relevant for setters. */
     729             :   false, /* isEliminatable.  Not relevant for setters. */
     730             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     731             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     732             :   false,  /* isTypedMethod.  Only relevant for methods. */
     733             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     734             : };
     735             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     736             : static_assert(0 < 1, "There is no slot for us");
     737             : 
     738             : static bool
     739           0 : set(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     740             : {
     741           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     742           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "URLSearchParams.set");
     743             :   }
     744           0 :   binding_detail::FakeString arg0;
     745           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     746           0 :     return false;
     747             :   }
     748           0 :   NormalizeUSVString(arg0);
     749           0 :   binding_detail::FakeString arg1;
     750           0 :   if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     751           0 :     return false;
     752             :   }
     753           0 :   NormalizeUSVString(arg1);
     754           0 :   self->Set(Constify(arg0), Constify(arg1));
     755           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     756           0 :   args.rval().setUndefined();
     757           0 :   return true;
     758             : }
     759             : 
     760             : static const JSJitInfo set_methodinfo = {
     761             :   { (JSJitGetterOp)set },
     762             :   { prototypes::id::URLSearchParams },
     763             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     764             :   JSJitInfo::Method,
     765             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     766             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     767             :   false,  /* isInfallible. False in setters. */
     768             :   false,  /* isMovable.  Not relevant for setters. */
     769             :   false, /* isEliminatable.  Not relevant for setters. */
     770             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     771             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     772             :   false,  /* isTypedMethod.  Only relevant for methods. */
     773             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     774             : };
     775             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     776             : static_assert(0 < 1, "There is no slot for us");
     777             : 
     778             : static bool
     779           0 : sort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     780             : {
     781           0 :   binding_detail::FastErrorResult rv;
     782           0 :   self->Sort(rv);
     783           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     784           0 :     return false;
     785             :   }
     786           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     787           0 :   args.rval().setUndefined();
     788           0 :   return true;
     789             : }
     790             : 
     791             : static const JSJitInfo sort_methodinfo = {
     792             :   { (JSJitGetterOp)sort },
     793             :   { prototypes::id::URLSearchParams },
     794             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     795             :   JSJitInfo::Method,
     796             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     797             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     798             :   false,  /* isInfallible. False in setters. */
     799             :   false,  /* isMovable.  Not relevant for setters. */
     800             :   false, /* isEliminatable.  Not relevant for setters. */
     801             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     802             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     803             :   false,  /* isTypedMethod.  Only relevant for methods. */
     804             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     805             : };
     806             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     807             : static_assert(0 < 1, "There is no slot for us");
     808             : 
     809             : static bool
     810           0 : __stringifier(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     811             : {
     812           0 :   DOMString result;
     813           0 :   self->Stringify(result);
     814           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     815           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     816           0 :     return false;
     817             :   }
     818           0 :   return true;
     819             : }
     820             : 
     821             : static const JSJitInfo __stringifier_methodinfo = {
     822             :   { (JSJitGetterOp)__stringifier },
     823             :   { prototypes::id::URLSearchParams },
     824             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     825             :   JSJitInfo::Method,
     826             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     827             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     828             :   false,  /* isInfallible. False in setters. */
     829             :   false,  /* isMovable.  Not relevant for setters. */
     830             :   false, /* isEliminatable.  Not relevant for setters. */
     831             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     832             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     833             :   false,  /* isTypedMethod.  Only relevant for methods. */
     834             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     835             : };
     836             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     837             : static_assert(0 < 1, "There is no slot for us");
     838             : 
     839             : static bool
     840           0 : entries(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     841             : {
     842             :   typedef mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> itrType;
     843             :   RefPtr<itrType> result(new itrType(self,
     844             :                                        itrType::IterableIteratorType::Entries,
     845           0 :                                        &URLSearchParamsIteratorBinding::Wrap));
     846             :   static_assert(!IsPointer<decltype(result)>::value,
     847             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     848           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
     849           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     850           0 :     return false;
     851             :   }
     852           0 :   return true;
     853             : }
     854             : 
     855             : static const JSJitInfo::ArgType entries_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
     856             : static const JSTypedMethodJitInfo entries_methodinfo = {
     857             :   {
     858             :     { (JSJitGetterOp)entries },
     859             :     { prototypes::id::URLSearchParams },
     860             :     { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     861             :     JSJitInfo::Method,
     862             :     JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     863             :     JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     864             :     false,  /* isInfallible. False in setters. */
     865             :     false,  /* isMovable.  Not relevant for setters. */
     866             :     false, /* isEliminatable.  Not relevant for setters. */
     867             :     false, /* isAlwaysInSlot.  Only relevant for getters. */
     868             :     false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     869             :     true,  /* isTypedMethod.  Only relevant for methods. */
     870             :     0   /* Reserved slot index, if we're stored in a slot, else 0. */
     871             :   },
     872             :   entries_methodinfo_argTypes
     873             : };
     874             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     875             : static_assert(0 < 1, "There is no slot for us");
     876             : 
     877             : static bool
     878           0 : keys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     879             : {
     880             :   typedef mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> itrType;
     881             :   RefPtr<itrType> result(new itrType(self,
     882             :                                        itrType::IterableIteratorType::Keys,
     883           0 :                                        &URLSearchParamsIteratorBinding::Wrap));
     884             :   static_assert(!IsPointer<decltype(result)>::value,
     885             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     886           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
     887           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     888           0 :     return false;
     889             :   }
     890           0 :   return true;
     891             : }
     892             : 
     893             : static const JSJitInfo::ArgType keys_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
     894             : static const JSTypedMethodJitInfo keys_methodinfo = {
     895             :   {
     896             :     { (JSJitGetterOp)keys },
     897             :     { prototypes::id::URLSearchParams },
     898             :     { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     899             :     JSJitInfo::Method,
     900             :     JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     901             :     JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     902             :     false,  /* isInfallible. False in setters. */
     903             :     false,  /* isMovable.  Not relevant for setters. */
     904             :     false, /* isEliminatable.  Not relevant for setters. */
     905             :     false, /* isAlwaysInSlot.  Only relevant for getters. */
     906             :     false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     907             :     true,  /* isTypedMethod.  Only relevant for methods. */
     908             :     0   /* Reserved slot index, if we're stored in a slot, else 0. */
     909             :   },
     910             :   keys_methodinfo_argTypes
     911             : };
     912             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     913             : static_assert(0 < 1, "There is no slot for us");
     914             : 
     915             : static bool
     916           0 : values(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     917             : {
     918             :   typedef mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> itrType;
     919             :   RefPtr<itrType> result(new itrType(self,
     920             :                                        itrType::IterableIteratorType::Values,
     921           0 :                                        &URLSearchParamsIteratorBinding::Wrap));
     922             :   static_assert(!IsPointer<decltype(result)>::value,
     923             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     924           0 :   if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
     925           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     926           0 :     return false;
     927             :   }
     928           0 :   return true;
     929             : }
     930             : 
     931             : static const JSJitInfo::ArgType values_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd };
     932             : static const JSTypedMethodJitInfo values_methodinfo = {
     933             :   {
     934             :     { (JSJitGetterOp)values },
     935             :     { prototypes::id::URLSearchParams },
     936             :     { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     937             :     JSJitInfo::Method,
     938             :     JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     939             :     JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     940             :     false,  /* isInfallible. False in setters. */
     941             :     false,  /* isMovable.  Not relevant for setters. */
     942             :     false, /* isEliminatable.  Not relevant for setters. */
     943             :     false, /* isAlwaysInSlot.  Only relevant for getters. */
     944             :     false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     945             :     true,  /* isTypedMethod.  Only relevant for methods. */
     946             :     0   /* Reserved slot index, if we're stored in a slot, else 0. */
     947             :   },
     948             :   values_methodinfo_argTypes
     949             : };
     950             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     951             : static_assert(0 < 1, "There is no slot for us");
     952             : 
     953             : static bool
     954           0 : forEach(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::URLSearchParams* self, const JSJitMethodCallArgs& args)
     955             : {
     956           0 :   JS::Rooted<JSObject*> arg0(cx);
     957           0 :   if (args.get(0).isObject()) {
     958           0 :     arg0 = &args.get(0).toObject();
     959             :   } else {
     960           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of URLSearchParams.forEach");
     961           0 :     return false;
     962             :   }
     963           0 :   JS::Rooted<JS::Value> arg1(cx);
     964           0 :   if (args.hasDefined(1)) {
     965           0 :     arg1 = args.get(1);
     966             :   } else {
     967           0 :     arg1 = JS::UndefinedValue();
     968             :   }
     969           0 :   if (!JS::IsCallable(arg0)) {
     970           0 :     ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of URLSearchParams.forEach");
     971           0 :     return false;
     972             :   }
     973           0 :   JS::AutoValueArray<3> callArgs(cx);
     974           0 :   callArgs[2].setObject(*obj);
     975           0 :   JS::Rooted<JS::Value> ignoredReturnVal(cx);
     976           0 :   for (size_t i = 0; i < self->GetIterableLength(); ++i) {
     977           0 :     if (!ToJSValue(cx, self->GetValueAtIndex(i), callArgs[0])) {
     978           0 :       return false;
     979             :     }
     980           0 :     if (!ToJSValue(cx, self->GetKeyAtIndex(i), callArgs[1])) {
     981           0 :       return false;
     982             :     }
     983           0 :     if (!JS::Call(cx, arg1, arg0, JS::HandleValueArray(callArgs),
     984             :                   &ignoredReturnVal)) {
     985           0 :       return false;
     986             :     }
     987             :   }
     988           0 :   args.rval().setUndefined();
     989           0 :   return true;
     990             : }
     991             : 
     992             : static const JSJitInfo forEach_methodinfo = {
     993             :   { (JSJitGetterOp)forEach },
     994             :   { prototypes::id::URLSearchParams },
     995             :   { PrototypeTraits<prototypes::id::URLSearchParams>::Depth },
     996             :   JSJitInfo::Method,
     997             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     998             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     999             :   false,  /* isInfallible. False in setters. */
    1000             :   false,  /* isMovable.  Not relevant for setters. */
    1001             :   false, /* isEliminatable.  Not relevant for setters. */
    1002             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1003             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1004             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1005             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1006             : };
    1007             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1008             : static_assert(0 < 1, "There is no slot for us");
    1009             : 
    1010             : static bool
    1011           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1012             : {
    1013           0 :   mozilla::dom::URLSearchParams* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URLSearchParams>(obj);
    1014             :   // We don't want to preserve if we don't have a wrapper, and we
    1015             :   // obviously can't preserve if we're not initialized.
    1016           0 :   if (self && self->GetWrapperPreserveColor()) {
    1017           0 :     PreserveWrapper(self);
    1018             :   }
    1019           0 :   return true;
    1020             : }
    1021             : 
    1022             : static void
    1023           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1024             : {
    1025           0 :   mozilla::dom::URLSearchParams* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URLSearchParams>(obj);
    1026           0 :   if (self) {
    1027           0 :     ClearWrapper(self, self, obj);
    1028           0 :     AddForDeferredFinalization<mozilla::dom::URLSearchParams>(self);
    1029             :   }
    1030           0 : }
    1031             : 
    1032             : static void
    1033           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1034             : {
    1035           0 :   mozilla::dom::URLSearchParams* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::URLSearchParams>(obj);
    1036           0 :   if (self) {
    1037           0 :     UpdateWrapper(self, self, obj, old);
    1038             :   }
    1039           0 : }
    1040             : 
    1041             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1042             : #if defined(__clang__)
    1043             : #pragma clang diagnostic push
    1044             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1045             : #endif
    1046             : static const JSFunctionSpec sMethods_specs[] = {
    1047             :   JS_FNSPEC("append", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&append_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    1048             :   JS_FNSPEC("delete", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&delete_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1049             :   JS_FNSPEC("get", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1050             :   JS_FNSPEC("getAll", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAll_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1051             :   JS_FNSPEC("has", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&has_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1052             :   JS_FNSPEC("set", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&set_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
    1053             :   JS_FNSPEC("sort", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&sort_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1054             :   JS_FNSPEC("entries", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&entries_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1055             :   JS_FNSPEC("keys", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&keys_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1056             :   JS_FNSPEC("values", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&values_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1057             :   JS_FNSPEC("forEach", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&forEach_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1058             :   JS_FNSPEC("toString", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&__stringifier_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1059             :   JS_FS_END
    1060             : };
    1061             : #if defined(__clang__)
    1062             : #pragma clang diagnostic pop
    1063             : #endif
    1064             : 
    1065             : 
    1066             : // Can't be const because the pref-enabled boolean needs to be writable
    1067             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1068             :   { nullptr, &sMethods_specs[0] },
    1069             :   { nullptr, nullptr }
    1070             : };
    1071             : 
    1072             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1073             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1074             : static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1075             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1076             : 
    1077             : 
    1078             : static uint16_t sNativeProperties_sortedPropertyIndices[12];
    1079             : static PropertyInfo sNativeProperties_propertyInfos[12];
    1080             : 
    1081             : static const NativePropertiesN<1> sNativeProperties = {
    1082             :   false, 0,
    1083             :   false, 0,
    1084             :   true,  0 /* sMethods */,
    1085             :   false, 0,
    1086             :   false, 0,
    1087             :   false, 0,
    1088             :   false, 0,
    1089             :   7,
    1090             :   12,
    1091             :   sNativeProperties_sortedPropertyIndices,
    1092             :   {
    1093             :     { sMethods, &sNativeProperties_propertyInfos[0] }
    1094             :   }
    1095             : };
    1096             : static_assert(7 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.iteratorAliasMethodIndex) - 1),
    1097             :     "We have an iterator alias index that is oversized");
    1098             : static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1099             :     "We have a property info count that is oversized");
    1100             : 
    1101             : static bool
    1102           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1103             : {
    1104           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1105           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1106           0 :   if (!args.isConstructing()) {
    1107             :     // XXXbz wish I could get the name from the callee instead of
    1108             :     // Adding more relocations
    1109           0 :     return ThrowConstructorWithoutNew(cx, "URLSearchParams");
    1110             :   }
    1111             : 
    1112           0 :   GlobalObject global(cx, obj);
    1113           0 :   if (global.Failed()) {
    1114           0 :     return false;
    1115             :   }
    1116             : 
    1117           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    1118           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1119           0 :     return false;
    1120             :   }
    1121             : 
    1122           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1123           0 :   USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString arg0;
    1124           0 :   USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVStringArgument arg0_holder(arg0);
    1125           0 :   if (!(args.hasDefined(0))) {
    1126             :     static const char16_t data[] = { 0 };
    1127           0 :     arg0_holder.SetStringData(data, ArrayLength(data) - 1);
    1128             :   } else {
    1129             :     {
    1130           0 :       bool done = false, failed = false, tryNext;
    1131           0 :       if (args[0].isObject()) {
    1132           0 :         done = (failed = !arg0_holder.TrySetToUSVStringSequenceSequence(cx, args[0], tryNext, false)) || !tryNext;
    1133           0 :         if (!done) {
    1134           0 :           done = (failed = !arg0_holder.TrySetToUSVStringUSVStringRecord(cx, args[0], tryNext, false)) || !tryNext;
    1135             :         }
    1136             :       }
    1137           0 :       if (!done) {
    1138             :         do {
    1139           0 :           done = (failed = !arg0_holder.TrySetToUSVString(cx, args[0], tryNext)) || !tryNext;
    1140           0 :           break;
    1141             :         } while (0);
    1142             :       }
    1143           0 :       if (failed) {
    1144           0 :         return false;
    1145             :       }
    1146           0 :       if (!done) {
    1147           0 :         ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of URLSearchParams.constructor", "USVStringSequenceSequence, USVStringUSVStringRecord");
    1148           0 :         return false;
    1149             :       }
    1150             :     }
    1151             :   }
    1152           0 :   Maybe<JSAutoCompartment> ac;
    1153           0 :   if (objIsXray) {
    1154           0 :     obj = js::CheckedUnwrap(obj);
    1155           0 :     if (!obj) {
    1156           0 :       return false;
    1157             :     }
    1158           0 :     ac.emplace(cx, obj);
    1159           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
    1160           0 :       return false;
    1161             :     }
    1162             :   }
    1163           0 :   binding_detail::FastErrorResult rv;
    1164           0 :   auto result(StrongOrRawPtr<mozilla::dom::URLSearchParams>(mozilla::dom::URLSearchParams::Constructor(global, Constify(arg0), rv)));
    1165           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1166           0 :     return false;
    1167             :   }
    1168           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1169             :   static_assert(!IsPointer<decltype(result)>::value,
    1170             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
    1171           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1172           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1173           0 :     return false;
    1174             :   }
    1175           0 :   return true;
    1176             : }
    1177             : 
    1178             : static const js::ClassOps sInterfaceObjectClassOps = {
    1179             :     nullptr,               /* addProperty */
    1180             :     nullptr,               /* delProperty */
    1181             :     nullptr,               /* getProperty */
    1182             :     nullptr,               /* setProperty */
    1183             :     nullptr,               /* enumerate */
    1184             :     nullptr,               /* newEnumerate */
    1185             :     nullptr,               /* resolve */
    1186             :     nullptr,               /* mayResolve */
    1187             :     nullptr,               /* finalize */
    1188             :     _constructor, /* call */
    1189             :     nullptr,               /* hasInstance */
    1190             :     _constructor, /* construct */
    1191             :     nullptr,               /* trace */
    1192             : };
    1193             : 
    1194             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1195             :   {
    1196             :     "Function",
    1197             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1198             :     &sInterfaceObjectClassOps,
    1199             :     JS_NULL_CLASS_SPEC,
    1200             :     JS_NULL_CLASS_EXT,
    1201             :     &sInterfaceObjectClassObjectOps
    1202             :   },
    1203             :   eInterface,
    1204             :   true,
    1205             :   prototypes::id::URLSearchParams,
    1206             :   PrototypeTraits<prototypes::id::URLSearchParams>::Depth,
    1207             :   sNativePropertyHooks,
    1208             :   "function URLSearchParams() {\n    [native code]\n}",
    1209             :   JS::GetRealmFunctionPrototype
    1210             : };
    1211             : 
    1212             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1213             :   {
    1214             :     "URLSearchParamsPrototype",
    1215             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1216             :     JS_NULL_CLASS_OPS,
    1217             :     JS_NULL_CLASS_SPEC,
    1218             :     JS_NULL_CLASS_EXT,
    1219             :     JS_NULL_OBJECT_OPS
    1220             :   },
    1221             :   eInterfacePrototype,
    1222             :   false,
    1223             :   prototypes::id::URLSearchParams,
    1224             :   PrototypeTraits<prototypes::id::URLSearchParams>::Depth,
    1225             :   sNativePropertyHooks,
    1226             :   "[object URLSearchParamsPrototype]",
    1227             :   JS::GetRealmObjectPrototype
    1228             : };
    1229             : 
    1230             : JSObject*
    1231           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1232             : {
    1233           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1234             : }
    1235             : 
    1236             : static const js::ClassOps sClassOps = {
    1237             :   _addProperty, /* addProperty */
    1238             :   nullptr,               /* delProperty */
    1239             :   nullptr,               /* getProperty */
    1240             :   nullptr,               /* setProperty */
    1241             :   nullptr,               /* enumerate */
    1242             :   nullptr, /* newEnumerate */
    1243             :   nullptr, /* resolve */
    1244             :   nullptr, /* mayResolve */
    1245             :   _finalize, /* finalize */
    1246             :   nullptr, /* call */
    1247             :   nullptr,               /* hasInstance */
    1248             :   nullptr,               /* construct */
    1249             :   nullptr, /* trace */
    1250             : };
    1251             : 
    1252             : static const js::ClassExtension sClassExtension = {
    1253             :   nullptr, /* weakmapKeyDelegateOp */
    1254             :   _objectMoved /* objectMovedOp */
    1255             : };
    1256             : 
    1257             : static const DOMJSClass sClass = {
    1258             :   { "URLSearchParams",
    1259             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1260             :     &sClassOps,
    1261             :     JS_NULL_CLASS_SPEC,
    1262             :     &sClassExtension,
    1263             :     JS_NULL_OBJECT_OPS
    1264             :   },
    1265             :   { prototypes::id::URLSearchParams, 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 },
    1266             :   IsBaseOf<nsISupports, mozilla::dom::URLSearchParams >::value,
    1267             :   sNativePropertyHooks,
    1268             :   FindAssociatedGlobalForNative<mozilla::dom::URLSearchParams>::Get,
    1269             :   GetProtoObjectHandle,
    1270             :   GetCCParticipant<mozilla::dom::URLSearchParams>::Get()
    1271             : };
    1272             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1273             :               "Must have the right minimal number of reserved slots.");
    1274             : static_assert(1 >= 1,
    1275             :               "Must have enough reserved slots.");
    1276             : 
    1277             : const JSClass*
    1278           0 : GetJSClass()
    1279             : {
    1280           0 :   return sClass.ToJSClass();
    1281             : }
    1282             : 
    1283             : bool
    1284           0 : Wrap(JSContext* aCx, mozilla::dom::URLSearchParams* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1285             : {
    1286             :   MOZ_ASSERT(static_cast<mozilla::dom::URLSearchParams*>(aObject) ==
    1287             :              reinterpret_cast<mozilla::dom::URLSearchParams*>(aObject),
    1288             :              "Multiple inheritance for mozilla::dom::URLSearchParams is broken.");
    1289           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1290           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1291           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1292             :              "You should probably not be using Wrap() directly; use "
    1293             :              "GetOrCreateDOMReflector instead");
    1294             : 
    1295           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1296             :              "nsISupports must be on our primary inheritance chain");
    1297             : 
    1298           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1299           0 :   if (!global) {
    1300           0 :     return false;
    1301             :   }
    1302           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1303           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1304             : 
    1305             :   // That might have ended up wrapping us already, due to the wonders
    1306             :   // of XBL.  Check for that, and bail out as needed.
    1307           0 :   aReflector.set(aCache->GetWrapper());
    1308           0 :   if (aReflector) {
    1309             : #ifdef DEBUG
    1310           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1311             : #endif // DEBUG
    1312           0 :     return true;
    1313             :   }
    1314             : 
    1315           0 :   JSAutoCompartment ac(aCx, global);
    1316           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1317           0 :   if (!canonicalProto) {
    1318           0 :     return false;
    1319             :   }
    1320           0 :   JS::Rooted<JSObject*> proto(aCx);
    1321           0 :   if (aGivenProto) {
    1322           0 :     proto = aGivenProto;
    1323             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1324             :     // coming in, we changed compartments to that of "parent" so may need
    1325             :     // to wrap the proto here.
    1326           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1327           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1328           0 :         return false;
    1329             :       }
    1330             :     }
    1331             :   } else {
    1332           0 :     proto = canonicalProto;
    1333             :   }
    1334             : 
    1335           0 :   BindingJSObjectCreator<mozilla::dom::URLSearchParams> creator(aCx);
    1336           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1337           0 :   if (!aReflector) {
    1338           0 :     return false;
    1339             :   }
    1340             : 
    1341           0 :   aCache->SetWrapper(aReflector);
    1342           0 :   creator.InitializationSucceeded();
    1343             : 
    1344           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1345             :              aCache->GetWrapperPreserveColor() == aReflector);
    1346             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1347             :   // otherwise we won't be able to properly recreate it later, since
    1348             :   // we won't know what proto to use.  Note that we don't check
    1349             :   // aGivenProto here, since it's entirely possible (and even
    1350             :   // somewhat common) to have a non-null aGivenProto which is the
    1351             :   // same as canonicalProto.
    1352           0 :   if (proto != canonicalProto) {
    1353           0 :     PreserveWrapper(aObject);
    1354             :   }
    1355             : 
    1356           0 :   return true;
    1357             : }
    1358             : 
    1359             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1360             :   nullptr,
    1361             :   nullptr,
    1362             :   nullptr,
    1363             :   { sNativeProperties.Upcast(), nullptr },
    1364             :   prototypes::id::URLSearchParams,
    1365             :   constructors::id::URLSearchParams,
    1366             :   nullptr,
    1367             :   &DefaultXrayExpandoObjectClass
    1368             : } };
    1369             : 
    1370             : void
    1371           3 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1372             : {
    1373           6 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1374           3 :   if (!parentProto) {
    1375           0 :     return;
    1376             :   }
    1377             : 
    1378           6 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1379           3 :   if (!constructorProto) {
    1380           0 :     return;
    1381             :   }
    1382             : 
    1383             :   static bool sIdsInited = false;
    1384           3 :   if (!sIdsInited && NS_IsMainThread()) {
    1385           2 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1386           0 :       return;
    1387             :     }
    1388           2 :     sIdsInited = true;
    1389             :   }
    1390             : 
    1391           3 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::URLSearchParams);
    1392           3 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::URLSearchParams);
    1393           6 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1394             :                               &sPrototypeClass.mBase, protoCache,
    1395             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1396             :                               interfaceCache,
    1397             :                               sNativeProperties.Upcast(),
    1398             :                               nullptr,
    1399             :                               "URLSearchParams", aDefineOnGlobal,
    1400             :                               nullptr,
    1401           3 :                               false);
    1402             : 
    1403             :   // Set up aliases on the interface prototype object we just created.
    1404           3 :   JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx);
    1405           3 :   if (!proto) {
    1406           0 :     *protoCache = nullptr;
    1407           0 :     if (interfaceCache) {
    1408           0 :       *interfaceCache = nullptr;
    1409             :     }
    1410           0 :     return;
    1411             :   }
    1412             : 
    1413           6 :   JS::Rooted<JS::Value> aliasedVal(aCx);
    1414             : 
    1415           3 :   if (!JS_GetProperty(aCx, proto, "entries", &aliasedVal)) {
    1416           0 :     *protoCache = nullptr;
    1417           0 :     if (interfaceCache) {
    1418           0 :       *interfaceCache = nullptr;
    1419             :     }
    1420           0 :     return;
    1421             :   }
    1422           6 :   JS::Rooted<jsid> iteratorId(aCx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::iterator)));
    1423           3 :   if (!JS_DefinePropertyById(aCx, proto, iteratorId, aliasedVal, 0)) {
    1424           0 :     *protoCache = nullptr;
    1425           0 :     if (interfaceCache) {
    1426           0 :       *interfaceCache = nullptr;
    1427             :     }
    1428           0 :     return;
    1429             :   }
    1430             : }
    1431             : 
    1432             : JS::Handle<JSObject*>
    1433           3 : GetProtoObjectHandle(JSContext* aCx)
    1434             : {
    1435             :   /* Get the interface prototype object for this class.  This will create the
    1436             :      object as needed. */
    1437           3 :   bool aDefineOnGlobal = true;
    1438             : 
    1439             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1440           3 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1441           3 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1442           0 :     return nullptr;
    1443             :   }
    1444             : 
    1445             :   /* Check to see whether the interface objects are already installed */
    1446           3 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1447           3 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::URLSearchParams)) {
    1448           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1449           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1450             :   }
    1451             : 
    1452             :   /*
    1453             :    * The object might _still_ be null, but that's OK.
    1454             :    *
    1455             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1456             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1457             :    * changed after they have been set.
    1458             :    *
    1459             :    * Calling address() avoids the read read barrier that does gray
    1460             :    * unmarking, but it's not possible for the object to be gray here.
    1461             :    */
    1462             : 
    1463           3 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::URLSearchParams);
    1464           3 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1465           3 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1466             : }
    1467             : 
    1468             : JS::Handle<JSObject*>
    1469           3 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1470             : {
    1471             :   /* Get the interface object for this class.  This will create the object as
    1472             :      needed. */
    1473             : 
    1474             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1475           3 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1476           3 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1477           0 :     return nullptr;
    1478             :   }
    1479             : 
    1480             :   /* Check to see whether the interface objects are already installed */
    1481           3 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1482           3 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::URLSearchParams)) {
    1483           6 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1484           3 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1485             :   }
    1486             : 
    1487             :   /*
    1488             :    * The object might _still_ be null, but that's OK.
    1489             :    *
    1490             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1491             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1492             :    * changed after they have been set.
    1493             :    *
    1494             :    * Calling address() avoids the read read barrier that does gray
    1495             :    * unmarking, but it's not possible for the object to be gray here.
    1496             :    */
    1497             : 
    1498           3 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::URLSearchParams);
    1499           3 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1500           3 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1501             : }
    1502             : 
    1503             : JSObject*
    1504           3 : GetConstructorObject(JSContext* aCx)
    1505             : {
    1506           3 :   return GetConstructorObjectHandle(aCx);
    1507             : }
    1508             : 
    1509             : } // namespace URLSearchParamsBinding
    1510             : 
    1511             : 
    1512             : 
    1513             : namespace URLSearchParamsIteratorBinding {
    1514             : 
    1515             : static bool
    1516           0 : next(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>* self, const JSJitMethodCallArgs& args)
    1517             : {
    1518           0 :   binding_detail::FastErrorResult rv;
    1519           0 :   JS::Rooted<JSObject*> result(cx);
    1520           0 :   self->Next(cx, &result, rv);
    1521           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1522           0 :     return false;
    1523             :   }
    1524           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1525           0 :   JS::ExposeObjectToActiveJS(result);
    1526           0 :   args.rval().setObject(*result);
    1527           0 :   if (!MaybeWrapObjectValue(cx, args.rval())) {
    1528           0 :     return false;
    1529             :   }
    1530           0 :   return true;
    1531             : }
    1532             : 
    1533             : static const JSJitInfo next_methodinfo = {
    1534             :   { (JSJitGetterOp)next },
    1535             :   { prototypes::id::URLSearchParamsIterator },
    1536             :   { PrototypeTraits<prototypes::id::URLSearchParamsIterator>::Depth },
    1537             :   JSJitInfo::Method,
    1538             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1539             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    1540             :   false,  /* isInfallible. False in setters. */
    1541             :   false,  /* isMovable.  Not relevant for setters. */
    1542             :   false, /* isEliminatable.  Not relevant for setters. */
    1543             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1544             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1545             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1546             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1547             : };
    1548             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1549             : static_assert(0 < 1, "There is no slot for us");
    1550             : 
    1551             : static void
    1552           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1553             : {
    1554           0 :   mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>>(obj);
    1555           0 :   if (self) {
    1556           0 :     AddForDeferredFinalization<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>>(self);
    1557             :   }
    1558           0 : }
    1559             : 
    1560             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1561             : #if defined(__clang__)
    1562             : #pragma clang diagnostic push
    1563             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1564             : #endif
    1565             : static const JSFunctionSpec sMethods_specs[] = {
    1566             :   JS_FNSPEC("next", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&next_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    1567             :   JS_FS_END
    1568             : };
    1569             : #if defined(__clang__)
    1570             : #pragma clang diagnostic pop
    1571             : #endif
    1572             : 
    1573             : 
    1574             : // Can't be const because the pref-enabled boolean needs to be writable
    1575             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1576             :   { nullptr, &sMethods_specs[0] },
    1577             :   { nullptr, nullptr }
    1578             : };
    1579             : 
    1580             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1581             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1582             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1583             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1584             : 
    1585             : 
    1586             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
    1587             : static PropertyInfo sNativeProperties_propertyInfos[1];
    1588             : 
    1589             : static const NativePropertiesN<1> sNativeProperties = {
    1590             :   false, 0,
    1591             :   false, 0,
    1592             :   true,  0 /* sMethods */,
    1593             :   false, 0,
    1594             :   false, 0,
    1595             :   false, 0,
    1596             :   false, 0,
    1597             :   -1,
    1598             :   1,
    1599             :   sNativeProperties_sortedPropertyIndices,
    1600             :   {
    1601             :     { sMethods, &sNativeProperties_propertyInfos[0] }
    1602             :   }
    1603             : };
    1604             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1605             :     "We have a property info count that is oversized");
    1606             : 
    1607             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1608             :   {
    1609             :     "URLSearchParamsIteratorPrototype",
    1610             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1611             :     JS_NULL_CLASS_OPS,
    1612             :     JS_NULL_CLASS_SPEC,
    1613             :     JS_NULL_CLASS_EXT,
    1614             :     JS_NULL_OBJECT_OPS
    1615             :   },
    1616             :   eInterfacePrototype,
    1617             :   false,
    1618             :   prototypes::id::URLSearchParamsIterator,
    1619             :   PrototypeTraits<prototypes::id::URLSearchParamsIterator>::Depth,
    1620             :   sNativePropertyHooks,
    1621             :   "[object URLSearchParamsIteratorPrototype]",
    1622             :   JS::GetRealmIteratorPrototype
    1623             : };
    1624             : 
    1625             : static const js::ClassOps sClassOps = {
    1626             :   nullptr, /* addProperty */
    1627             :   nullptr,               /* delProperty */
    1628             :   nullptr,               /* getProperty */
    1629             :   nullptr,               /* setProperty */
    1630             :   nullptr,               /* enumerate */
    1631             :   nullptr, /* newEnumerate */
    1632             :   nullptr, /* resolve */
    1633             :   nullptr, /* mayResolve */
    1634             :   _finalize, /* finalize */
    1635             :   nullptr, /* call */
    1636             :   nullptr,               /* hasInstance */
    1637             :   nullptr,               /* construct */
    1638             :   nullptr, /* trace */
    1639             : };
    1640             : 
    1641             : static const js::ClassExtension sClassExtension = {
    1642             :   nullptr, /* weakmapKeyDelegateOp */
    1643             :   nullptr /* objectMovedOp */
    1644             : };
    1645             : 
    1646             : static const DOMJSClass sClass = {
    1647             :   { "URLSearchParamsIterator",
    1648             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1649             :     &sClassOps,
    1650             :     JS_NULL_CLASS_SPEC,
    1651             :     &sClassExtension,
    1652             :     JS_NULL_OBJECT_OPS
    1653             :   },
    1654             :   { prototypes::id::URLSearchParamsIterator, 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 },
    1655             :   IsBaseOf<nsISupports, mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> >::value,
    1656             :   sNativePropertyHooks,
    1657             :   FindAssociatedGlobalForNative<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>>::Get,
    1658             :   GetProtoObjectHandle,
    1659             :   GetCCParticipant<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>>::Get()
    1660             : };
    1661             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1662             :               "Must have the right minimal number of reserved slots.");
    1663             : static_assert(1 >= 1,
    1664             :               "Must have enough reserved slots.");
    1665             : 
    1666             : const JSClass*
    1667           0 : GetJSClass()
    1668             : {
    1669           0 :   return sClass.ToJSClass();
    1670             : }
    1671             : 
    1672             : bool
    1673           0 : Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1674             : {
    1675             :   MOZ_ASSERT(static_cast<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>*>(aObject) ==
    1676             :              reinterpret_cast<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>*>(aObject),
    1677             :              "Multiple inheritance for mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> is broken.");
    1678           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1679           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1680             : 
    1681           0 :   JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
    1682           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1683           0 :   if (!canonicalProto) {
    1684           0 :     return false;
    1685             :   }
    1686           0 :   JS::Rooted<JSObject*> proto(aCx);
    1687           0 :   if (aGivenProto) {
    1688           0 :     proto = aGivenProto;
    1689             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1690             :     // coming in, we changed compartments to that of "parent" so may need
    1691             :     // to wrap the proto here.
    1692           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1693           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1694           0 :         return false;
    1695             :       }
    1696             :     }
    1697             :   } else {
    1698           0 :     proto = canonicalProto;
    1699             :   }
    1700             : 
    1701           0 :   BindingJSObjectCreator<mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>> creator(aCx);
    1702           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1703           0 :   if (!aReflector) {
    1704           0 :     return false;
    1705             :   }
    1706             : 
    1707             : 
    1708             : 
    1709           0 :   creator.InitializationSucceeded();
    1710           0 :   return true;
    1711             : }
    1712             : 
    1713             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1714             :   nullptr,
    1715             :   nullptr,
    1716             :   nullptr,
    1717             :   { sNativeProperties.Upcast(), nullptr },
    1718             :   prototypes::id::URLSearchParamsIterator,
    1719             :   constructors::id::_ID_Count,
    1720             :   nullptr,
    1721             :   &DefaultXrayExpandoObjectClass
    1722             : } };
    1723             : 
    1724             : void
    1725           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1726             : {
    1727           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmIteratorPrototype(aCx));
    1728           0 :   if (!parentProto) {
    1729           0 :     return;
    1730             :   }
    1731             : 
    1732             :   static bool sIdsInited = false;
    1733           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1734           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1735           0 :       return;
    1736             :     }
    1737           0 :     sIdsInited = true;
    1738             :   }
    1739             : 
    1740           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::URLSearchParamsIterator);
    1741           0 :   JS::Heap<JSObject*>* interfaceCache = nullptr;
    1742           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1743             :                               &sPrototypeClass.mBase, protoCache,
    1744             :                               nullptr, nullptr, 0, nullptr,
    1745             :                               interfaceCache,
    1746             :                               sNativeProperties.Upcast(),
    1747             :                               nullptr,
    1748             :                               nullptr, aDefineOnGlobal,
    1749             :                               nullptr,
    1750           0 :                               false);
    1751             : }
    1752             : 
    1753             : JS::Handle<JSObject*>
    1754           0 : GetProtoObjectHandle(JSContext* aCx)
    1755             : {
    1756             :   /* Get the interface prototype object for this class.  This will create the
    1757             :      object as needed. */
    1758           0 :   bool aDefineOnGlobal = true;
    1759             : 
    1760             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1761           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1762           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1763           0 :     return nullptr;
    1764             :   }
    1765             : 
    1766             :   /* Check to see whether the interface objects are already installed */
    1767           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1768           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::URLSearchParamsIterator)) {
    1769           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1770           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1771             :   }
    1772             : 
    1773             :   /*
    1774             :    * The object might _still_ be null, but that's OK.
    1775             :    *
    1776             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1777             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1778             :    * changed after they have been set.
    1779             :    *
    1780             :    * Calling address() avoids the read read barrier that does gray
    1781             :    * unmarking, but it's not possible for the object to be gray here.
    1782             :    */
    1783             : 
    1784           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::URLSearchParamsIterator);
    1785           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1786           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1787             : }
    1788             : 
    1789             : } // namespace URLSearchParamsIteratorBinding
    1790             : 
    1791             : 
    1792             : 
    1793             : } // namespace dom
    1794             : } // namespace mozilla

Generated by: LCOV version 1.13