happy-dom 15.9.0 → 15.10.0
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/browser/BrowserSettingsFactory.cjs +4 -0
- package/cjs/browser/BrowserSettingsFactory.cjs.map +1 -1
- package/cjs/browser/BrowserSettingsFactory.d.ts.map +1 -1
- package/cjs/browser/DefaultBrowserSettings.cjs +3 -0
- package/cjs/browser/DefaultBrowserSettings.cjs.map +1 -1
- package/cjs/browser/DefaultBrowserSettings.d.ts.map +1 -1
- package/cjs/browser/types/IBrowserSettings.d.ts +14 -1
- package/cjs/browser/types/IBrowserSettings.d.ts.map +1 -1
- package/cjs/browser/types/IOptionalBrowserSettings.d.ts +11 -0
- package/cjs/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
- package/cjs/fetch/Fetch.cjs +10 -7
- package/cjs/fetch/Fetch.cjs.map +1 -1
- package/cjs/fetch/Fetch.d.ts +3 -3
- package/cjs/fetch/Fetch.d.ts.map +1 -1
- package/cjs/fetch/ResourceFetch.cjs +2 -2
- package/cjs/fetch/ResourceFetch.cjs.map +1 -1
- package/cjs/fetch/SyncFetch.cjs +10 -7
- package/cjs/fetch/SyncFetch.cjs.map +1 -1
- package/cjs/fetch/SyncFetch.d.ts +3 -3
- package/cjs/fetch/SyncFetch.d.ts.map +1 -1
- package/lib/browser/BrowserSettingsFactory.d.ts.map +1 -1
- package/lib/browser/BrowserSettingsFactory.js +4 -0
- package/lib/browser/BrowserSettingsFactory.js.map +1 -1
- package/lib/browser/DefaultBrowserSettings.d.ts.map +1 -1
- package/lib/browser/DefaultBrowserSettings.js +3 -0
- package/lib/browser/DefaultBrowserSettings.js.map +1 -1
- package/lib/browser/types/IBrowserSettings.d.ts +14 -1
- package/lib/browser/types/IBrowserSettings.d.ts.map +1 -1
- package/lib/browser/types/IOptionalBrowserSettings.d.ts +11 -0
- package/lib/browser/types/IOptionalBrowserSettings.d.ts.map +1 -1
- package/lib/fetch/Fetch.d.ts +3 -3
- package/lib/fetch/Fetch.d.ts.map +1 -1
- package/lib/fetch/Fetch.js +10 -7
- package/lib/fetch/Fetch.js.map +1 -1
- package/lib/fetch/ResourceFetch.js +2 -2
- package/lib/fetch/ResourceFetch.js.map +1 -1
- package/lib/fetch/SyncFetch.d.ts +3 -3
- package/lib/fetch/SyncFetch.d.ts.map +1 -1
- package/lib/fetch/SyncFetch.js +10 -7
- package/lib/fetch/SyncFetch.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/BrowserSettingsFactory.ts +4 -0
- package/src/browser/DefaultBrowserSettings.ts +3 -0
- package/src/browser/types/IBrowserSettings.ts +15 -1
- package/src/browser/types/IOptionalBrowserSettings.ts +12 -0
- package/src/fetch/Fetch.ts +16 -9
- package/src/fetch/ResourceFetch.ts +2 -2
- package/src/fetch/SyncFetch.ts +16 -9
package/src/fetch/SyncFetch.ts
CHANGED
@@ -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
|
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.
|
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
|
-
|
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.
|
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 '${
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
298
|
+
disableSameOriginPolicy: true,
|
292
299
|
unfilteredHeaders: corsHeaders
|
293
300
|
});
|
294
301
|
|