1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

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

@ -53,6 +53,8 @@
RegExpPrototype, RegExpPrototype,
RegExpPrototypeTest, RegExpPrototypeTest,
RegExpPrototypeToString, RegExpPrototypeToString,
SafeArrayIterator,
SafeSet,
SetPrototype, SetPrototype,
SetPrototypeEntries, SetPrototypeEntries,
Symbol, Symbol,
@ -1938,11 +1940,14 @@
const [first, ...rest] = args; const [first, ...rest] = args;
if (typeof first === "string") { if (typeof first === "string") {
this.error(`Assertion failed: ${first}`, ...rest); this.error(
`Assertion failed: ${first}`,
...new SafeArrayIterator(rest),
);
return; return;
} }
this.error(`Assertion failed:`, ...args); this.error(`Assertion failed:`, ...new SafeArrayIterator(args));
}; };
count = (label = "default") => { count = (label = "default") => {
@ -1994,7 +1999,7 @@
const indexKey = isSet || isMap ? "(iter idx)" : "(idx)"; const indexKey = isSet || isMap ? "(iter idx)" : "(idx)";
if (isSet) { if (isSet) {
resultData = [...data]; resultData = [...new SafeSet(data)];
} else if (isMap) { } else if (isMap) {
let idx = 0; let idx = 0;
resultData = {}; resultData = {};
@ -2048,12 +2053,16 @@
const headerKeys = ObjectKeys(objectValues); const headerKeys = ObjectKeys(objectValues);
const bodyValues = ObjectValues(objectValues); const bodyValues = ObjectValues(objectValues);
const headerProps = properties ||
[
...new SafeArrayIterator(headerKeys),
!isMap && hasPrimitives && valuesKey,
];
const header = ArrayPrototypeFilter([ const header = ArrayPrototypeFilter([
indexKey, indexKey,
...(properties || ...new SafeArrayIterator(headerProps),
[...headerKeys, !isMap && hasPrimitives && valuesKey]),
], Boolean); ], Boolean);
const body = [indexKeys, ...bodyValues, values]; const body = [indexKeys, ...new SafeArrayIterator(bodyValues), values];
toTable(header, body); toTable(header, body);
}; };
@ -2080,7 +2089,7 @@
const startTime = MapPrototypeGet(timerMap, label); const startTime = MapPrototypeGet(timerMap, label);
const duration = DateNow() - startTime; const duration = DateNow() - startTime;
this.info(`${label}: ${duration}ms`, ...args); this.info(`${label}: ${duration}ms`, ...new SafeArrayIterator(args));
}; };
timeEnd = (label = "default") => { timeEnd = (label = "default") => {
@ -2100,7 +2109,7 @@
group = (...label) => { group = (...label) => {
if (label.length > 0) { if (label.length > 0) {
this.log(...label); this.log(...new SafeArrayIterator(label));
} }
this.indentLevel += 2; this.indentLevel += 2;
}; };

View file

@ -13,6 +13,7 @@
ArrayBufferIsView, ArrayBufferIsView,
ArrayBufferPrototype, ArrayBufferPrototype,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
SafeArrayIterator,
} = window.__bootstrap.primordials; } = window.__bootstrap.primordials;
webidl.converters.AlgorithmIdentifier = (V, opts) => { webidl.converters.AlgorithmIdentifier = (V, opts) => {
@ -79,7 +80,7 @@
/** @type {__bootstrap.webidl.Dictionary} */ /** @type {__bootstrap.webidl.Dictionary} */
const dictRsaKeyGenParams = [ const dictRsaKeyGenParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "modulusLength", key: "modulusLength",
converter: (V, opts) => converter: (V, opts) =>
@ -97,7 +98,7 @@
.createDictionaryConverter("RsaKeyGenParams", dictRsaKeyGenParams); .createDictionaryConverter("RsaKeyGenParams", dictRsaKeyGenParams);
const dictRsaHashedKeyGenParams = [ const dictRsaHashedKeyGenParams = [
...dictRsaKeyGenParams, ...new SafeArrayIterator(dictRsaKeyGenParams),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -111,7 +112,7 @@
); );
const dictRsaHashedImportParams = [ const dictRsaHashedImportParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -127,7 +128,7 @@
webidl.converters.NamedCurve = webidl.converters.DOMString; webidl.converters.NamedCurve = webidl.converters.DOMString;
const dictEcKeyImportParams = [ const dictEcKeyImportParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "namedCurve", key: "namedCurve",
converter: webidl.converters.NamedCurve, converter: webidl.converters.NamedCurve,
@ -141,7 +142,7 @@
); );
const dictEcKeyGenParams = [ const dictEcKeyGenParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "namedCurve", key: "namedCurve",
converter: webidl.converters.NamedCurve, converter: webidl.converters.NamedCurve,
@ -153,7 +154,7 @@
.createDictionaryConverter("EcKeyGenParams", dictEcKeyGenParams); .createDictionaryConverter("EcKeyGenParams", dictEcKeyGenParams);
const dictEcImportParams = [ const dictEcImportParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "namedCurve", key: "namedCurve",
converter: webidl.converters.NamedCurve, converter: webidl.converters.NamedCurve,
@ -165,7 +166,7 @@
.createDictionaryConverter("EcImportParams", dictEcImportParams); .createDictionaryConverter("EcImportParams", dictEcImportParams);
const dictAesKeyGenParams = [ const dictAesKeyGenParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "length", key: "length",
converter: (V, opts) => converter: (V, opts) =>
@ -178,7 +179,7 @@
.createDictionaryConverter("AesKeyGenParams", dictAesKeyGenParams); .createDictionaryConverter("AesKeyGenParams", dictAesKeyGenParams);
const dictHmacKeyGenParams = [ const dictHmacKeyGenParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -195,7 +196,7 @@
.createDictionaryConverter("HmacKeyGenParams", dictHmacKeyGenParams); .createDictionaryConverter("HmacKeyGenParams", dictHmacKeyGenParams);
const dictRsaPssParams = [ const dictRsaPssParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "saltLength", key: "saltLength",
converter: (V, opts) => converter: (V, opts) =>
@ -208,7 +209,7 @@
.createDictionaryConverter("RsaPssParams", dictRsaPssParams); .createDictionaryConverter("RsaPssParams", dictRsaPssParams);
const dictRsaOaepParams = [ const dictRsaOaepParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "label", key: "label",
converter: webidl.converters["BufferSource"], converter: webidl.converters["BufferSource"],
@ -219,7 +220,7 @@
.createDictionaryConverter("RsaOaepParams", dictRsaOaepParams); .createDictionaryConverter("RsaOaepParams", dictRsaOaepParams);
const dictEcdsaParams = [ const dictEcdsaParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -231,7 +232,7 @@
.createDictionaryConverter("EcdsaParams", dictEcdsaParams); .createDictionaryConverter("EcdsaParams", dictEcdsaParams);
const dictHmacImportParams = [ const dictHmacImportParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -357,7 +358,7 @@
); );
const dictHkdfParams = [ const dictHkdfParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -379,7 +380,7 @@
.createDictionaryConverter("HkdfParams", dictHkdfParams); .createDictionaryConverter("HkdfParams", dictHkdfParams);
const dictPbkdf2Params = [ const dictPbkdf2Params = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "hash", key: "hash",
converter: webidl.converters.HashAlgorithmIdentifier, converter: webidl.converters.HashAlgorithmIdentifier,
@ -402,7 +403,7 @@
.createDictionaryConverter("Pbkdf2Params", dictPbkdf2Params); .createDictionaryConverter("Pbkdf2Params", dictPbkdf2Params);
const dictAesDerivedKeyParams = [ const dictAesDerivedKeyParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "length", key: "length",
converter: (V, opts) => converter: (V, opts) =>
@ -412,7 +413,7 @@
]; ];
const dictAesCbcParams = [ const dictAesCbcParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "iv", key: "iv",
converter: webidl.converters["BufferSource"], converter: webidl.converters["BufferSource"],
@ -421,7 +422,7 @@
]; ];
const dictAesGcmParams = [ const dictAesGcmParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "iv", key: "iv",
converter: webidl.converters["BufferSource"], converter: webidl.converters["BufferSource"],
@ -439,7 +440,7 @@
]; ];
const dictAesCtrParams = [ const dictAesCtrParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "counter", key: "counter",
converter: webidl.converters["BufferSource"], converter: webidl.converters["BufferSource"],
@ -485,7 +486,7 @@
.createDictionaryConverter("CryptoKeyPair", dictCryptoKeyPair); .createDictionaryConverter("CryptoKeyPair", dictCryptoKeyPair);
const dictEcdhKeyDeriveParams = [ const dictEcdhKeyDeriveParams = [
...dictAlgorithm, ...new SafeArrayIterator(dictAlgorithm),
{ {
key: "public", key: "public",
converter: webidl.converters.CryptoKey, converter: webidl.converters.CryptoKey,

View file

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

View file

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

View file

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

View file

@ -38,6 +38,7 @@
Promise, Promise,
PromisePrototypeThen, PromisePrototypeThen,
PromisePrototypeCatch, PromisePrototypeCatch,
SafeArrayIterator,
String, String,
StringPrototypeStartsWith, StringPrototypeStartsWith,
StringPrototypeToLowerCase, StringPrototypeToLowerCase,
@ -168,7 +169,7 @@
if (this.urlList.length == 0) return null; if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1]; 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 (recursive) return response;
if (response.urlList.length === 0) { if (response.urlList.length === 0) {
response.urlList = [...req.urlList]; response.urlList = [...new SafeArrayIterator(req.urlList)];
} }
return response; return response;

View file

@ -17,6 +17,7 @@
NumberPOSITIVE_INFINITY, NumberPOSITIVE_INFINITY,
PromisePrototypeThen, PromisePrototypeThen,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
SafeArrayIterator,
SymbolFor, SymbolFor,
TypeError, TypeError,
} = window.__bootstrap.primordials; } = window.__bootstrap.primordials;
@ -159,7 +160,11 @@
// 3. // 3.
// TODO(@andreubotella): Error handling. // TODO(@andreubotella): Error handling.
if (typeof callback === "function") { if (typeof callback === "function") {
FunctionPrototypeCall(callback, globalThis, ...args); FunctionPrototypeCall(
callback,
globalThis,
...new SafeArrayIterator(args),
);
} else { } else {
// TODO(@andreubotella): eval doesn't seem to have a primordial, but // TODO(@andreubotella): eval doesn't seem to have a primordial, but
// it can be redefined in the global scope. // it can be redefined in the global scope.

View file

@ -18,6 +18,7 @@
ArrayPrototypeSort, ArrayPrototypeSort,
ArrayPrototypeSplice, ArrayPrototypeSplice,
ObjectKeys, ObjectKeys,
SafeArrayIterator,
StringPrototypeSlice, StringPrototypeSlice,
Symbol, Symbol,
SymbolFor, SymbolFor,
@ -345,7 +346,12 @@
"op_url_parse_search_params", "op_url_parse_search_params",
StringPrototypeSlice(this.search, 1), StringPrototypeSlice(this.search, 1),
); );
ArrayPrototypeSplice(params, 0, params.length, ...newParams); ArrayPrototypeSplice(
params,
0,
params.length,
...new SafeArrayIterator(newParams),
);
} }
} }

View file

@ -18,6 +18,7 @@
StringPrototypePadStart, StringPrototypePadStart,
TypeError, TypeError,
ArrayPrototypeJoin, ArrayPrototypeJoin,
SafeArrayIterator,
StringPrototypeCharAt, StringPrototypeCharAt,
StringPrototypeMatch, StringPrototypeMatch,
StringPrototypeSlice, StringPrototypeSlice,
@ -31,11 +32,21 @@
const ASCII_DIGIT = ["\u0030-\u0039"]; const ASCII_DIGIT = ["\u0030-\u0039"];
const ASCII_UPPER_ALPHA = ["\u0041-\u005A"]; const ASCII_UPPER_ALPHA = ["\u0041-\u005A"];
const ASCII_LOWER_ALPHA = ["\u0061-\u007A"]; const ASCII_LOWER_ALPHA = ["\u0061-\u007A"];
const ASCII_ALPHA = [...ASCII_UPPER_ALPHA, ...ASCII_LOWER_ALPHA]; const ASCII_ALPHA = [
const ASCII_ALPHANUMERIC = [...ASCII_DIGIT, ...ASCII_ALPHA]; ...new SafeArrayIterator(ASCII_UPPER_ALPHA),
...new SafeArrayIterator(ASCII_LOWER_ALPHA),
];
const ASCII_ALPHANUMERIC = [
...new SafeArrayIterator(ASCII_DIGIT),
...new SafeArrayIterator(ASCII_ALPHA),
];
const HTTP_TAB_OR_SPACE = ["\u0009", "\u0020"]; const HTTP_TAB_OR_SPACE = ["\u0009", "\u0020"];
const HTTP_WHITESPACE = ["\u000A", "\u000D", ...HTTP_TAB_OR_SPACE]; const HTTP_WHITESPACE = [
"\u000A",
"\u000D",
...new SafeArrayIterator(HTTP_TAB_OR_SPACE),
];
const HTTP_TOKEN_CODE_POINT = [ const HTTP_TOKEN_CODE_POINT = [
"\u0021", "\u0021",
@ -53,7 +64,7 @@
"\u0060", "\u0060",
"\u007C", "\u007C",
"\u007E", "\u007E",
...ASCII_ALPHANUMERIC, ...new SafeArrayIterator(ASCII_ALPHANUMERIC),
]; ];
const HTTP_TOKEN_CODE_POINT_RE = new RegExp( const HTTP_TOKEN_CODE_POINT_RE = new RegExp(
`^[${regexMatcher(HTTP_TOKEN_CODE_POINT)}]+$`, `^[${regexMatcher(HTTP_TOKEN_CODE_POINT)}]+$`,

View file

@ -31,6 +31,7 @@
ObjectGetOwnPropertyDescriptor, ObjectGetOwnPropertyDescriptor,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
ReflectDefineProperty, ReflectDefineProperty,
SafeArrayIterator,
Symbol, Symbol,
SymbolFor, SymbolFor,
SymbolToStringTag, SymbolToStringTag,
@ -1061,7 +1062,7 @@
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(ErrorEvent.prototype, this),
keys: [ keys: [
...EVENT_PROPS, ...new SafeArrayIterator(EVENT_PROPS),
"message", "message",
"filename", "filename",
"lineno", "lineno",
@ -1122,7 +1123,7 @@
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(CloseEvent.prototype, this),
keys: [ keys: [
...EVENT_PROPS, ...new SafeArrayIterator(EVENT_PROPS),
"wasClean", "wasClean",
"code", "code",
"reason", "reason",
@ -1154,7 +1155,7 @@
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(MessageEvent.prototype, this),
keys: [ keys: [
...EVENT_PROPS, ...new SafeArrayIterator(EVENT_PROPS),
"data", "data",
"origin", "origin",
"lastEventId", "lastEventId",
@ -1187,7 +1188,7 @@
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(CustomEvent.prototype, this),
keys: [ keys: [
...EVENT_PROPS, ...new SafeArrayIterator(EVENT_PROPS),
"detail", "detail",
], ],
})); }));
@ -1217,7 +1218,7 @@
object: this, object: this,
evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this), evaluate: ObjectPrototypeIsPrototypeOf(ProgressEvent.prototype, this),
keys: [ keys: [
...EVENT_PROPS, ...new SafeArrayIterator(EVENT_PROPS),
"lengthComputable", "lengthComputable",
"loaded", "loaded",
"total", "total",

View file

@ -19,6 +19,7 @@
ArrayPrototypeMap, ArrayPrototypeMap,
StringPrototypeCharCodeAt, StringPrototypeCharCodeAt,
ArrayPrototypeJoin, ArrayPrototypeJoin,
SafeArrayIterator,
StringFromCharCode, StringFromCharCode,
TypedArrayFrom, TypedArrayFrom,
Uint8Array, Uint8Array,
@ -38,7 +39,7 @@
const uint8Array = forgivingBase64Decode(data); const uint8Array = forgivingBase64Decode(data);
const result = ArrayPrototypeMap( const result = ArrayPrototypeMap(
[...uint8Array], [...new SafeArrayIterator(uint8Array)],
(byte) => StringFromCharCode(byte), (byte) => StringFromCharCode(byte),
); );
return ArrayPrototypeJoin(result, ""); return ArrayPrototypeJoin(result, "");
@ -55,16 +56,19 @@
prefix, prefix,
context: "Argument 1", context: "Argument 1",
}); });
const byteArray = ArrayPrototypeMap([...data], (char) => { const byteArray = ArrayPrototypeMap(
const charCode = StringPrototypeCharCodeAt(char, 0); [...new SafeArrayIterator(data)],
if (charCode > 0xff) { (char) => {
throw new DOMException( const charCode = StringPrototypeCharCodeAt(char, 0);
"The string to be encoded contains characters outside of the Latin1 range.", if (charCode > 0xff) {
"InvalidCharacterError", throw new DOMException(
); "The string to be encoded contains characters outside of the Latin1 range.",
} "InvalidCharacterError",
return charCode; );
}); }
return charCode;
},
);
return forgivingBase64Encode(TypedArrayFrom(Uint8Array, byteArray)); return forgivingBase64Encode(TypedArrayFrom(Uint8Array, byteArray));
} }

View file

@ -30,6 +30,7 @@
ObjectDefineProperty, ObjectDefineProperty,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
queueMicrotask, queueMicrotask,
SafeArrayIterator,
StringFromCodePoint, StringFromCodePoint,
Symbol, Symbol,
TypedArrayPrototypeSet, TypedArrayPrototypeSet,
@ -484,7 +485,11 @@
if (typeof wrappedHandler.handler !== "function") { if (typeof wrappedHandler.handler !== "function") {
return; return;
} }
return FunctionPrototypeCall(wrappedHandler.handler, this, ...args); return FunctionPrototypeCall(
wrappedHandler.handler,
this,
...new SafeArrayIterator(args),
);
} }
wrappedHandler.handler = handler; wrappedHandler.handler = handler;
return wrappedHandler; return wrappedHandler;

View file

@ -32,6 +32,7 @@
PromisePrototypeThen, PromisePrototypeThen,
PromiseReject, PromiseReject,
PromiseResolve, PromiseResolve,
SafeArrayIterator,
Set, Set,
SetPrototypeEntries, SetPrototypeEntries,
SetPrototypeForEach, SetPrototypeForEach,
@ -543,7 +544,9 @@
} }
[SymbolFor("Deno.privateCustomInspect")](inspect) { [SymbolFor("Deno.privateCustomInspect")](inspect) {
return `${this.constructor.name} ${inspect([...this.values()])}`; return `${this.constructor.name} ${
inspect([...new SafeArrayIterator(this.values())])
}`;
} }
} }
@ -1923,7 +1926,7 @@
const { err } = core.opSync("op_webgpu_buffer_unmap", { const { err } = core.opSync("op_webgpu_buffer_unmap", {
bufferRid, bufferRid,
mappedRid, mappedRid,
}, ...(write ? [new Uint8Array(buffer)] : [])); }, ...new SafeArrayIterator(write ? [new Uint8Array(buffer)] : []));
device.pushError(err); device.pushError(err);
if (err) return; if (err) return;
} }

