diff --git a/lib/web/eventsource/eventsource.js b/lib/web/eventsource/eventsource.js index b736eb3c5f5..4c402f0e066 100644 --- a/lib/web/eventsource/eventsource.js +++ b/lib/web/eventsource/eventsource.js @@ -3,7 +3,7 @@ const { pipeline } = require('node:stream') const { fetching } = require('../fetch') const { makeRequest } = require('../fetch/request') -const { webidl, maybeMarkAsUncloneable } = require('../fetch/webidl') +const { webidl } = require('../fetch/webidl') const { EventSourceStream } = require('./eventsource-stream') const { parseMIMEType } = require('../fetch/data-url') const { createFastMessageEvent } = require('../websocket/events') @@ -109,7 +109,7 @@ class EventSource extends EventTarget { // 1. Let ev be a new EventSource object. super() - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) const prefix = 'EventSource constructor' webidl.argumentLengthCheck(arguments, 1, prefix) diff --git a/lib/web/fetch/formdata.js b/lib/web/fetch/formdata.js index 918a14ed7f0..6bd57bf6572 100644 --- a/lib/web/fetch/formdata.js +++ b/lib/web/fetch/formdata.js @@ -2,7 +2,7 @@ const { iteratorMixin } = require('./util') const { kEnumerableProperty } = require('../../core/util') -const { webidl, maybeMarkAsUncloneable } = require('./webidl') +const { webidl } = require('./webidl') const { File: NativeFile } = require('node:buffer') const nodeUtil = require('node:util') @@ -14,7 +14,7 @@ class FormData { #state = [] constructor (form) { - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) if (form !== undefined) { throw webidl.errors.conversionFailed({ diff --git a/lib/web/fetch/headers.js b/lib/web/fetch/headers.js index 7f6c2cb6d73..7e6182556ff 100644 --- a/lib/web/fetch/headers.js +++ b/lib/web/fetch/headers.js @@ -9,7 +9,7 @@ const { isValidHeaderName, isValidHeaderValue } = require('./util') -const { webidl, maybeMarkAsUncloneable } = require('./webidl') +const { webidl } = require('./webidl') const assert = require('node:assert') const util = require('node:util') @@ -420,7 +420,7 @@ class Headers { #headersList constructor (init = undefined) { - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) if (init === kConstruct) { return diff --git a/lib/web/fetch/request.js b/lib/web/fetch/request.js index 352e3a4aa43..de6f3f9a466 100644 --- a/lib/web/fetch/request.js +++ b/lib/web/fetch/request.js @@ -23,7 +23,7 @@ const { requestDuplex } = require('./constants') const { kEnumerableProperty, normalizedMethodRecordsBase, normalizedMethodRecords } = util -const { webidl, maybeMarkAsUncloneable } = require('./webidl') +const { webidl } = require('./webidl') const { URLSerializer } = require('./data-url') const { kConstruct } = require('../../core/symbols') const assert = require('node:assert') @@ -92,7 +92,7 @@ class Request { // https://fetch.spec.whatwg.org/#dom-request constructor (input, init = undefined) { - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) if (input === kConstruct) { return diff --git a/lib/web/fetch/response.js b/lib/web/fetch/response.js index 120b4f7b16a..e6b8c6a8833 100644 --- a/lib/web/fetch/response.js +++ b/lib/web/fetch/response.js @@ -18,7 +18,7 @@ const { redirectStatusSet, nullBodyStatus } = require('./constants') -const { webidl, maybeMarkAsUncloneable } = require('./webidl') +const { webidl } = require('./webidl') const { FormData } = require('./formdata') const { URLSerializer } = require('./data-url') const { kConstruct } = require('../../core/symbols') @@ -113,7 +113,7 @@ class Response { // https://fetch.spec.whatwg.org/#dom-response constructor (body = null, init = undefined) { - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) if (body === kConstruct) { return diff --git a/lib/web/fetch/webidl.js b/lib/web/fetch/webidl.js index 5cc794c5930..97922be8fa7 100644 --- a/lib/web/fetch/webidl.js +++ b/lib/web/fetch/webidl.js @@ -120,6 +120,12 @@ webidl.util.TypeValueToString = function (o) { } } +webidl.util.maybeMarkAsUncloneable = function (target) { + if (markAsUncloneable !== undefined) { + markAsUncloneable(target) + } +} + // https://webidl.spec.whatwg.org/#abstract-opdef-converttoint webidl.util.ConvertToInt = function (V, bitLength, signedness, opts) { let upperBound @@ -700,13 +706,6 @@ webidl.converters['record'] = webidl.recordConverter( webidl.converters.Blob = webidl.interfaceConverter(Blob) -function maybeMarkAsUncloneable (target) { - if (markAsUncloneable !== undefined) { - markAsUncloneable(target) - } -} - module.exports = { - webidl, - maybeMarkAsUncloneable + webidl } diff --git a/lib/web/websocket/events.js b/lib/web/websocket/events.js index 0c22986c87c..d12cb0388b2 100644 --- a/lib/web/websocket/events.js +++ b/lib/web/websocket/events.js @@ -1,6 +1,6 @@ 'use strict' -const { webidl, maybeMarkAsUncloneable } = require('../fetch/webidl') +const { webidl } = require('../fetch/webidl') const { kEnumerableProperty } = require('../../core/util') const { kConstruct } = require('../../core/symbols') const { MessagePort } = require('node:worker_threads') @@ -14,7 +14,7 @@ class MessageEvent extends Event { constructor (type, eventInitDict = {}) { if (type === kConstruct) { super(arguments[1], arguments[2]) - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) return } @@ -27,7 +27,7 @@ class MessageEvent extends Event { super(type, eventInitDict) this.#eventInit = eventInitDict - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) } get data () { @@ -114,7 +114,7 @@ class CloseEvent extends Event { super(type, eventInitDict) this.#eventInit = eventInitDict - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) } get wasClean () { diff --git a/lib/web/websocket/websocket.js b/lib/web/websocket/websocket.js index a882932f814..9ece7b256be 100644 --- a/lib/web/websocket/websocket.js +++ b/lib/web/websocket/websocket.js @@ -1,6 +1,6 @@ 'use strict' -const { webidl, maybeMarkAsUncloneable } = require('../fetch/webidl') +const { webidl } = require('../fetch/webidl') const { URLSerializer } = require('../fetch/data-url') const { environmentSettingsObject } = require('../fetch/util') const { staticPropertyDescriptors, states, sentCloseFrameState, sendHints, opcodes } = require('./constants') @@ -100,7 +100,7 @@ class WebSocket extends EventTarget { constructor (url, protocols = []) { super() - maybeMarkAsUncloneable(this) + webidl.util.maybeMarkAsUncloneable(this) const prefix = 'WebSocket constructor' webidl.argumentLengthCheck(arguments, 1, prefix)