0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(ext/web): writability of ReadableStream.from (#20836)

Fixes a WPT in `URL` and `ReadableStream`.

Some unrelated WPT expectation changes due to WPT update.
This commit is contained in:
Luca Casonato 2023-10-10 12:01:01 +09:00 committed by GitHub
parent 84c9300aff
commit 2665ca103e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1064 additions and 307 deletions

View file

@ -277,8 +277,8 @@ class Cache {
} }
} }
webidl.configurePrototype(CacheStorage); webidl.configureInterface(CacheStorage);
webidl.configurePrototype(Cache); webidl.configureInterface(Cache);
const CacheStoragePrototype = CacheStorage.prototype; const CacheStoragePrototype = CacheStorage.prototype;
const CachePrototype = Cache.prototype; const CachePrototype = Cache.prototype;

View file

@ -361,7 +361,7 @@ class CryptoKey {
} }
} }
webidl.configurePrototype(CryptoKey); webidl.configureInterface(CryptoKey);
const CryptoKeyPrototype = CryptoKey.prototype; const CryptoKeyPrototype = CryptoKey.prototype;
/** /**
@ -4671,7 +4671,7 @@ async function encrypt(normalizedAlgorithm, key, data) {
} }
} }
webidl.configurePrototype(SubtleCrypto); webidl.configureInterface(SubtleCrypto);
const subtle = webidl.createBranded(SubtleCrypto); const subtle = webidl.createBranded(SubtleCrypto);
class Crypto { class Crypto {
@ -4734,7 +4734,7 @@ class Crypto {
} }
} }
webidl.configurePrototype(Crypto); webidl.configureInterface(Crypto);
const CryptoPrototype = Crypto.prototype; const CryptoPrototype = Crypto.prototype;
const crypto = webidl.createBranded(Crypto); const crypto = webidl.createBranded(Crypto);

View file

@ -453,7 +453,7 @@ class Headers {
webidl.mixinPairIterable("Headers", Headers, _iterableHeaders, 0, 1); webidl.mixinPairIterable("Headers", Headers, _iterableHeaders, 0, 1);
webidl.configurePrototype(Headers); webidl.configureInterface(Headers);
const HeadersPrototype = Headers.prototype; const HeadersPrototype = Headers.prototype;
webidl.converters["HeadersInit"] = (V, prefix, context, opts) => { webidl.converters["HeadersInit"] = (V, prefix, context, opts) => {

View file

@ -266,7 +266,7 @@ class FormData {
webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value"); webidl.mixinPairIterable("FormData", FormData, entryList, "name", "value");
webidl.configurePrototype(FormData); webidl.configureInterface(FormData);
const FormDataPrototype = FormData.prototype; const FormDataPrototype = FormData.prototype;
const ESCAPE_FILENAME_PATTERN = new SafeRegExp(/\r?\n|\r/g); const ESCAPE_FILENAME_PATTERN = new SafeRegExp(/\r?\n|\r/g);

View file

@ -497,7 +497,7 @@ class Request {
} }
} }
webidl.configurePrototype(Request); webidl.configureInterface(Request);
const RequestPrototype = Request.prototype; const RequestPrototype = Request.prototype;
mixinBody(RequestPrototype, _body, _mimeType); mixinBody(RequestPrototype, _body, _mimeType);

View file

@ -426,7 +426,7 @@ class Response {
} }
} }
webidl.configurePrototype(Response); webidl.configureInterface(Response);
ObjectDefineProperties(Response, { ObjectDefineProperties(Response, {
json: { enumerable: true }, json: { enumerable: true },
redirect: { enumerable: true }, redirect: { enumerable: true },

View file

@ -324,7 +324,7 @@ class URLSearchParams {
webidl.mixinPairIterable("URLSearchParams", URLSearchParams, _list, 0, 1); webidl.mixinPairIterable("URLSearchParams", URLSearchParams, _list, 0, 1);
webidl.configurePrototype(URLSearchParams); webidl.configureInterface(URLSearchParams);
const URLSearchParamsPrototype = URLSearchParams.prototype; const URLSearchParamsPrototype = URLSearchParams.prototype;
webidl.converters["URLSearchParams"] = webidl.createInterfaceConverter( webidl.converters["URLSearchParams"] = webidl.createInterfaceConverter(
@ -806,7 +806,7 @@ class URL {
} }
} }
webidl.configurePrototype(URL); webidl.configureInterface(URL);
const URLPrototype = URL.prototype; const URLPrototype = URL.prototype;
/** /**

View file

@ -238,7 +238,7 @@ class URLPattern {
} }
} }
webidl.configurePrototype(URLPattern); webidl.configureInterface(URLPattern);
const URLPatternPrototype = URLPattern.prototype; const URLPatternPrototype = URLPattern.prototype;
webidl.converters.URLPatternInit = webidl webidl.converters.URLPatternInit = webidl

View file

@ -170,7 +170,7 @@ ObjectDefineProperty(DOMException.prototype, "__callSiteEvals", {
ObjectSetPrototypeOf(DOMException.prototype, ErrorPrototype); ObjectSetPrototypeOf(DOMException.prototype, ErrorPrototype);
webidl.configurePrototype(DOMException); webidl.configureInterface(DOMException);
const DOMExceptionPrototype = DOMException.prototype; const DOMExceptionPrototype = DOMException.prototype;
const entries = ObjectEntries({ const entries = ObjectEntries({

View file

@ -1044,7 +1044,7 @@ class EventTarget {
} }
} }
webidl.configurePrototype(EventTarget); webidl.configureInterface(EventTarget);
const EventTargetPrototype = EventTarget.prototype; const EventTargetPrototype = EventTarget.prototype;
defineEnumerableProps(EventTarget, [ defineEnumerableProps(EventTarget, [

View file

@ -152,7 +152,7 @@ class AbortSignal extends EventTarget {
} }
defineEventHandler(AbortSignal.prototype, "abort"); defineEventHandler(AbortSignal.prototype, "abort");
webidl.configurePrototype(AbortSignal); webidl.configureInterface(AbortSignal);
const AbortSignalPrototype = AbortSignal.prototype; const AbortSignalPrototype = AbortSignal.prototype;
class AbortController { class AbortController {
@ -173,7 +173,7 @@ class AbortController {
} }
} }
webidl.configurePrototype(AbortController); webidl.configureInterface(AbortController);
const AbortControllerPrototype = AbortController.prototype; const AbortControllerPrototype = AbortController.prototype;
webidl.converters["AbortSignal"] = webidl.createInterfaceConverter( webidl.converters["AbortSignal"] = webidl.createInterfaceConverter(

View file

@ -4866,7 +4866,7 @@ class ByteLengthQueuingStrategy {
} }
} }
webidl.configurePrototype(ByteLengthQueuingStrategy); webidl.configureInterface(ByteLengthQueuingStrategy);
const ByteLengthQueuingStrategyPrototype = ByteLengthQueuingStrategy.prototype; const ByteLengthQueuingStrategyPrototype = ByteLengthQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, (chunk: ArrayBufferView) => number>} */ /** @type {WeakMap<typeof globalThis, (chunk: ArrayBufferView) => number>} */
@ -4920,7 +4920,7 @@ class CountQueuingStrategy {
} }
} }
webidl.configurePrototype(CountQueuingStrategy); webidl.configureInterface(CountQueuingStrategy);
const CountQueuingStrategyPrototype = CountQueuingStrategy.prototype; const CountQueuingStrategyPrototype = CountQueuingStrategy.prototype;
/** @type {WeakMap<typeof globalThis, () => 1>} */ /** @type {WeakMap<typeof globalThis, () => 1>} */
@ -5254,7 +5254,7 @@ ObjectDefineProperty(ReadableStream.prototype, SymbolAsyncIterator, {
configurable: true, configurable: true,
}); });
webidl.configurePrototype(ReadableStream); webidl.configureInterface(ReadableStream);
const ReadableStreamPrototype = ReadableStream.prototype; const ReadableStreamPrototype = ReadableStream.prototype;
function errorReadableStream(stream, e) { function errorReadableStream(stream, e) {
@ -5354,7 +5354,7 @@ class ReadableStreamDefaultReader {
} }
} }
webidl.configurePrototype(ReadableStreamDefaultReader); webidl.configureInterface(ReadableStreamDefaultReader);
const ReadableStreamDefaultReaderPrototype = const ReadableStreamDefaultReaderPrototype =
ReadableStreamDefaultReader.prototype; ReadableStreamDefaultReader.prototype;
@ -5484,7 +5484,7 @@ class ReadableStreamBYOBReader {
} }
} }
webidl.configurePrototype(ReadableStreamBYOBReader); webidl.configureInterface(ReadableStreamBYOBReader);
const ReadableStreamBYOBReaderPrototype = ReadableStreamBYOBReader.prototype; const ReadableStreamBYOBReaderPrototype = ReadableStreamBYOBReader.prototype;
class ReadableStreamBYOBRequest { class ReadableStreamBYOBRequest {
@ -5564,7 +5564,7 @@ class ReadableStreamBYOBRequest {
} }
} }
webidl.configurePrototype(ReadableStreamBYOBRequest); webidl.configureInterface(ReadableStreamBYOBRequest);
const ReadableStreamBYOBRequestPrototype = ReadableStreamBYOBRequest.prototype; const ReadableStreamBYOBRequestPrototype = ReadableStreamBYOBRequest.prototype;
class ReadableByteStreamController { class ReadableByteStreamController {
@ -5761,7 +5761,7 @@ class ReadableByteStreamController {
} }
} }
webidl.configurePrototype(ReadableByteStreamController); webidl.configureInterface(ReadableByteStreamController);
const ReadableByteStreamControllerPrototype = const ReadableByteStreamControllerPrototype =
ReadableByteStreamController.prototype; ReadableByteStreamController.prototype;
@ -5884,7 +5884,7 @@ class ReadableStreamDefaultController {
} }
} }
webidl.configurePrototype(ReadableStreamDefaultController); webidl.configureInterface(ReadableStreamDefaultController);
const ReadableStreamDefaultControllerPrototype = const ReadableStreamDefaultControllerPrototype =
ReadableStreamDefaultController.prototype; ReadableStreamDefaultController.prototype;
@ -6002,7 +6002,7 @@ class TransformStream {
} }
} }
webidl.configurePrototype(TransformStream); webidl.configureInterface(TransformStream);
const TransformStreamPrototype = TransformStream.prototype; const TransformStreamPrototype = TransformStream.prototype;
/** @template O */ /** @template O */
@ -6069,7 +6069,7 @@ class TransformStreamDefaultController {
} }
} }
webidl.configurePrototype(TransformStreamDefaultController); webidl.configureInterface(TransformStreamDefaultController);
const TransformStreamDefaultControllerPrototype = const TransformStreamDefaultControllerPrototype =
TransformStreamDefaultController.prototype; TransformStreamDefaultController.prototype;
@ -6204,7 +6204,7 @@ class WritableStream {
} }
} }
webidl.configurePrototype(WritableStream); webidl.configureInterface(WritableStream);
const WritableStreamPrototype = WritableStream.prototype; const WritableStreamPrototype = WritableStream.prototype;
/** @template W */ /** @template W */
@ -6350,7 +6350,7 @@ class WritableStreamDefaultWriter {
} }
} }
webidl.configurePrototype(WritableStreamDefaultWriter); webidl.configureInterface(WritableStreamDefaultWriter);
const WritableStreamDefaultWriterPrototype = const WritableStreamDefaultWriterPrototype =
WritableStreamDefaultWriter.prototype; WritableStreamDefaultWriter.prototype;
@ -6428,7 +6428,7 @@ class WritableStreamDefaultController {
} }
} }
webidl.configurePrototype(WritableStreamDefaultController); webidl.configureInterface(WritableStreamDefaultController);
const WritableStreamDefaultControllerPrototype = const WritableStreamDefaultControllerPrototype =
WritableStreamDefaultController.prototype; WritableStreamDefaultController.prototype;

