refactor: update runtime code for primordial check for iterators (#13510)

This commit is contained in:
Bartek Iwańczuk 2022-02-07 13:54:32 +01:00 committed by GitHub
parent 9c7ed1c98b
commit bf22f114a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 141 additions and 65 deletions

View file

@ -32,6 +32,7 @@
ObjectPrototypeHasOwnProperty,
ObjectEntries,
RegExpPrototypeTest,
SafeArrayIterator,
Symbol,
SymbolFor,
SymbolIterator,
@ -230,7 +231,10 @@
}
return ArrayPrototypeSort(
[...ObjectEntries(headers), ...cookies],
[
...new SafeArrayIterator(ObjectEntries(headers)),
...new SafeArrayIterator(cookies),
],
(a, b) => {
const akey = a[0];
const bkey = b[0];

View file

@ -38,6 +38,7 @@
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
RegExpPrototypeTest,
SafeArrayIterator,
Symbol,
SymbolFor,
TypeError,
@ -101,7 +102,9 @@
*/
function cloneInnerRequest(request) {
const headerList = [
...ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]),
...new SafeArrayIterator(
ArrayPrototypeMap(request.headerList, (x) => [x[0], x[1]]),
),
];
let body = null;
if (request.body !== null) {

View file

@ -37,6 +37,7 @@
RangeError,
RegExp,
RegExpPrototypeTest,
SafeArrayIterator,
Symbol,
SymbolFor,
TypeError,
@ -45,7 +46,11 @@
const VCHAR = ["\x21-\x7E"];
const OBS_TEXT = ["\x80-\xFF"];
const REASON_PHRASE = [...HTTP_TAB_OR_SPACE, ...VCHAR, ...OBS_TEXT];
const REASON_PHRASE = [
...new SafeArrayIterator(HTTP_TAB_OR_SPACE),
...new SafeArrayIterator(VCHAR),
...new SafeArrayIterator(OBS_TEXT),
];
const REASON_PHRASE_MATCHER = regexMatcher(REASON_PHRASE);
const REASON_PHRASE_RE = new RegExp(`^[${REASON_PHRASE_MATCHER}]*$`);
@ -90,9 +95,11 @@
* @returns {InnerResponse}
*/
function cloneInnerResponse(response) {
const urlList = [...response.urlList];
const urlList = [...new SafeArrayIterator(response.urlList)];
const headerList = [
...ArrayPrototypeMap(response.headerList, (x) => [x[0], x[1]]),
...new SafeArrayIterator(
ArrayPrototypeMap(response.headerList, (x) => [x[0], x[1]]),
),
];
let body = null;
if (response.body !== null) {

View file

@ -38,6 +38,7 @@
Promise,
PromisePrototypeThen,
PromisePrototypeCatch,
SafeArrayIterator,
String,
StringPrototypeStartsWith,
StringPrototypeToLowerCase,
@ -168,7 +169,7 @@
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
urlList: recursive ? [] : [...req.urlList],
urlList: recursive ? [] : [...new SafeArrayIterator(req.urlList)],
};
}
@ -331,7 +332,7 @@
if (recursive) return response;
if (response.urlList.length === 0) {
response.urlList = [...req.urlList];
response.urlList = [...new SafeArrayIterator(req.urlList)];
}
return response;