Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Window(options) {
EventTarget.setup(this);
const rawPerformance = new RawPerformance();
const windowInitialized = rawPerformance.now();
const window = this;
mixin(window, WindowEventHandlersImpl.prototype);
mixin(window, GlobalEventHandlersImpl.prototype);
this._initGlobalEvents();
///// INTERFACES FROM THE DOM
// TODO: consider a mode of some sort where these are not shared between all DOM instances
// It'd be very memory-expensive in most cases, though.
for (const name in dom) {
Object.defineProperty(window, name, {
enumerable: false,
configurable: true,
function Window(options) {
EventTarget.setup(this);
const rawPerformance = new RawPerformance();
const windowInitialized = rawPerformance.now();
const window = this;
mixin(window, WindowEventHandlersImpl.prototype);
mixin(window, GlobalEventHandlersImpl.prototype);
this._initGlobalEvents();
///// INTERFACES FROM THE DOM
// TODO: consider a mode of some sort where these are not shared between all DOM instances
// It'd be very memory-expensive in most cases, though.
for (const name in dom) {
Object.defineProperty(window, name, {
enumerable: false,
configurable: true,
function Window(options) {
setupWindow(this, { runScripts: options.runScripts });
const rawPerformance = new RawPerformance();
const windowInitialized = rawPerformance.now();
const window = this;
///// PRIVATE DATA PROPERTIES
this._resourceLoader = options.resourceLoader;
// vm initialization is deferred until script processing is activated
this._globalProxy = this;
Object.defineProperty(idlUtils.implForWrapper(this), idlUtils.wrapperSymbol, { get: () => this._globalProxy });
let timers = Object.create(null);
let animationFrameCallbacks = Object.create(null);
// List options explicitly to be clear which are passed through
this.Headers = Headers;
this.importScripts = () => {};
this.indexedDB = new IDBFactory();
this.IDBKeyRange = IDBKeyRange;
this.IDBDatabase = IDBDatabase;
this.IDBObjectStore = IDBObjectStore;
this.resetIDB = resetIDB;
this.MessageEvent = MessageEvent;
this.MessageChannel = MessageChannel;
this.MessagePort = MessagePort;
this.Notification = Notification;
this.NotificationEvent = NotificationEvent;
this.PushEvent = PushEvent;
this.PushManager = PushManager;
this.PushSubscription = PushSubscription;
this.performance = new Performance();
this.Request = Request;
this.Response = Response;
this.SyncEvent = SyncEvent;
this.ServiceWorkerGlobalScope = ServiceWorkerGlobalScope;
this.URL = URL;
this.URLSearchParams = URLSearchParams;
this.navigator = {};
this.navigator.userAgent = options.userAgent;
this.WindowClient = WindowClient;
this.trigger = (name, args) => {
if (this.listeners.has(name)) {
return eventHandler(
name,
args,