Files
headroom/frontend/node_modules/happy-dom/lib/window/CrossOriginBrowserWindow.js
Santhosh Janardhanan de2d83092e feat: Reinitialize frontend with SvelteKit and TypeScript
- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
2026-02-17 16:19:59 -05:00

120 lines
3.1 KiB
JavaScript

import EventTarget from '../event/EventTarget.js';
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
import * as PropertySymbol from '../PropertySymbol.js';
/**
* Browser window with limited access due to CORS restrictions in iframes.
*/
export default class CrossOriginBrowserWindow extends EventTarget {
window = this;
location;
// Internal properties
[PropertySymbol.self] = this;
// Private properties
#targetWindow;
/**
* Constructor.
*
* @param target Target window.
* @param [parent] Parent window.
*/
constructor(target, parent) {
super();
this[PropertySymbol.parent] = parent ?? this;
this[PropertySymbol.top] = parent ?? this;
this.location = new Proxy({}, {
get: () => {
throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum.securityError);
},
set: () => {
throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum.securityError);
}
});
this.#targetWindow = target;
}
/**
* Returns self.
*
* @returns Self.
*/
get self() {
return this[PropertySymbol.self];
}
/**
* Returns self.
*
* @param self Self.
*/
set self(self) {
this[PropertySymbol.self] = self;
}
/**
* Returns top.
*
* @returns Top.
*/
get top() {
return this[PropertySymbol.top];
}
/**
* Returns parent.
*
* @returns Parent.
*/
get parent() {
return this[PropertySymbol.parent];
}
/**
* Returns parent.
*
* @param parent Parent.
*/
set parent(parent) {
this[PropertySymbol.parent] = parent;
}
/**
* Returns the opener.
*
* @returns Opener.
*/
get opener() {
return this.#targetWindow.opener;
}
/**
* Returns the closed state.
*
* @returns Closed state.
*/
get closed() {
return this.#targetWindow.closed;
}
/**
* Shifts focus away from the window.
*/
blur() {
this.#targetWindow.blur();
}
/**
* Gives focus to the window.
*/
focus() {
this.#targetWindow.focus();
}
/**
* Closes the window.
*/
close() {
this.#targetWindow.close();
}
/**
* Safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
*
* @param message Message.
* @param [targetOrigin=*] Target origin.
* @param transfer Transfer. Not implemented.
*/
postMessage(message, targetOrigin = '*', transfer) {
this.#targetWindow.postMessage(message, targetOrigin, transfer);
}
}
//# sourceMappingURL=CrossOriginBrowserWindow.js.map