Socket
Socket
Sign inDemoInstall

jsdom

Package Overview
Dependencies
Maintainers
0
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdom - npm Package Compare versions

Comparing version 24.1.2 to 24.1.3

40

lib/jsdom/browser/Window.js

@@ -5,2 +5,3 @@ "use strict";

const { CSSStyleDeclaration } = require("cssstyle");
const whatwgURL = require("whatwg-url");
const notImplemented = require("./not-implemented");

@@ -17,3 +18,2 @@ const { installInterfaces } = require("../living/interfaces");

const namedPropertiesWindow = require("../living/named-properties-window");
const postMessage = require("../living/post-message");
const DOMException = require("../living/generated/DOMException");

@@ -38,2 +38,3 @@ const idlUtils = require("../living/generated/utils");

const CustomElementRegistry = require("../living/generated/CustomElementRegistry");
const MessageEvent = require("../living/generated/MessageEvent");
const jsGlobals = require("./js-globals.json");

@@ -787,4 +788,39 @@

window.postMessage = postMessage(window);
window.postMessage = function (message, targetOrigin) {
if (arguments.length < 2) {
throw new TypeError("'postMessage' requires 2 arguments: 'message' and 'targetOrigin'");
}
targetOrigin = webIDLConversions.DOMString(targetOrigin);
if (targetOrigin === "/") {
// TODO: targetOrigin === "/" requires getting incumbent settings object.
// Maybe could be done with Error stack traces??
return;
} else if (targetOrigin !== "*") {
const parsedURL = whatwgURL.parseURL(targetOrigin);
if (parsedURL === null) {
throw DOMException.create(window, [
"Failed to execute 'postMessage' on 'Window': " +
"Invalid target origin '" + targetOrigin + "' in a call to 'postMessage'.",
"SyntaxError"
]);
}
targetOrigin = whatwgURL.serializeURLOrigin(parsedURL);
if (targetOrigin !== idlUtils.implForWrapper(window._document)._origin) {
// Not implemented.
return;
}
}
// TODO: event.source - requires reference to incumbent window
// TODO: event.origin - requires reference to incumbent window
// TODO: event.ports
// TODO: event.data - requires structured cloning
setTimeout(() => {
fireAnEvent("message", window, MessageEvent, { data: message });
}, 0);
};
window.atob = function (str) {

@@ -791,0 +827,0 @@ try {

9

lib/jsdom/utils.js
"use strict";
const whatwgURL = require("whatwg-url");
const { domSymbolTree } = require("./living/helpers/internal-constants");

@@ -71,10 +70,2 @@ const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;

function isValidAbsoluteURL(str) {
return whatwgURL.parseURL(str) !== null;
}
exports.isValidTargetOrigin = function (str) {
return str === "*" || str === "/" || isValidAbsoluteURL(str);
};
exports.simultaneousIterators = function* (first, second) {

@@ -81,0 +72,0 @@ for (;;) {

{
"name": "jsdom",
"version": "24.1.2",
"version": "24.1.3",
"description": "A JavaScript implementation of many web standards",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc