happy-dom 15.9.0 → 15.10.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.

Files changed (64) hide show
  1. package/cjs/browser/BrowserSettingsFactory.cjs +4 -0
  2. package/cjs/browser/BrowserSettingsFactory.cjs.map +1 -1
  3. package/cjs/browser/BrowserSettingsFactory.d.ts.map +1 -1
  4. package/cjs/browser/DefaultBrowserSettings.cjs +3 -0
  5. package/cjs/browser/DefaultBrowserSettings.cjs.map +1 -1
  6. package/cjs/browser/DefaultBrowserSettings.d.ts.map +1 -1
  7. package/cjs/browser/types/IBrowserSettings.d.ts +14 -1
  8. package/cjs/browser/types/IBrowserSettings.d.ts.map +1 -1
  9. package/cjs/browser/types/IOptionalBrowserSettings.d.ts +11 -0
  10. package/cjs/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
  11. package/cjs/fetch/Fetch.cjs +10 -7
  12. package/cjs/fetch/Fetch.cjs.map +1 -1
  13. package/cjs/fetch/Fetch.d.ts +3 -3
  14. package/cjs/fetch/Fetch.d.ts.map +1 -1
  15. package/cjs/fetch/ResourceFetch.cjs +2 -2
  16. package/cjs/fetch/ResourceFetch.cjs.map +1 -1
  17. package/cjs/fetch/SyncFetch.cjs +10 -7
  18. package/cjs/fetch/SyncFetch.cjs.map +1 -1
  19. package/cjs/fetch/SyncFetch.d.ts +3 -3
  20. package/cjs/fetch/SyncFetch.d.ts.map +1 -1
  21. package/cjs/fetch/utilities/SyncFetchScriptBuilder.cjs +1 -1
  22. package/cjs/fetch/utilities/SyncFetchScriptBuilder.cjs.map +1 -1
  23. package/cjs/fetch/utilities/SyncFetchScriptBuilder.d.ts.map +1 -1
  24. package/lib/browser/BrowserSettingsFactory.d.ts.map +1 -1
  25. package/lib/browser/BrowserSettingsFactory.js +4 -0
  26. package/lib/browser/BrowserSettingsFactory.js.map +1 -1
  27. package/lib/browser/DefaultBrowserSettings.d.ts.map +1 -1
  28. package/lib/browser/DefaultBrowserSettings.js +3 -0
  29. package/lib/browser/DefaultBrowserSettings.js.map +1 -1
  30. package/lib/browser/types/IBrowserSettings.d.ts +14 -1
  31. package/lib/browser/types/IBrowserSettings.d.ts.map +1 -1
  32. package/lib/browser/types/IOptionalBrowserSettings.d.ts +11 -0
  33. package/lib/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
  34. package/lib/fetch/Fetch.d.ts +3 -3
  35. package/lib/fetch/Fetch.d.ts.map +1 -1
  36. package/lib/fetch/Fetch.js +10 -7
  37. package/lib/fetch/Fetch.js.map +1 -1
  38. package/lib/fetch/ResourceFetch.js +2 -2
  39. package/lib/fetch/ResourceFetch.js.map +1 -1
  40. package/lib/fetch/SyncFetch.d.ts +3 -3
  41. package/lib/fetch/SyncFetch.d.ts.map +1 -1
  42. package/lib/fetch/SyncFetch.js +10 -7
  43. package/lib/fetch/SyncFetch.js.map +1 -1
  44. package/lib/fetch/utilities/SyncFetchScriptBuilder.d.ts.map +1 -1
  45. package/lib/fetch/utilities/SyncFetchScriptBuilder.js +1 -1
  46. package/lib/fetch/utilities/SyncFetchScriptBuilder.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/browser/BrowserSettingsFactory.ts +4 -0
  49. package/src/browser/DefaultBrowserSettings.ts +3 -0
  50. package/src/browser/types/IBrowserSettings.ts +15 -1
  51. package/src/browser/types/IOptionalBrowserSettings.ts +12 -0
  52. package/src/fetch/Fetch.ts +16 -9
  53. package/src/fetch/ResourceFetch.ts +2 -2
  54. package/src/fetch/SyncFetch.ts +16 -9
  55. package/src/fetch/utilities/SyncFetchScriptBuilder.ts +2 -1
  56. package/cjs/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.cjs +0 -28
  57. package/cjs/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.cjs.map +0 -1
  58. package/cjs/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.d.ts +0 -2
  59. package/cjs/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.d.ts.map +0 -1
  60. package/lib/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.d.ts +0 -2
  61. package/lib/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.d.ts.map +0 -1
  62. package/lib/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.js +0 -23
  63. package/lib/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.js.map +0 -1
  64. package/src/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.ts +0 -27
@@ -53,7 +53,7 @@ export default class Fetch {
53
53
  private request: Request;
54
54
  private redirectCount = 0;
55
55
  private disableCache: boolean;
56
- private disableCrossOriginPolicy: boolean;
56
+ private disableSameOriginPolicy: boolean;
57
57
  #browserFrame: IBrowserFrame;
58
58
  #window: BrowserWindow;
59
59
  #unfilteredHeaders: Headers | null = null;
@@ -69,7 +69,7 @@ export default class Fetch {
69
69
  * @param [options.redirectCount] Redirect count.
70
70
  * @param [options.contentType] Content Type.
71
71
  * @param [options.disableCache] Disables the use of cached responses. It will still store the response in the cache.
72
- * @param [options.disableCrossOriginPolicy] Disables the Cross-Origin policy.
72
+ * @param [options.disableSameOriginPolicy] Disables the Same-Origin policy.
73
73
  * @param [options.unfilteredHeaders] Unfiltered headers - necessary for preflight requests.
74
74
  */
75
75
  constructor(options: {
@@ -80,7 +80,7 @@ export default class Fetch {
80
80
  redirectCount?: number;
81
81
  contentType?: string;
82
82
  disableCache?: boolean;
83
- disableCrossOriginPolicy?: boolean;
83
+ disableSameOriginPolicy?: boolean;
84
84
  unfilteredHeaders?: Headers;
85
85
  }) {
86
86
  this.#browserFrame = options.browserFrame;
@@ -95,7 +95,10 @@ export default class Fetch {
95
95
  }
96
96
  this.redirectCount = options.redirectCount ?? 0;
97
97
  this.disableCache = options.disableCache ?? false;
98
- this.disableCrossOriginPolicy = options.disableCrossOriginPolicy ?? false;
98
+ this.disableSameOriginPolicy =
99
+ options.disableSameOriginPolicy ??
100
+ this.#browserFrame.page.context.browser.settings.fetch.disableSameOriginPolicy ??
101
+ false;
99
102
  }
100
103
 
101
104
  /**
@@ -128,7 +131,11 @@ export default class Fetch {
128
131
  this.#window.location.protocol === 'https:'
129
132
  ) {
130
133
  throw new this.#window.DOMException(
131
- `Mixed Content: The page at '${this.#window.location.href}' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${this.request.url}'. This request has been blocked; the content must be served over HTTPS.`,
134
+ `Mixed Content: The page at '${
135
+ this.#window.location.href
136
+ }' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${
137
+ this.request.url
138
+ }'. This request has been blocked; the content must be served over HTTPS.`,
132
139
  DOMExceptionNameEnum.securityError
133
140
  );
134
141
  }
@@ -141,7 +148,7 @@ export default class Fetch {
141
148
  }
142
149
  }
143
150
 
144
- if (!this.disableCrossOriginPolicy) {
151
+ if (!this.disableSameOriginPolicy) {
145
152
  const compliesWithCrossOriginPolicy = await this.compliesWithCrossOriginPolicy();
146
153
 
147
154
  if (!compliesWithCrossOriginPolicy) {
@@ -192,7 +199,7 @@ export default class Fetch {
192
199
  url: this.request.url,
193
200
  init: { headers, method: cachedResponse.request.method },
194
201
  disableCache: true,
195
- disableCrossOriginPolicy: true
202
+ disableSameOriginPolicy: true
196
203
  });
197
204
 
198
205
  if (cachedResponse.etag || !cachedResponse.staleWhileRevalidate) {
@@ -251,7 +258,7 @@ export default class Fetch {
251
258
  */
252
259
  private async compliesWithCrossOriginPolicy(): Promise<boolean> {
253
260
  if (
254
- this.disableCrossOriginPolicy ||
261
+ this.disableSameOriginPolicy ||
255
262
  !FetchCORSUtility.isCORS(this.#window.location.href, this.request[PropertySymbol.url])
256
263
  ) {
257
264
  return true;
@@ -303,7 +310,7 @@ export default class Fetch {
303
310
  url: this.request.url,
304
311
  init: { method: 'OPTIONS' },
305
312
  disableCache: true,
306
- disableCrossOriginPolicy: true,
313
+ disableSameOriginPolicy: true,
307
314
  unfilteredHeaders: corsHeaders
308
315
  });
309
316
 
@@ -34,7 +34,7 @@ export default class ResourceFetch {
34
34
  browserFrame: this.#browserFrame,
35
35
  window: this.window,
36
36
  url,
37
- disableCrossOriginPolicy: true
37
+ disableSameOriginPolicy: true
38
38
  });
39
39
  const response = await fetch.send();
40
40
 
@@ -60,7 +60,7 @@ export default class ResourceFetch {
60
60
  browserFrame: this.#browserFrame,
61
61
  window: this.window,
62
62
  url,
63
- disableCrossOriginPolicy: true
63
+ disableSameOriginPolicy: true
64
64
  });
65
65
 
66
66
  const response = fetch.send();
@@ -38,7 +38,7 @@ export default class SyncFetch {
38
38
  private request: Request;
39
39
  private redirectCount = 0;
40
40
  private disableCache: boolean;
41
- private disableCrossOriginPolicy: boolean;
41
+ private disableSameOriginPolicy: boolean;
42
42
  #browserFrame: IBrowserFrame;
43
43
  #window: BrowserWindow;
44
44
  #unfilteredHeaders: Headers | null = null;
@@ -54,7 +54,7 @@ export default class SyncFetch {
54
54
  * @param [options.redirectCount] Redirect count.
55
55
  * @param [options.contentType] Content Type.
56
56
  * @param [options.disableCache] Disables the use of cached responses. It will still store the response in the cache.
57
- * @param [options.disableCrossOriginPolicy] Disables the Cross-Origin policy.
57
+ * @param [options.disableSameOriginPolicy] Disables the Same-Origin policy.
58
58
  * @param [options.unfilteredHeaders] Unfiltered headers - necessary for preflight requests.
59
59
  */
60
60
  constructor(options: {
@@ -65,7 +65,7 @@ export default class SyncFetch {
65
65
  redirectCount?: number;
66
66
  contentType?: string;
67
67
  disableCache?: boolean;
68
- disableCrossOriginPolicy?: boolean;
68
+ disableSameOriginPolicy?: boolean;
69
69
  unfilteredHeaders?: Headers;
70
70
  }) {
71
71
  this.#browserFrame = options.browserFrame;
@@ -80,7 +80,10 @@ export default class SyncFetch {
80
80
  }
81
81
  this.redirectCount = options.redirectCount ?? 0;
82
82
  this.disableCache = options.disableCache ?? false;
83
- this.disableCrossOriginPolicy = options.disableCrossOriginPolicy ?? false;
83
+ this.disableSameOriginPolicy =
84
+ options.disableSameOriginPolicy ??
85
+ this.#browserFrame.page.context.browser.settings.fetch.disableSameOriginPolicy ??
86
+ false;
84
87
  }
85
88
 
86
89
  /**
@@ -118,7 +121,11 @@ export default class SyncFetch {
118
121
  this.#window.location.protocol === 'https:'
119
122
  ) {
120
123
  throw new this.#window.DOMException(
121
- `Mixed Content: The page at '${this.#window.location.href}' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${this.request.url}'. This request has been blocked; the content must be served over HTTPS.`,
124
+ `Mixed Content: The page at '${
125
+ this.#window.location.href
126
+ }' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${
127
+ this.request.url
128
+ }'. This request has been blocked; the content must be served over HTTPS.`,
122
129
  DOMExceptionNameEnum.securityError
123
130
  );
124
131
  }
@@ -177,7 +184,7 @@ export default class SyncFetch {
177
184
  url: this.request.url,
178
185
  init: { headers, method: cachedResponse.request.method },
179
186
  disableCache: true,
180
- disableCrossOriginPolicy: true
187
+ disableSameOriginPolicy: true
181
188
  });
182
189
 
183
190
  const validateResponse = <ISyncResponse>fetch.send();
@@ -199,7 +206,7 @@ export default class SyncFetch {
199
206
  url: this.request.url,
200
207
  init: { headers, method: cachedResponse.request.method },
201
208
  disableCache: true,
202
- disableCrossOriginPolicy: true
209
+ disableSameOriginPolicy: true
203
210
  });
204
211
  fetch.send().then((response) => {
205
212
  response.buffer().then((body: Buffer) => {
@@ -236,7 +243,7 @@ export default class SyncFetch {
236
243
  */
237
244
  private compliesWithCrossOriginPolicy(): boolean {
238
245
  if (
239
- this.disableCrossOriginPolicy ||
246
+ this.disableSameOriginPolicy ||
240
247
  !FetchCORSUtility.isCORS(this.#window.location.href, this.request[PropertySymbol.url])
241
248
  ) {
242
249
  return true;
@@ -288,7 +295,7 @@ export default class SyncFetch {
288
295
  url: this.request.url,
289
296
  init: { method: 'OPTIONS' },
290
297
  disableCache: true,
291
- disableCrossOriginPolicy: true,
298
+ disableSameOriginPolicy: true,
292
299
  unfilteredHeaders: corsHeaders
293
300
  });
294
301
 
@@ -23,6 +23,7 @@ export default class SyncFetchScriptBuilder {
23
23
  }): string {
24
24
  const sortedHeaders = {};
25
25
  const headerNames = Object.keys(request.headers).sort();
26
+
26
27
  for (const name of headerNames) {
27
28
  sortedHeaders[name] = request.headers[name];
28
29
  }
@@ -43,7 +44,7 @@ export default class SyncFetchScriptBuilder {
43
44
  null,
44
45
  4
45
46
  )};
46
- const request = sendRequest('${request.url.href}', options, (incomingMessage) => {
47
+ const request = sendRequest(\`${request.url.href}\`, options, (incomingMessage) => {
47
48
  let data = Buffer.alloc(0);
48
49
  incomingMessage.on('data', (chunk) => {
49
50
  data = Buffer.concat([data, Buffer.from(chunk)]);
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const SVGAnimateMotionElement_js_1 = __importDefault(require("../../../src/nodes/svg-animate-motion-element/SVGAnimateMotionElement.cjs"));
7
- const Window_js_1 = __importDefault(require("../../../src/window/Window.cjs"));
8
- const vitest_1 = require("vitest");
9
- const SVGAnimationElement_js_1 = __importDefault(require("../../../src/nodes/svg-animation-element/SVGAnimationElement.cjs"));
10
- (0, vitest_1.describe)('SVGAnimateMotionElement', () => {
11
- let window;
12
- let document;
13
- let element;
14
- (0, vitest_1.beforeEach)(() => {
15
- window = new Window_js_1.default();
16
- document = window.document;
17
- element = document.createElementNS('http://www.w3.org/2000/svg', 'animateMotion');
18
- });
19
- (0, vitest_1.describe)('constructor()', () => {
20
- (0, vitest_1.it)('Should be an instanceof SVGAnimateMotionElement', () => {
21
- (0, vitest_1.expect)(element instanceof SVGAnimateMotionElement_js_1.default).toBe(true);
22
- });
23
- (0, vitest_1.it)('Should be an instanceof SVGAnimationElement', () => {
24
- (0, vitest_1.expect)(element instanceof SVGAnimationElement_js_1.default).toBe(true);
25
- });
26
- });
27
- });
28
- //# sourceMappingURL=SVGAnimateMotionElement.test.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SVGAnimateMotionElement.test.cjs","sourceRoot":"","sources":["../../../src/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.ts"],"names":[],"mappings":";;;;;AAAA,0IAA+G;AAC/G,8EAAmD;AAEnD,mCAA0D;AAC1D,6HAAkG;AAElG,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,IAAI,MAAc,CAAC;IACnB,IAAI,QAAkB,CAAC;IACvB,IAAI,OAAgC,CAAC;IAErC,IAAA,mBAAU,EAAC,GAAG,EAAE;QACf,MAAM,GAAG,IAAI,mBAAM,EAAE,CAAC;QACtB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC3B,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,eAAe,EAAE,GAAG,EAAE;QAC9B,IAAA,WAAE,EAAC,iDAAiD,EAAE,GAAG,EAAE;YAC1D,IAAA,eAAM,EAAC,OAAO,YAAY,oCAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,6CAA6C,EAAE,GAAG,EAAE;YACtD,IAAA,eAAM,EAAC,OAAO,YAAY,gCAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SVGAnimateMotionElement.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SVGAnimateMotionElement.test.d.ts","sourceRoot":"","sources":["../../../src/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=SVGAnimateMotionElement.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SVGAnimateMotionElement.test.d.ts","sourceRoot":"","sources":["../../../src/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import SVGAnimateMotionElement from '../../../src/nodes/svg-animate-motion-element/SVGAnimateMotionElement.js';
2
- import Window from '../../../src/window/Window.js';
3
- import { beforeEach, describe, it, expect } from 'vitest';
4
- import SVGAnimationElement from '../../../src/nodes/svg-animation-element/SVGAnimationElement.js';
5
- describe('SVGAnimateMotionElement', () => {
6
- let window;
7
- let document;
8
- let element;
9
- beforeEach(() => {
10
- window = new Window();
11
- document = window.document;
12
- element = document.createElementNS('http://www.w3.org/2000/svg', 'animateMotion');
13
- });
14
- describe('constructor()', () => {
15
- it('Should be an instanceof SVGAnimateMotionElement', () => {
16
- expect(element instanceof SVGAnimateMotionElement).toBe(true);
17
- });
18
- it('Should be an instanceof SVGAnimationElement', () => {
19
- expect(element instanceof SVGAnimationElement).toBe(true);
20
- });
21
- });
22
- });
23
- //# sourceMappingURL=SVGAnimateMotionElement.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SVGAnimateMotionElement.test.js","sourceRoot":"","sources":["../../../src/nodes/svg-animate-motion-element copy/SVGAnimateMotionElement.test.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,0EAA0E,CAAC;AAC/G,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,mBAAmB,MAAM,iEAAiE,CAAC;AAElG,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,IAAI,MAAc,CAAC;IACnB,IAAI,QAAkB,CAAC;IACvB,IAAI,OAAgC,CAAC;IAErC,UAAU,CAAC,GAAG,EAAE;QACf,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACtB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC3B,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YAC1D,MAAM,CAAC,OAAO,YAAY,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACtD,MAAM,CAAC,OAAO,YAAY,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,27 +0,0 @@
1
- import SVGAnimateMotionElement from '../../../src/nodes/svg-animate-motion-element/SVGAnimateMotionElement.js';
2
- import Window from '../../../src/window/Window.js';
3
- import Document from '../../../src/nodes/document/Document.js';
4
- import { beforeEach, describe, it, expect } from 'vitest';
5
- import SVGAnimationElement from '../../../src/nodes/svg-animation-element/SVGAnimationElement.js';
6
-
7
- describe('SVGAnimateMotionElement', () => {
8
- let window: Window;
9
- let document: Document;
10
- let element: SVGAnimateMotionElement;
11
-
12
- beforeEach(() => {
13
- window = new Window();
14
- document = window.document;
15
- element = document.createElementNS('http://www.w3.org/2000/svg', 'animateMotion');
16
- });
17
-
18
- describe('constructor()', () => {
19
- it('Should be an instanceof SVGAnimateMotionElement', () => {
20
- expect(element instanceof SVGAnimateMotionElement).toBe(true);
21
- });
22
-
23
- it('Should be an instanceof SVGAnimationElement', () => {
24
- expect(element instanceof SVGAnimationElement).toBe(true);
25
- });
26
- });
27
- });