diff --git a/Dependencies.md b/Dependencies.md index 3fb8a7f10879..538ed648eff4 100644 --- a/Dependencies.md +++ b/Dependencies.md @@ -18,7 +18,7 @@ Through the rest of the development cycle dependencies shouldn't be updated unle The last part predominantly goes for `golang.org/x/*` and particularly `golang.org/x/net` which usually have updates through the development of Go itself. -[Goja](https://github.com/dop251/goja) has special considerations as it's heavily used and bug fixes there or new features usually have high impact on k6. Which means that we usually try to update it whenever something new lands there. +[Sobek](https://github.com/grafana/sobek) has special considerations as it's heavily used and bug fixes there or new features usually have high impact on k6. Which means that we usually try to update it whenever something new lands there. As the stability of any k6 release is pretty essential, this should be done only when adequate testing can be done, and in general, the changelog for each dependency should be consulted on what has changed. @@ -55,10 +55,10 @@ You can use the command `modtools check --direct-only` provided you, to update i Commit dependencies one by one with a message like `Update from vX.Y.Z to vX.Y.Z` and a relevant changelog for k6. Sometimes that means "nothing of relevance for k6", sometimes it means a list of bug fixes or new features. It's preferable to make multiple PRs - in most cases you can split them in three: -- update for goja - which usually needs to happen. +- update for sobek - which usually needs to happen. - update for `golang.org/x/*` - also again happen literally every release - everything else - this in general doesn't include more than 5-6 small updates. Further splitting is recommended if PRs become too big. -When updating goja it's recommended to run the tc39 tests in `js/tc39`. And if needed, update the breaking ones as explained in an [Introduction to a k6's TC39 testing](./js/tc39/README.md). +When updating sobek it's recommended to run the tc39 tests in `js/tc39`. And if needed, update the breaking ones as explained in an [Introduction to a k6's TC39 testing](./js/tc39/README.md). diff --git a/cmd/runtime_options.go b/cmd/runtime_options.go index 61e67cfdf0c6..80cd7076ca4c 100644 --- a/cmd/runtime_options.go +++ b/cmd/runtime_options.go @@ -24,7 +24,7 @@ func runtimeOptionFlagSet(includeSysEnv bool) *pflag.FlagSet { flags.Bool("include-system-env-vars", includeSysEnv, "pass the real system environment variables to the runtime") flags.String("compatibility-mode", "extended", `JavaScript compiler compatibility mode, "extended" or "base" or "experimental_enhanced" -base: pure goja - Golang JS VM supporting ES5.1+ +base: pure sobek - Golang JS VM supporting ES5.1+ extended: base + Babel with parts of ES2015 preset slower to compile in case the script uses syntax unsupported by base experimental_enhanced: esbuild-based transpiling for TypeScript and ES6+ support diff --git a/js/common/bridge.go b/js/common/bridge.go index 5535ed161fd1..6ac794b07e71 100644 --- a/js/common/bridge.go +++ b/js/common/bridge.go @@ -71,11 +71,11 @@ func MethodName(_ reflect.Type, m reflect.Method) string { type FieldNameMapper struct{} // FieldName is part of the sobek.FieldNameMapper interface -// https://godoc.org/github.com/dop251/goja#FieldNameMapper +// https://godoc.org/github.com/grafana/sobek#FieldNameMapper func (FieldNameMapper) FieldName(t reflect.Type, f reflect.StructField) string { return FieldName(t, f) } // MethodName is part of the sobek.FieldNameMapper interface -// https://godoc.org/github.com/dop251/goja#FieldNameMapper +// https://godoc.org/github.com/grafana/sobek#FieldNameMapper func (FieldNameMapper) MethodName(t reflect.Type, m reflect.Method) string { return MethodName(t, m) } diff --git a/js/common/interrupt_error.go b/js/common/interrupt_error.go index 0ed89f3239df..285b4a04b51c 100644 --- a/js/common/interrupt_error.go +++ b/js/common/interrupt_error.go @@ -8,9 +8,9 @@ import ( // UnwrapGojaInterruptedError returns the internal error handled by sobek. func UnwrapGojaInterruptedError(err error) error { - var gojaErr *sobek.InterruptedError - if errors.As(err, &gojaErr) { - if e, ok := gojaErr.Value().(error); ok { + var sobekErr *sobek.InterruptedError + if errors.As(err, &sobekErr) { + if e, ok := sobekErr.Value().(error); ok { return e } } diff --git a/js/common/randsource.go b/js/common/randsource.go index 141e547071a9..904f006567b0 100644 --- a/js/common/randsource.go +++ b/js/common/randsource.go @@ -9,8 +9,8 @@ import ( "github.com/grafana/sobek" ) -// NewRandSource is copied from goja's source code: -// https://github.com/dop251/goja/blob/master/goja/main.go#L44 +// NewRandSource is copied from sobek's source code: +// https://github.com/grafana/sobek/blob/master/sobek/main.go#L44 // The returned RandSource is NOT safe for concurrent use: // https://golang.org/pkg/math/rand/#NewSource func NewRandSource() sobek.RandSource { diff --git a/js/common/util.go b/js/common/util.go index 94e8cff0387e..807651cfb442 100644 --- a/js/common/util.go +++ b/js/common/util.go @@ -17,7 +17,7 @@ func Throw(rt *sobek.Runtime, err error) { panic(rt.NewGoError(err)) // this catches the stack unlike rt.ToValue } -// GetReader tries to return an io.Reader value from an exported goja value. +// GetReader tries to return an io.Reader value from an exported sobek value. func GetReader(data interface{}) (io.Reader, error) { switch r := data.(type) { case string: diff --git a/js/compiler/compiler.go b/js/compiler/compiler.go index 40ab043c4bbf..d428d6244c86 100644 --- a/js/compiler/compiler.go +++ b/js/compiler/compiler.go @@ -30,26 +30,26 @@ var ( // "presets": []string{"latest"}, "plugins": []interface{}{ // es2015 https://github.com/babel/babel/blob/v6.26.0/packages/babel-preset-es2015/src/index.js - // in goja + // in sobek // []interface{}{"transform-es2015-template-literals", map[string]interface{}{"loose": false, "spec": false}}, - // "transform-es2015-literals", // in goja - // "transform-es2015-function-name", // in goja - // []interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}}, // in goja - // "transform-es2015-block-scoped-functions", // in goja - // []interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-object-super", // in goja - // "transform-es2015-shorthand-properties", // in goja - // "transform-es2015-duplicate-keys", // in goja - // []interface{}{"transform-es2015-computed-properties", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-for-of", // in goja - // "transform-es2015-sticky-regex", // in goja - // "transform-es2015-unicode-regex", // in goja - // "check-es2015-constants", // in goja - // []interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-parameters", // in goja - // []interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}}, // in goja - // "transform-es2015-block-scoping", // in goja - // "transform-es2015-typeof-symbol", // in goja + // "transform-es2015-literals", // in sobek + // "transform-es2015-function-name", // in sobek + // []interface{}{"transform-es2015-arrow-functions", map[string]interface{}{"spec": false}}, // in sobek + // "transform-es2015-block-scoped-functions", // in sobek + // []interface{}{"transform-es2015-classes", map[string]interface{}{"loose": false}}, // in sobek + // "transform-es2015-object-super", // in sobek + // "transform-es2015-shorthand-properties", // in sobek + // "transform-es2015-duplicate-keys", // in sobek + // []interface{}{"transform-es2015-computed-properties", map[string]interface{}{"loose": false}}, // in sobek + // "transform-es2015-for-of", // in sobek + // "transform-es2015-sticky-regex", // in sobek + // "transform-es2015-unicode-regex", // in sobek + // "check-es2015-constants", // in sobek + // []interface{}{"transform-es2015-spread", map[string]interface{}{"loose": false}}, // in sobek + // "transform-es2015-parameters", // in sobek + // []interface{}{"transform-es2015-destructuring", map[string]interface{}{"loose": false}}, // in sobek + // "transform-es2015-block-scoping", // in sobek + // "transform-es2015-typeof-symbol", // in sobek // all the other module plugins are just dropped []interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}}, // "transform-regenerator", // Doesn't really work unless regeneratorRuntime is also added @@ -58,7 +58,7 @@ var ( // "transform-exponentiation-operator", // es2017 https://github.com/babel/babel/blob/v6.26.0/packages/babel-preset-es2017/src/index.js - // "syntax-trailing-function-commas", // in goja + // "syntax-trailing-function-commas", // in sobek // "transform-async-to-generator", // Doesn't really work unless regeneratorRuntime is also added }, "ast": false, @@ -172,12 +172,12 @@ type compilationState struct { } // Compile the program in the given CompatibilityMode, wrapping it between pre and post code -// TODO isESM will be used once goja support ESM modules natively +// TODO isESM will be used once sobek support ESM modules natively func (c *Compiler) Compile(src, filename string, isESM bool) (*sobek.Program, string, error) { return c.compileImpl(src, filename, !isESM, c.Options.CompatibilityMode, nil) } -// sourceMapLoader is to be used with goja's WithSourceMapLoader +// sourceMapLoader is to be used with sobek's WithSourceMapLoader // it not only gets the file from disk in the simple case, but also returns it if the map was generated from babel // additioanlly it fixes off by one error in commonjs dependencies due to having to wrap them in a function. func (c *compilationState) sourceMapLoader(path string) ([]byte, error) { @@ -396,7 +396,7 @@ func (b *babel) transformImpl( return code, nil, nil } - // this is to make goja try to load a sourcemap. + // this is to make sobek try to load a sourcemap. // it is a special url as it should never leak outside of this code // additionally the alternative support from babel is to embed *the whole* sourcemap at the end code += "\n//# sourceMappingURL=" + sourceMapURLFromBabel diff --git a/js/eventloop/eventloop.go b/js/eventloop/eventloop.go index 09a11cf60e58..6dd2fdaa5f0f 100644 --- a/js/eventloop/eventloop.go +++ b/js/eventloop/eventloop.go @@ -108,7 +108,7 @@ func (e *EventLoop) wakeup() { // This ensures that the actual work happens asynchronously, while the Promise // is immediately returned and the main thread resumes execution. It also // ensures that the Promise resolution happens safely back on the main thread -// once the async work is done, as required by goja and all other JS runtimes. +// once the async work is done, as required by sobek and all other JS runtimes. // // TODO: rename to ReservePendingCallback or something more appropriate? func (e *EventLoop) RegisterCallback() (enqueueCallback func(func() error)) { @@ -132,7 +132,7 @@ func (e *EventLoop) RegisterCallback() (enqueueCallback func(func() error)) { } func (e *EventLoop) promiseRejectionTracker(p *sobek.Promise, op sobek.PromiseRejectionOperation) { - // No locking necessary here as the goja runtime will call this synchronously + // No locking necessary here as the sobek runtime will call this synchronously // Read Notes on https://tc39.es/ecma262/#sec-host-promise-rejection-tracker if op == sobek.PromiseRejectionReject { e.pendingPromiseRejections[p] = struct{}{} diff --git a/js/modules/k6/data/data.go b/js/modules/k6/data/data.go index 9e5ad78fa8b8..a67f1a9c7bab 100644 --- a/js/modules/k6/data/data.go +++ b/js/modules/k6/data/data.go @@ -111,11 +111,11 @@ func (s *sharedArrays) get(rt *sobek.Runtime, name string, call sobek.Callable) } func getShareArrayFromCall(rt *sobek.Runtime, call sobek.Callable) sharedArray { - gojaValue, err := call(sobek.Undefined()) + sobekValue, err := call(sobek.Undefined()) if err != nil { common.Throw(rt, err) } - obj := gojaValue.ToObject(rt) + obj := sobekValue.ToObject(rt) if obj.ClassName() != "Array" { common.Throw(rt, errors.New("only arrays can be made into SharedArray")) // TODO better error } diff --git a/js/modules/k6/execution/execution.go b/js/modules/k6/execution/execution.go index 6393b1d9c2fc..2f2cb78dea22 100644 --- a/js/modules/k6/execution/execution.go +++ b/js/modules/k6/execution/execution.go @@ -353,7 +353,7 @@ func (o *tagsDynamicObject) Get(key string) sobek.Value { } // Set a property value for the key. It returns true if succeed. String, Boolean -// and Number types are implicitly converted to the goja's relative string +// and Number types are implicitly converted to the sobek's relative string // representation. An exception is raised in case a denied type is provided. func (o *tagsDynamicObject) Set(key string, val sobek.Value) bool { o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) { @@ -410,7 +410,7 @@ func (o *metadataDynamicObject) Get(key string) sobek.Value { } // Set a property value for the key. It returns true if successful. String, Boolean -// and Number types are implicitly converted to the goja's relative string +// and Number types are implicitly converted to the sobek's relative string // representation. An exception is raised in case a denied type is provided. func (o *metadataDynamicObject) Set(key string, val sobek.Value) bool { o.state.Tags.Modify(func(tagsAndMeta *metrics.TagsAndMeta) { diff --git a/js/modules/k6/experimental/streams/goja.go b/js/modules/k6/experimental/streams/goja.go index e9b3a04e75af..06f45868bc0e 100644 --- a/js/modules/k6/experimental/streams/goja.go +++ b/js/modules/k6/experimental/streams/goja.go @@ -59,7 +59,7 @@ func promiseThen( return newPromise, nil } -// isNumber returns true if the given goja value holds a number +// isNumber returns true if the given sobek value holds a number func isNumber(value sobek.Value) bool { _, isFloat := value.Export().(float64) _, isInt := value.Export().(int64) diff --git a/js/modules/k6/experimental/streams/tests/checkout.sh b/js/modules/k6/experimental/streams/tests/checkout.sh index df42ab66ff57..87dffec01e08 100755 --- a/js/modules/k6/experimental/streams/tests/checkout.sh +++ b/js/modules/k6/experimental/streams/tests/checkout.sh @@ -13,7 +13,7 @@ git sparse-checkout set resources streams git fetch origin --depth=1 "${sha}" git checkout ${sha} -# Apply custom patches needed to run the tests in k6/goja +# Apply custom patches needed to run the tests in k6/sobek for patch in ../*.patch do git apply "$patch" diff --git a/js/modules/k6/grpc/client.go b/js/modules/k6/grpc/client.go index 2ff52484dc65..d77d1e7e136d 100644 --- a/js/modules/k6/grpc/client.go +++ b/js/modules/k6/grpc/client.go @@ -385,7 +385,7 @@ func (c *Client) Close() error { return err } -// MethodInfo holds information on any parsed method descriptors that can be used by the goja VM +// MethodInfo holds information on any parsed method descriptors that can be used by the sobek VM type MethodInfo struct { Package string Service string diff --git a/js/modules/k6/grpc/listeners.go b/js/modules/k6/grpc/listeners.go index c1bd336e42a4..00ebb3b63fca 100644 --- a/js/modules/k6/grpc/listeners.go +++ b/js/modules/k6/grpc/listeners.go @@ -26,7 +26,7 @@ type eventListener struct { eventType string // this return sobek.value *and* error in order to return error on exception instead of panic - // https://pkg.go.dev/github.com/dop251/goja#hdr-Functions + // https://pkg.go.dev/github.com/grafana/sobek#hdr-Functions list []func(sobek.Value) (sobek.Value, error) } diff --git a/js/modules/k6/grpc/params_test.go b/js/modules/k6/grpc/params_test.go index 62929a98054a..7bf93ee3d76a 100644 --- a/js/modules/k6/grpc/params_test.go +++ b/js/modules/k6/grpc/params_test.go @@ -142,7 +142,7 @@ func TestCallParamsTimeOutParse(t *testing.T) { // newParamsTestRuntime creates a new test runtime // that could be used to test the params // it also moves to the VU context and creates the params -// goja value that could be used in the tests +// sobek value that could be used in the tests func newParamsTestRuntime(t *testing.T, paramsJSON string) (*modulestest.Runtime, sobek.Value) { t.Helper() diff --git a/js/modules/k6/html/html.go b/js/modules/k6/html/html.go index 4630c1db0651..8d2c3c2dbc2e 100644 --- a/js/modules/k6/html/html.go +++ b/js/modules/k6/html/html.go @@ -79,9 +79,9 @@ func (s Selection) emptySelection() Selection { return s.Eq(s.Size()) } -func (s Selection) buildMatcher(v sobek.Value, gojaFn sobek.Callable) func(int, *goquery.Selection) bool { +func (s Selection) buildMatcher(v sobek.Value, sobekFn sobek.Callable) func(int, *goquery.Selection) bool { return func(idx int, sel *goquery.Selection) bool { - fnRes, fnErr := gojaFn(v, s.rt.ToValue(idx), s.rt.ToValue(sel)) + fnRes, fnErr := sobekFn(v, s.rt.ToValue(idx), s.rt.ToValue(sel)) if fnErr != nil { common.Throw(s.rt, fnErr) } @@ -181,12 +181,12 @@ func (s Selection) Has(arg interface{}) Selection { } func (s Selection) Not(v sobek.Value) Selection { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { return s.varargFnCall(v, s.sel.Not, s.sel.NotSelection, s.sel.NotNodes) } - return Selection{s.rt, s.sel.NotFunction(s.buildMatcher(v, gojaFn)), s.URL} + return Selection{s.rt, s.sel.NotFunction(s.buildMatcher(v, sobekFn)), s.URL} } func (s Selection) Next(def ...string) Selection { @@ -357,13 +357,13 @@ func (s Selection) Children(def ...string) Selection { } func (s Selection) Each(v sobek.Value) Selection { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to each() must be a function")) } fn := func(idx int, _ *goquery.Selection) { - if _, err := gojaFn(v, s.rt.ToValue(idx), selToElement(Selection{s.rt, s.sel.Eq(idx), s.URL})); err != nil { + if _, err := sobekFn(v, s.rt.ToValue(idx), selToElement(Selection{s.rt, s.sel.Eq(idx), s.URL})); err != nil { common.Throw(s.rt, fmt.Errorf("the function passed to each() failed: %w", err)) } } @@ -380,12 +380,12 @@ func (s Selection) Filter(v sobek.Value) Selection { return Selection{s.rt, s.sel.FilterSelection(val.sel), s.URL} } - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to filter() must be a function, a selector or a selection")) } - return Selection{s.rt, s.sel.FilterFunction(s.buildMatcher(v, gojaFn)), s.URL} + return Selection{s.rt, s.sel.FilterFunction(s.buildMatcher(v, sobekFn)), s.URL} } func (s Selection) Is(v sobek.Value) bool { @@ -397,18 +397,18 @@ func (s Selection) Is(v sobek.Value) bool { return s.sel.IsSelection(val.sel) default: - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to is() must be a function, a selector or a selection")) } - return s.sel.IsFunction(s.buildMatcher(v, gojaFn)) + return s.sel.IsFunction(s.buildMatcher(v, sobekFn)) } } // Map implements ES5 Array.prototype.map func (s Selection) Map(v sobek.Value) []sobek.Value { - gojaFn, isFn := sobek.AssertFunction(v) + sobekFn, isFn := sobek.AssertFunction(v) if !isFn { common.Throw(s.rt, errors.New("the argument to map() must be a function")) } @@ -417,7 +417,7 @@ func (s Selection) Map(v sobek.Value) []sobek.Value { s.sel.Each(func(idx int, sel *goquery.Selection) { selection := &Selection{sel: sel, URL: s.URL, rt: s.rt} - if fnRes, fnErr := gojaFn(v, s.rt.ToValue(idx), s.rt.ToValue(selection)); fnErr == nil { + if fnRes, fnErr := sobekFn(v, s.rt.ToValue(idx), s.rt.ToValue(selection)); fnErr == nil { values = append(values, fnRes) } }) diff --git a/js/modules/k6/http/cookiejar.go b/js/modules/k6/http/cookiejar.go index 4a68fbb2e875..183e4d7f0737 100644 --- a/js/modules/k6/http/cookiejar.go +++ b/js/modules/k6/http/cookiejar.go @@ -20,7 +20,7 @@ var ErrJarForbiddenInInitContext = common.NewInitContextError("Making cookie jar // CookieJar is cookiejar.Jar wrapper to be used in js scripts type CookieJar struct { moduleInstance *ModuleInstance - // js is to make it not be accessible from inside goja/js, the json is + // js is to make it not be accessible from inside sobek/js, the json is // for when it is returned from setup(). Jar *cookiejar.Jar `js:"-" json:"-"` } diff --git a/js/modules/k6/http/response.go b/js/modules/k6/http/response.go index 38d291c872e3..a9e7cc4eefe2 100644 --- a/js/modules/k6/http/response.go +++ b/js/modules/k6/http/response.go @@ -16,7 +16,7 @@ import ( "go.k6.io/k6/lib/netext/httpext" ) -// Response is a representation of an HTTP response to be returned to the goja VM +// Response is a representation of an HTTP response to be returned to the sobek VM type Response struct { *httpext.Response `js:"-"` client *Client @@ -61,7 +61,7 @@ func (res *Response) HTML(selector ...string) html.Selection { return sel } -// JSON parses the body of a response as JSON and returns it to the goja VM. +// JSON parses the body of a response as JSON and returns it to the sobek VM. func (res *Response) JSON(selector ...string) sobek.Value { rt := res.client.moduleInstance.vu.Runtime() diff --git a/js/modules/k6/timers/timers.go b/js/modules/k6/timers/timers.go index 0c1879b90ae4..abac45b5f7a3 100644 --- a/js/modules/k6/timers/timers.go +++ b/js/modules/k6/timers/timers.go @@ -64,7 +64,7 @@ func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance { func (e *Timers) Exports() modules.Exports { return modules.Exports{ Named: map[string]interface{}{ - // TODO the usage of `ToValue` here is so that goja doesn't do it automatically later + // TODO the usage of `ToValue` here is so that sobek doesn't do it automatically later // which will effectively create new instance each time it is accessed. "setTimeout": e.vu.Runtime().ToValue(e.setTimeout), "clearTimeout": e.vu.Runtime().ToValue(e.clearTimeout), diff --git a/js/modules/require_impl.go b/js/modules/require_impl.go index f7236195c033..d3fa70e0d79d 100644 --- a/js/modules/require_impl.go +++ b/js/modules/require_impl.go @@ -43,7 +43,7 @@ func (r *LegacyRequireImpl) Require(specifier string) (*sobek.Object, error) { // // With native ESM this won't even be possible as `require` might not be called - instead an import // might be used in which case we won't be able to be doing this hack. In that case we either will - // need some goja specific helper or to use stack traces as goja_nodejs does. + // need some sobek specific helper or to use stack traces. currentPWD := r.currentlyRequiredModule if specifier != "k6" && !strings.HasPrefix(specifier, "k6/") { defer func() { diff --git a/js/promises/promises.go b/js/promises/promises.go index 89cc463a4443..0fea944fb120 100644 --- a/js/promises/promises.go +++ b/js/promises/promises.go @@ -8,7 +8,7 @@ import ( // New can be used to create promises that will be dispatched to k6's event loop. // -// Calling the function will create a goja promise and return its `resolve` and `reject` callbacks, wrapped +// Calling the function will create a sobek promise and return its `resolve` and `reject` callbacks, wrapped // in such a way that it will block the k6 JavaScript runtime's event loop from exiting before they are // called, even if the promise isn't resolved by the time the current script ends executing. // diff --git a/js/runner.go b/js/runner.go index 64c116094b7f..2433568a8801 100644 --- a/js/runner.go +++ b/js/runner.go @@ -566,12 +566,12 @@ func (r *Runner) runPart( } //nolint:gochecknoglobals -var gojaPromiseType = reflect.TypeOf((*sobek.Promise)(nil)) +var sobekPromiseType = reflect.TypeOf((*sobek.Promise)(nil)) // unPromisify gets the result of v if it is a promise, otherwise returns v func unPromisify(v sobek.Value) sobek.Value { if !common.IsNullish(v) { - if v.ExportType() == gojaPromiseType { + if v.ExportType() == sobekPromiseType { p, ok := v.Export().(*sobek.Promise) if !ok { panic("Something that was promise did not export to a promise; this shouldn't happen") @@ -757,7 +757,7 @@ func (u *ActiveVU) RunOnce() error { u.incrIteration() if err := u.Runtime.Set("__ITER", u.iteration); err != nil { - panic(fmt.Errorf("error setting __ITER in goja runtime: %w", err)) + panic(fmt.Errorf("error setting __ITER in sobek runtime: %w", err)) } ctx, cancel := context.WithCancel(u.RunContext) diff --git a/js/tc39/README.md b/js/tc39/README.md index cc1dbc21979c..1bb8f92f8ac9 100644 --- a/js/tc39/README.md +++ b/js/tc39/README.md @@ -1,6 +1,6 @@ # Introduction to a k6's TC39 testing -The point of this module is to test k6 goja+babel and k6 goja+esbuild combo against the tc39 test suite. +The point of this module is to test k6 sobek+babel and k6 sobek+esbuild combo against the tc39 test suite. Ways to use it: 1. run ./checkout.sh to checkout the last commit sha of [test262](https://github.com/tc39/test262) @@ -8,13 +8,13 @@ Ways to use it: 2. Run `go test &> out.log` The full list of failing tests, and the error, is in `breaking_test_errors-*.json`. All errors list there with the corresponding error will *not* be counted as errors - this is what the test expects, those specific errors. -Due to changes to goja it is not uncommon for the error to change, or there to be now a new error on previously passing test, or (hopefully) a test that was not passing but now is. +Due to changes to soben it is not uncommon for the error to change, or there to be now a new error on previously passing test, or (hopefully) a test that was not passing but now is. In all of those cases `breaking_test_errors-*.json` needs to be updated. Run the test with `-update` flag to update: `go test -update` NOTE: some text editors/IDEs will try to parse files ending in `json` as JSON, which given the size of `breaking_test_errors-*.json` might be a problem when it's not actually a JSON (before the edit). So it might be a better idea to name it something different if editing by hand and fix it later. -This is a modified version of [the code in the goja -repo](https://github.com/dop251/goja/blob/master/tc39_test.go) +This is a modified version of [the code in the original goja +repo](https://github.com/dop251/goja/blob/master/tc39_test.go) that sobek was forked from. ## Reasons for recording breaking_test_errors.json diff --git a/js/tc39/tc39_test.go b/js/tc39/tc39_test.go index a51349037223..5fa37e98b550 100644 --- a/js/tc39/tc39_test.go +++ b/js/tc39/tc39_test.go @@ -60,7 +60,7 @@ var ( "top-level-await", // not supported at all "String.prototype.replaceAll", // not supported at all, Stage 4 since 2020 - // from goja + // from sobek "Symbol.asyncIterator", "regexp-named-groups", "regexp-dotall", diff --git a/lib/netext/grpcext/conn.go b/lib/netext/grpcext/conn.go index 89fdcba763f5..ef932cb41a13 100644 --- a/lib/netext/grpcext/conn.go +++ b/lib/netext/grpcext/conn.go @@ -151,7 +151,7 @@ func (c *Conn) Invoke( sterr := status.Convert(err) response.Status = sterr.Code() - // (rogchap) when you access a JSON property in goja, you are actually accessing the underling + // (rogchap) when you access a JSON property in sobek, you are actually accessing the underling // Go type (struct, map, slice etc); because these are dynamic messages the Unmarshaled JSON does // not map back to a "real" field or value (as a normal Go type would). If we don't marshal and then // unmarshal back to a map, you will get "undefined" when accessing JSON properties, even when diff --git a/lib/netext/httpext/compression.go b/lib/netext/httpext/compression.go index 6716fb4ad5ee..42ae6e273a3a 100644 --- a/lib/netext/httpext/compression.go +++ b/lib/netext/httpext/compression.go @@ -182,7 +182,7 @@ func readResponseBody( // Copy the data to a new slice before we return the buffer to the pool, // because buf.Bytes() points to the underlying buffer byte slice. // The ArrayBuffer wrapping will be done in the js/modules/k6/http - // package to avoid a reverse dependency, since it depends on goja. + // package to avoid a reverse dependency, since it depends on sobek. binData := make([]byte, buf.Len()) copy(binData, buf.Bytes()) result = binData diff --git a/lib/runtime_options.go b/lib/runtime_options.go index d7f95b0bebd1..772f1bf83df5 100644 --- a/lib/runtime_options.go +++ b/lib/runtime_options.go @@ -15,13 +15,13 @@ type CompatibilityMode uint8 const ( // CompatibilityModeExtended achieves ES6+ compatibility with Babel CompatibilityModeExtended CompatibilityMode = iota + 1 - // CompatibilityModeBase is standard goja ES5.1+ + // CompatibilityModeBase is standard sobek ES5.1+ CompatibilityModeBase // CompatibilityModeExperimentalEnhanced achieves TypeScript and ES6+ compatibility with esbuild CompatibilityModeExperimentalEnhanced ) -// RuntimeOptions are settings passed onto the goja JS runtime +// RuntimeOptions are settings passed onto the sobek JS runtime type RuntimeOptions struct { TestType null.String `json:"-"`