happy-dom 14.0.0 → 14.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/cjs/PropertySymbol.cjs +7 -1
- package/cjs/PropertySymbol.cjs.map +1 -1
- package/cjs/PropertySymbol.d.ts +6 -0
- package/cjs/PropertySymbol.d.ts.map +1 -1
- package/cjs/browser/types/IBrowserSettings.d.ts +2 -0
- package/cjs/browser/types/IBrowserSettings.d.ts.map +1 -1
- package/cjs/browser/types/IOptionalBrowserSettings.d.ts +2 -0
- package/cjs/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs +6 -1
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs +6 -1
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
- package/cjs/window/BrowserWindow.cjs +51 -7
- package/cjs/window/BrowserWindow.cjs.map +1 -1
- package/cjs/window/BrowserWindow.d.ts +37 -7
- package/cjs/window/BrowserWindow.d.ts.map +1 -1
- package/lib/PropertySymbol.d.ts +6 -0
- package/lib/PropertySymbol.d.ts.map +1 -1
- package/lib/PropertySymbol.js +6 -0
- package/lib/PropertySymbol.js.map +1 -1
- package/lib/browser/types/IBrowserSettings.d.ts +2 -0
- package/lib/browser/types/IBrowserSettings.d.ts.map +1 -1
- package/lib/browser/types/IOptionalBrowserSettings.d.ts +2 -0
- package/lib/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js +6 -1
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js +6 -1
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js.map +1 -1
- package/lib/window/BrowserWindow.d.ts +37 -7
- package/lib/window/BrowserWindow.d.ts.map +1 -1
- package/lib/window/BrowserWindow.js +51 -7
- package/lib/window/BrowserWindow.js.map +1 -1
- package/package.json +1 -1
- package/src/PropertySymbol.ts +6 -0
- package/src/browser/types/IBrowserSettings.ts +3 -0
- package/src/browser/types/IOptionalBrowserSettings.ts +3 -0
- package/src/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.ts +11 -7
- package/src/nodes/html-script-element/HTMLScriptElementScriptLoader.ts +11 -7
- package/src/window/BrowserWindow.ts +65 -13
@@ -14,6 +14,9 @@ export default interface IOptionalBrowserSettings {
|
|
14
14
|
/** Disables computed style rendering. */
|
15
15
|
disableComputedStyleRendering?: boolean;
|
16
16
|
|
17
|
+
/** Handle disabled file loading as success */
|
18
|
+
handleDisabledFileLoadingAsSuccess?: boolean;
|
19
|
+
|
17
20
|
/**
|
18
21
|
* Disables error capturing.
|
19
22
|
*
|
@@ -63,13 +63,17 @@ export default class HTMLLinkElementStyleSheetLoader {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
if (browserSettings.disableCSSFileLoading) {
|
66
|
-
|
67
|
-
element
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
if (browserSettings.handleDisabledFileLoadingAsSuccess) {
|
67
|
+
element.dispatchEvent(new Event('load'));
|
68
|
+
} else {
|
69
|
+
WindowErrorUtility.dispatchError(
|
70
|
+
element,
|
71
|
+
new DOMException(
|
72
|
+
`Failed to load external stylesheet "${absoluteURL}". CSS file loading is disabled.`,
|
73
|
+
DOMExceptionNameEnum.notSupportedError
|
74
|
+
)
|
75
|
+
);
|
76
|
+
}
|
73
77
|
return;
|
74
78
|
}
|
75
79
|
|
@@ -61,13 +61,17 @@ export default class HTMLScriptElementScriptLoader {
|
|
61
61
|
browserSettings.disableJavaScriptFileLoading ||
|
62
62
|
browserSettings.disableJavaScriptEvaluation
|
63
63
|
) {
|
64
|
-
|
65
|
-
element
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
if (browserSettings.handleDisabledFileLoadingAsSuccess) {
|
65
|
+
element.dispatchEvent(new Event('load'));
|
66
|
+
} else {
|
67
|
+
WindowErrorUtility.dispatchError(
|
68
|
+
element,
|
69
|
+
new DOMException(
|
70
|
+
`Failed to load external script "${absoluteURL}". JavaScript file loading is disabled.`,
|
71
|
+
DOMExceptionNameEnum.notSupportedError
|
72
|
+
)
|
73
|
+
);
|
74
|
+
}
|
71
75
|
return;
|
72
76
|
}
|
73
77
|
|
@@ -408,18 +408,11 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
408
408
|
// Public properties.
|
409
409
|
public readonly document: DocumentImplementation;
|
410
410
|
public readonly customElements: CustomElementRegistry;
|
411
|
-
public readonly location: Location;
|
412
|
-
public readonly history: History;
|
413
|
-
public readonly navigator: Navigator;
|
414
|
-
public readonly console: Console;
|
415
411
|
public readonly self: BrowserWindow = this;
|
416
412
|
public readonly top: BrowserWindow = this;
|
417
413
|
public readonly parent: BrowserWindow = this;
|
418
414
|
public readonly window: BrowserWindow = this;
|
419
415
|
public readonly globalThis: BrowserWindow = this;
|
420
|
-
public readonly screen: Screen;
|
421
|
-
public readonly sessionStorage: Storage;
|
422
|
-
public readonly localStorage: Storage;
|
423
416
|
public readonly performance: typeof performance = performance;
|
424
417
|
public readonly screenLeft: number = 0;
|
425
418
|
public readonly screenTop: number = 0;
|
@@ -427,6 +420,7 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
427
420
|
public readonly screenY: number = 0;
|
428
421
|
public readonly crypto: typeof webcrypto = webcrypto;
|
429
422
|
public readonly closed = false;
|
423
|
+
public console: Console;
|
430
424
|
public name = '';
|
431
425
|
|
432
426
|
// Node.js Globals
|
@@ -497,6 +491,12 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
497
491
|
public [PropertySymbol.captureEventListenerCount]: { [eventType: string]: number } = {};
|
498
492
|
public readonly [PropertySymbol.mutationObservers]: MutationObserver[] = [];
|
499
493
|
public readonly [PropertySymbol.readyStateManager] = new DocumentReadyStateManager(this);
|
494
|
+
public [PropertySymbol.location]: Location;
|
495
|
+
public [PropertySymbol.history]: History;
|
496
|
+
public [PropertySymbol.navigator]: Navigator;
|
497
|
+
public [PropertySymbol.screen]: Screen;
|
498
|
+
public [PropertySymbol.sessionStorage]: Storage;
|
499
|
+
public [PropertySymbol.localStorage]: Storage;
|
500
500
|
|
501
501
|
// Private properties
|
502
502
|
#browserFrame: IBrowserFrame;
|
@@ -519,12 +519,13 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
519
519
|
this.#browserFrame = browserFrame;
|
520
520
|
|
521
521
|
this.customElements = new CustomElementRegistry(this);
|
522
|
-
this.navigator = new Navigator(this);
|
523
|
-
this.history = new History();
|
524
|
-
this.screen = new Screen();
|
525
|
-
this.sessionStorage = new Storage();
|
526
|
-
this.localStorage = new Storage();
|
527
|
-
this.location = new Location(this.#browserFrame, options?.url ?? 'about:blank');
|
522
|
+
this[PropertySymbol.navigator] = new Navigator(this);
|
523
|
+
this[PropertySymbol.history] = new History();
|
524
|
+
this[PropertySymbol.screen] = new Screen();
|
525
|
+
this[PropertySymbol.sessionStorage] = new Storage();
|
526
|
+
this[PropertySymbol.localStorage] = new Storage();
|
527
|
+
this[PropertySymbol.location] = new Location(this.#browserFrame, options?.url ?? 'about:blank');
|
528
|
+
|
528
529
|
this.console = browserFrame.page.console;
|
529
530
|
|
530
531
|
WindowBrowserSettingsReader.setSettings(this, this.#browserFrame.page.context.browser.settings);
|
@@ -673,6 +674,57 @@ export default class BrowserWindow extends EventTarget implements INodeJSGlobal
|
|
673
674
|
});
|
674
675
|
}
|
675
676
|
|
677
|
+
/**
|
678
|
+
* Returns location.
|
679
|
+
*/
|
680
|
+
public get location(): Location {
|
681
|
+
return this[PropertySymbol.location];
|
682
|
+
}
|
683
|
+
|
684
|
+
/**
|
685
|
+
* Returns location.
|
686
|
+
*
|
687
|
+
* @param href Href.
|
688
|
+
*/
|
689
|
+
public set location(href: string) {
|
690
|
+
this[PropertySymbol.location].href = href;
|
691
|
+
}
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Returns history.
|
695
|
+
*/
|
696
|
+
public get history(): History {
|
697
|
+
return this[PropertySymbol.history];
|
698
|
+
}
|
699
|
+
|
700
|
+
/**
|
701
|
+
* Returns navigator.
|
702
|
+
*/
|
703
|
+
public get navigator(): Navigator {
|
704
|
+
return this[PropertySymbol.navigator];
|
705
|
+
}
|
706
|
+
|
707
|
+
/**
|
708
|
+
* Returns screen.
|
709
|
+
*/
|
710
|
+
public get screen(): Screen {
|
711
|
+
return this[PropertySymbol.screen];
|
712
|
+
}
|
713
|
+
|
714
|
+
/**
|
715
|
+
* Returns session storage.
|
716
|
+
*/
|
717
|
+
public get sessionStorage(): Storage {
|
718
|
+
return this[PropertySymbol.sessionStorage];
|
719
|
+
}
|
720
|
+
|
721
|
+
/**
|
722
|
+
* Returns local storage.
|
723
|
+
*/
|
724
|
+
public get localStorage(): Storage {
|
725
|
+
return this[PropertySymbol.localStorage];
|
726
|
+
}
|
727
|
+
|
676
728
|
/**
|
677
729
|
* Returns opener.
|
678
730
|
*
|