Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
convertInherit(obj, ret, { context = "The provided value" } = {}) {
{
const key = "is";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["DOMString"](value, { context: context + " has member is that" });
ret[key] = value;
}
}
},
if (new.target === undefined) {
throw new TypeError(
"Failed to construct 'KeyboardEvent'. Please use the 'new' operator; this constructor " +
"cannot be called as a function."
);
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to construct 'KeyboardEvent': 1 argument required, but only " + arguments.length + " present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = conversions["DOMString"](curArg, { context: "Failed to construct 'KeyboardEvent': parameter 1" });
args.push(curArg);
}
{
let curArg = arguments[1];
curArg = convertKeyboardEventInit(curArg, { context: "Failed to construct 'KeyboardEvent': parameter 2" });
args.push(curArg);
}
iface.setup(this, args);
}
open(method, uri, asynchronous, user, password) {
if (!this._ownerDocument) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
const argumentCount = arguments.length;
if (argumentCount < 2) {
throw new TypeError("Not enough arguments (expected at least 2)");
}
method = conversions.ByteString(method);
uri = conversions.USVString(uri);
if (user) {
user = conversions.USVString(user);
}
if (password) {
password = conversions.USVString(password);
}
if (!tokenRegexp.test(method)) {
throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
}
const upperCaseMethod = method.toUpperCase();
if (forbiddenRequestMethods.has(upperCaseMethod)) {
throw new DOMException("The operation is insecure.", "SecurityError");
}
const { client } = properties;
convertInherit(obj, ret, { context = "The provided value" } = {}) {
EventListenerOptions.convertInherit(obj, ret, { context });
{
const key = "once";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["boolean"](value, { context: context + " has member once that" });
ret[key] = value;
} else {
ret[key] = false;
}
}
},
setRequestHeader(header, value) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (arguments.length !== 2) {
throw new TypeError("2 arguments required for setRequestHeader");
}
header = conversions.ByteString(header);
value = conversions.ByteString(value);
if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
value = normalizeHeaderValue(value);
if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
}
const lcHeader = header.toLowerCase();
if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
return;
setRequestHeader(header, value) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (arguments.length !== 2) {
throw new TypeError("2 arguments required for setRequestHeader");
}
header = conversions.ByteString(header);
value = conversions.ByteString(value);
if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
value = normalizeHeaderValue(value);
if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
}
const lcHeader = header.toLowerCase();
if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
return;
setRequestHeader(header, value) {
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
if (arguments.length !== 2) {
throw new TypeError("2 arguments required for setRequestHeader");
}
header = conversions.ByteString(header);
value = conversions.ByteString(value);
if (this.readyState !== XMLHttpRequest.OPENED || properties.send) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
value = normalizeHeaderValue(value);
if (!tokenRegexp.test(header) || !fieldValueRegexp.test(value)) {
throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
}
const lcHeader = header.toLowerCase();
if (forbiddenRequestHeaders.has(lcHeader) || lcHeader.startsWith("sec-") || lcHeader.startsWith("proxy-")) {
return;
}
open(method, uri, asynchronous, user, password) {
if (!this._ownerDocument) {
throw new DOMException("The object is in an invalid state.", "InvalidStateError");
}
const flag = this[xhrSymbols.flag];
const properties = this[xhrSymbols.properties];
const argumentCount = arguments.length;
if (argumentCount < 2) {
throw new TypeError("Not enough arguments (expected at least 2)");
}
method = conversions.ByteString(method);
uri = conversions.USVString(uri);
if (user) {
user = conversions.USVString(user);
}
if (password) {
password = conversions.USVString(password);
}
if (!tokenRegexp.test(method)) {
throw new DOMException("The string did not match the expected pattern.", "SyntaxError");
}
const upperCaseMethod = method.toUpperCase();
if (forbiddenRequestMethods.has(upperCaseMethod)) {
throw new DOMException("The operation is insecure.", "SecurityError");
}
convertInherit(obj, ret, { context = "The provided value" } = {}) {
EventModifierInit.convertInherit(obj, ret, { context });
{
const key = "button";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["short"](value, { context: context + " has member button that" });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "buttons";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned short"](value, { context: context + " has member buttons that" });
ret[key] = value;
} else {
ret[key] = 0;
convertInherit(obj, ret, { context = "The provided value" } = {}) {
EventModifierInit.convertInherit(obj, ret, { context });
{
const key = "button";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["short"](value, { context: context + " has member button that" });
ret[key] = value;
} else {
ret[key] = 0;
}
}
{
const key = "buttons";
let value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
value = conversions["unsigned short"](value, { context: context + " has member buttons that" });
ret[key] = value;
} else {
ret[key] = 0;