View file

@ -9,6 +9,8 @@
const { writableStreamClose, Deferred } = window.__bootstrap.streams; const { writableStreamClose, Deferred } = window.__bootstrap.streams;
const { DOMException } = window.__bootstrap.domException; const { DOMException } = window.__bootstrap.domException;
const { add, remove } = window.__bootstrap.abortSignal; const { add, remove } = window.__bootstrap.abortSignal;
const { headersFromHeaderList, headerListFromHeaders, fillHeaders } =
window.__bootstrap.headers;
const { const {
ArrayPrototypeJoin, ArrayPrototypeJoin,
@ -121,6 +123,11 @@
); );
} }
const headers = headersFromHeaderList([], "request");
if (options.headers !== undefined) {
fillHeaders(headers, options.headers);
}
const cancelRid = core.opSync( const cancelRid = core.opSync(
"op_ws_check_permission_and_cancel_handle", "op_ws_check_permission_and_cancel_handle",
this[_url], this[_url],
@ -144,7 +151,7 @@
? ArrayPrototypeJoin(options.protocols, ", ") ? ArrayPrototypeJoin(options.protocols, ", ")
: "", : "",
cancelHandle: cancelRid, cancelHandle: cancelRid,
headers: [...new Headers(options.headers).entries()], headers: headerListFromHeaders(headers),
}), }),
(create) => { (create) => {
options.signal?.[remove](abort); options.signal?.[remove](abort);

View file

@ -6,6 +6,7 @@
const core = window.Deno.core; const core = window.Deno.core;
const webidl = window.__bootstrap.webidl; const webidl = window.__bootstrap.webidl;
const { const {
SafeArrayIterator,
Symbol, Symbol,
SymbolFor, SymbolFor,
ObjectDefineProperty, ObjectDefineProperty,
@ -116,7 +117,7 @@
get(target, key) { get(target, key) {
if (typeof key == "symbol") return target[key]; if (typeof key == "symbol") return target[key];
if (key in target) { if (key in target) {
return ReflectGet(...arguments); return ReflectGet(...new SafeArrayIterator(arguments));
} else { } else {
return target.getItem(key) ?? undefined; return target.getItem(key) ?? undefined;
} }

View file

@ -7,6 +7,7 @@
Error, Error,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
Promise, Promise,
SafeArrayIterator,
StringPrototypeReplace, StringPrototypeReplace,
TypeError, TypeError,
} = window.__bootstrap.primordials; } = window.__bootstrap.primordials;
@ -26,7 +27,10 @@
if (logDebug) { if (logDebug) {
// if we destructure `console` off `globalThis` too early, we don't bind to // if we destructure `console` off `globalThis` too early, we don't bind to
// the right console, therefore we don't log anything out. // the right console, therefore we don't log anything out.
globalThis.console.log(`DEBUG ${logSource} -`, ...args); globalThis.console.log(
`DEBUG ${logSource} -`,
...new SafeArrayIterator(args),
);
} }
} }

View file

@ -24,6 +24,7 @@
RegExp, RegExp,
RegExpPrototypeTest, RegExpPrototypeTest,
Set, Set,
SafeArrayIterator,
StringPrototypeEndsWith, StringPrototypeEndsWith,
StringPrototypeIncludes, StringPrototypeIncludes,
StringPrototypeSlice, StringPrototypeSlice,
@ -278,7 +279,10 @@ finishing test case.`;
const post = core.resources(); const post = core.resources();
const allResources = new Set([...ObjectKeys(pre), ...ObjectKeys(post)]); const allResources = new Set([
...new SafeArrayIterator(ObjectKeys(pre)),
...new SafeArrayIterator(ObjectKeys(post)),
]);
const details = []; const details = [];
for (const resource of allResources) { for (const resource of allResources) {
@ -322,7 +326,7 @@ finishing test case.`;
}); });
try { try {
await fn(...params); await fn(...new SafeArrayIterator(params));
} catch (err) { } catch (err) {
throw err; throw err;
} finally { } finally {
@ -423,7 +427,7 @@ finishing test case.`;
const token = pledgePermissions(permissions); const token = pledgePermissions(permissions);
try { try {
await fn(...params); await fn(...new SafeArrayIterator(params));
} finally { } finally {
restorePermissions(token); restorePermissions(token);
} }