View file

@ -192,7 +192,7 @@ class TextDecoder {
} }
} }
webidl.configurePrototype(TextDecoder); webidl.configureInterface(TextDecoder);
const TextDecoderPrototype = TextDecoder.prototype; const TextDecoderPrototype = TextDecoder.prototype;
class TextEncoder { class TextEncoder {
@ -251,7 +251,7 @@ class TextEncoder {
const encodeIntoBuf = new Uint32Array(2); const encodeIntoBuf = new Uint32Array(2);
webidl.configurePrototype(TextEncoder); webidl.configureInterface(TextEncoder);
const TextEncoderPrototype = TextEncoder.prototype; const TextEncoderPrototype = TextEncoder.prototype;
class TextDecoderStream { class TextDecoderStream {
@ -336,7 +336,7 @@ class TextDecoderStream {
} }
} }
webidl.configurePrototype(TextDecoderStream); webidl.configureInterface(TextDecoderStream);
const TextDecoderStreamPrototype = TextDecoderStream.prototype; const TextDecoderStreamPrototype = TextDecoderStream.prototype;
class TextEncoderStream { class TextEncoderStream {
@ -409,7 +409,7 @@ class TextEncoderStream {
} }
} }
webidl.configurePrototype(TextEncoderStream); webidl.configureInterface(TextEncoderStream);
const TextEncoderStreamPrototype = TextEncoderStream.prototype; const TextEncoderStreamPrototype = TextEncoderStream.prototype;
webidl.converters.TextDecoderOptions = webidl.createDictionaryConverter( webidl.converters.TextDecoderOptions = webidl.createDictionaryConverter(

View file

@ -428,7 +428,7 @@ class Blob {
} }
} }
webidl.configurePrototype(Blob); webidl.configureInterface(Blob);
const BlobPrototype = Blob.prototype; const BlobPrototype = Blob.prototype;
webidl.converters["Blob"] = webidl.createInterfaceConverter( webidl.converters["Blob"] = webidl.createInterfaceConverter(
@ -549,7 +549,7 @@ class File extends Blob {
} }
} }
webidl.configurePrototype(File); webidl.configureInterface(File);
const FilePrototype = File.prototype; const FilePrototype = File.prototype;
webidl.converters["FilePropertyBag"] = webidl.createDictionaryConverter( webidl.converters["FilePropertyBag"] = webidl.createDictionaryConverter(

View file

@ -432,7 +432,7 @@ class FileReader extends EventTarget {
} }
} }
webidl.configurePrototype(FileReader); webidl.configureInterface(FileReader);
const FileReaderPrototype = FileReader.prototype; const FileReaderPrototype = FileReader.prototype;
ObjectDefineProperty(FileReader, "EMPTY", { ObjectDefineProperty(FileReader, "EMPTY", {

View file

@ -64,7 +64,7 @@ class MessageChannel {
} }
} }
webidl.configurePrototype(MessageChannel); webidl.configureInterface(MessageChannel);
const MessageChannelPrototype = MessageChannel.prototype; const MessageChannelPrototype = MessageChannel.prototype;
const _id = Symbol("id"); const _id = Symbol("id");
@ -188,7 +188,7 @@ defineEventHandler(MessagePort.prototype, "message", function (self) {
}); });
defineEventHandler(MessagePort.prototype, "messageerror"); defineEventHandler(MessagePort.prototype, "messageerror");
webidl.configurePrototype(MessagePort); webidl.configureInterface(MessagePort);
const MessagePortPrototype = MessagePort.prototype; const MessagePortPrototype = MessagePort.prototype;
/** /**

View file

@ -62,7 +62,7 @@ class CompressionStream {
} }
} }
webidl.configurePrototype(CompressionStream); webidl.configureInterface(CompressionStream);
const CompressionStreamPrototype = CompressionStream.prototype; const CompressionStreamPrototype = CompressionStream.prototype;
class DecompressionStream { class DecompressionStream {
@ -110,7 +110,7 @@ function maybeEnqueue(controller, output) {
} }
} }
webidl.configurePrototype(DecompressionStream); webidl.configureInterface(DecompressionStream);
const DecompressionStreamPrototype = DecompressionStream.prototype; const DecompressionStreamPrototype = DecompressionStream.prototype;
export { CompressionStream, DecompressionStream }; export { CompressionStream, DecompressionStream };

View file

@ -212,7 +212,7 @@ class PerformanceEntry {
})); }));
} }
} }
webidl.configurePrototype(PerformanceEntry); webidl.configureInterface(PerformanceEntry);
const PerformanceEntryPrototype = PerformanceEntry.prototype; const PerformanceEntryPrototype = PerformanceEntry.prototype;
const _detail = Symbol("[[detail]]"); const _detail = Symbol("[[detail]]");
@ -279,7 +279,7 @@ class PerformanceMark extends PerformanceEntry {
})); }));
} }
} }
webidl.configurePrototype(PerformanceMark); webidl.configureInterface(PerformanceMark);
const PerformanceMarkPrototype = PerformanceMark.prototype; const PerformanceMarkPrototype = PerformanceMark.prototype;
class PerformanceMeasure extends PerformanceEntry { class PerformanceMeasure extends PerformanceEntry {
[_detail] = null; [_detail] = null;
@ -338,7 +338,7 @@ class PerformanceMeasure extends PerformanceEntry {
})); }));
} }
} }
webidl.configurePrototype(PerformanceMeasure); webidl.configureInterface(PerformanceMeasure);
const PerformanceMeasurePrototype = PerformanceMeasure.prototype; const PerformanceMeasurePrototype = PerformanceMeasure.prototype;
class Performance extends EventTarget { class Performance extends EventTarget {
constructor(key = null) { constructor(key = null) {
@ -577,7 +577,7 @@ class Performance extends EventTarget {
})); }));
} }
} }
webidl.configurePrototype(Performance); webidl.configureInterface(Performance);
const PerformancePrototype = Performance.prototype; const PerformancePrototype = Performance.prototype;
webidl.converters["Performance"] = webidl.createInterfaceConverter( webidl.converters["Performance"] = webidl.createInterfaceConverter(

View file

@ -1138,36 +1138,42 @@ function mixinPairIterable(name, prototype, dataSymbol, keyKey, valueKey) {
return ObjectDefineProperties(prototype.prototype, properties); return ObjectDefineProperties(prototype.prototype, properties);
} }
function configurePrototype(prototype) { function configureInterface(interface_) {
const descriptors = ObjectGetOwnPropertyDescriptors(prototype.prototype); configureProperties(interface_);
configureProperties(interface_.prototype);
ObjectDefineProperty(interface_.prototype, SymbolToStringTag, {
value: interface_.name,
enumerable: false,
configurable: true,
writable: false,
});
}
function configureProperties(obj) {
const descriptors = ObjectGetOwnPropertyDescriptors(obj);
for (const key in descriptors) { for (const key in descriptors) {
if (!ObjectHasOwn(descriptors, key)) { if (!ObjectHasOwn(descriptors, key)) {
continue; continue;
} }
if (key === "constructor") continue; if (key === "constructor") continue;
if (key === "prototype") continue;
const descriptor = descriptors[key]; const descriptor = descriptors[key];
if ( if (
ReflectHas(descriptor, "value") && ReflectHas(descriptor, "value") &&
typeof descriptor.value === "function" typeof descriptor.value === "function"
) { ) {
ObjectDefineProperty(prototype.prototype, key, { ObjectDefineProperty(obj, key, {
enumerable: true, enumerable: true,
writable: true, writable: true,
configurable: true, configurable: true,
}); });
} else if (ReflectHas(descriptor, "get")) { } else if (ReflectHas(descriptor, "get")) {
ObjectDefineProperty(prototype.prototype, key, { ObjectDefineProperty(obj, key, {
enumerable: true, enumerable: true,
configurable: true, configurable: true,
}); });
} }
} }
ObjectDefineProperty(prototype.prototype, SymbolToStringTag, {
value: prototype.name,
enumerable: false,
configurable: true,
writable: false,
});
} }
const setlikeInner = Symbol("[[set]]"); const setlikeInner = Symbol("[[set]]");
@ -1275,7 +1281,7 @@ function setlike(obj, objPrototype, readonly) {
export { export {
assertBranded, assertBranded,
brand, brand,
configurePrototype, configureInterface,
converters, converters,
createBranded, createBranded,
createDictionaryConverter, createDictionaryConverter,

View file

@ -543,7 +543,7 @@ declare module "ext:deno_webidl/00_webidl.js" {
/** /**
* Configure prototype properties enumerability / writability / configurability. * Configure prototype properties enumerability / writability / configurability.
*/ */
function configurePrototype(prototype: any); function configureInterface(prototype: any);
/** /**
* Get the WebIDL / ES type of a value. * Get the WebIDL / ES type of a value.

View file

@ -570,7 +570,7 @@ defineEventHandler(WebSocket.prototype, "error");
defineEventHandler(WebSocket.prototype, "close"); defineEventHandler(WebSocket.prototype, "close");
defineEventHandler(WebSocket.prototype, "open"); defineEventHandler(WebSocket.prototype, "open");
webidl.configurePrototype(WebSocket); webidl.configureInterface(WebSocket);
const WebSocketPrototype = WebSocket.prototype; const WebSocketPrototype = WebSocket.prototype;
export { export {

@ -1 +1 @@
Subproject commit c84a2ef4f244210040b5864fa28d157cfba2e537 Subproject commit a8872d92b147fc87200eb0c14fe7a4a9e7cd4f73

View file

@ -329,7 +329,10 @@ function assertAllExpectationsHaveTests(
for (const [key, expectation] of Object.entries(parentExpectation)) { for (const [key, expectation] of Object.entries(parentExpectation)) {
const path = `${parent}/${key}`; const path = `${parent}/${key}`;
if (!filter.matches(path)) continue; if (!filter.matches(path)) continue;
if (typeof expectation == "boolean" || Array.isArray(expectation)) { if (
(typeof expectation == "boolean" || Array.isArray(expectation)) &&
key !== "ignore"
) {
if (!tests.has(path)) { if (!tests.has(path)) {
missingTests.push(path); missingTests.push(path);
} }

File diff suppressed because it is too large Load diff