Comparing version 24.1.2 to 24.1.3
@@ -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 { |
"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": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3111228
480
82977