Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isArrayBuffer(data)) {
dataForEvent = data;
} else if (Array.isArray(data)) {
dataForEvent = copyToArrayBufferInNewRealm(Buffer.concat(data), this._globalObject);
} else {
dataForEvent = copyToArrayBufferInNewRealm(data, this._globalObject);
}
} else { // this.binaryType === "blob"
if (!Array.isArray(data)) {
data = [data];
}
dataForEvent = Blob.create(this._globalObject, [data, { type: "" }]);
}
fireAnEvent("message", this, MessageEvent, {
data: dataForEvent,
origin: serializeURLOrigin(this._urlRecord)
});
}
dataForEvent = data;
} else if (Array.isArray(data)) {
dataForEvent = new Uint8Array(Buffer.concat(data)).buffer;
} else {
dataForEvent = new Uint8Array(data).buffer;
}
} else { // this.binaryType === "blob"
if (!Array.isArray(data)) {
data = [data];
}
dataForEvent = Blob.create([data, { type: "" }]);
}
this._dispatch(MessageEvent.createImpl([
"message", {
data: dataForEvent,
origin: serializeURLOrigin(this._urlRecord)
}
], { isTrusted: true }));
}
get origin() {
reinitializeURL(this);
if (this.url === null) {
return "";
}
return whatwgURL.serializeURLOrigin(this.url);
}
get origin() {
return whatwgURL.serializeURLOrigin(this._url);
}
this._ws.onmessage = event => {
fireAnEvent("message", this, MessageEvent, {
data: event.data,
origin: serializeURLOrigin(this._urlRecord)
});
};
this._scriptingDisabled = privateData.options.scriptingDisabled;
if (this._cookieJar === undefined) {
this._cookieJar = new CookieJar(null, { looseMode: true });
}
this.contentType = privateData.options.contentType;
this._encoding = privateData.options.encoding;
const urlOption = privateData.options.url === undefined ? "about:blank" : privateData.options.url;
const parsed = whatwgURL.parseURL(urlOption);
if (parsed === null) {
throw new TypeError(`Could not parse "${urlOption}" as a URL`);
}
this._URL = parsed;
this.origin = whatwgURL.serializeURLOrigin(parsed);
this._location = Location.createImpl(this._globalObject, [], { relevantDocument: this });
this._history = History.createImpl(this._globalObject, [], {
window: this._defaultView,
document: this,
actAsIfLocationReloadCalled: () => this._location.reload()
});
this._workingNodeIterators = [];
this._workingNodeIteratorsMax = privateData.options.concurrentNodeIterators === undefined ?
10 :
Number(privateData.options.concurrentNodeIterators);
if (isNaN(this._workingNodeIteratorsMax)) {
throw new TypeError("The 'concurrentNodeIterators' option must be a Number");
}
reconfigure(settings) {
if ("windowTop" in settings) {
this[window]._top = settings.windowTop;
}
if ("url" in settings) {
const document = idlUtils.implForWrapper(this[window]._document);
const url = whatwgURL.parseURL(settings.url);
if (url === null) {
throw new TypeError(`Could not parse "${settings.url}" as a URL`);
}
document._URL = url;
document.origin = whatwgURL.serializeURLOrigin(document._URL);
}
}
exports.changeURL = function (window, urlString) {
const doc = idlUtils.implForWrapper(window._document);
const url = whatwgURL.parseURL(urlString);
if (url === null) {
throw new TypeError(`Could not parse "${urlString}" as a URL`);
}
doc._URL = url;
doc.origin = whatwgURL.serializeURLOrigin(doc._URL);
};
get origin() {
reinitializeURL(this);
if (this.url === null) {
return "";
}
return whatwgURL.serializeURLOrigin(this.url);
}
this._ws.onmessage = event => {
this._dispatch(MessageEvent.createImpl([
"message", {
data: event.data,
origin: serializeURLOrigin(this._urlRecord)
}
], {
isTrusted: true
}));
};