Set Response.type to basic on same-origin requests

This commit is contained in:
Karl Seguin
2025-09-23 11:35:51 +08:00
parent db166b4633
commit 6bad2b16e4
3 changed files with 32 additions and 4 deletions

View File

@@ -3,6 +3,24 @@
const promise1 = new Promise((resolve) => {
fetch('http://127.0.0.1:9582/xhr/json')
.then((res) => {
testing.expectEqual('cors', res.type);
return res.json()
})
.then((json) => {
resolve(json);
});
});
testing.async(promise1, (json) => {
testing.expectEqual({over: '9000!!!'}, json);
});
</script>
<script id=same-origin type=module>
const promise1 = new Promise((resolve) => {
fetch('http://localhost:9582/xhr/json')
.then((res) => {
testing.expectEqual('basic', res.type);
return res.json()
})
.then((json) => {

View File

@@ -95,7 +95,9 @@
async function async(promise, cb) {
const script_id = document.currentScript.id;
const stack = new Error().stack;
this._captured = {script_id: script_id, stack: stack};
const value = await promise;
// reset it, because await promise could change it.
this._captured = {script_id: script_id, stack: stack};
cb(value);
this._captured = null;