mirror of
https://github.com/golang/go
synced 2024-11-21 16:54:46 -07:00
add
This commit is contained in:
parent
fb4bdb64e0
commit
140640b414
@ -21,6 +21,16 @@ globalThis.crypto ??= require("crypto");
|
||||
|
||||
require("./wasm_exec");
|
||||
|
||||
// Disable fetch API in tests so that
|
||||
// RoundTrip ends up talking over the same fake
|
||||
// network the HTTP servers currently use in
|
||||
// various tests and examples.
|
||||
// See net/http/roundtrip_js.go.
|
||||
// See go.dev/issue/57613.
|
||||
if (process.argv[2].endsWith(".test")) {
|
||||
globalThis["JSFetchDisabledInTest"] = true;
|
||||
}
|
||||
|
||||
const go = new Go();
|
||||
go.argv = process.argv.slice(2);
|
||||
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"net/http/internal/ascii"
|
||||
"strconv"
|
||||
"syscall/js"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var uint8Array = js.Global().Get("Uint8Array")
|
||||
@ -47,13 +46,13 @@ const jsFetchRedirect = "js.fetch:redirect"
|
||||
var jsFetchMissing = js.Global().Get("fetch").IsUndefined()
|
||||
|
||||
// jsFetchDisabled controls whether the use of Fetch API is disabled.
|
||||
// It's set to true when we detect we're running in Node.js, so that
|
||||
// It's set to true when we detect we're running in test, so that
|
||||
// RoundTrip ends up talking over the same fake network the HTTP servers
|
||||
// currently use in various tests and examples. See go.dev/issue/57613.
|
||||
//
|
||||
// TODO(go.dev/issue/60810): See if it's viable to test the Fetch API
|
||||
// code path.
|
||||
var jsFetchDisabled = testing.Testing()
|
||||
var jsFetchDisabled = !js.Global().Get("JSFetchDisabledInTest").IsUndefined()
|
||||
|
||||
// RoundTrip implements the [RoundTripper] interface using the WHATWG Fetch API.
|
||||
func (t *Transport) RoundTrip(req *Request) (*Response, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user