Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove k6/experimental/browser #4161

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/tests/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2330,11 +2330,10 @@ func TestBrowserExperimentalImport(t *testing.T) {
}

export default function() {
browser.isConnected()
};
`

const wantExitCode = 108
const wantExitCode = 107
ts := getSingleFileTestState(t, script, []string{}, wantExitCode)
ts.Env["K6_BROWSER_EXECUTABLE_PATH"] = "k6-browser-fake-cmd"
cmd.ExecuteWithGlobalState(ts.GlobalState)
Expand Down
11 changes: 7 additions & 4 deletions js/jsmodules.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func getInternalJSModules() map[string]interface{} {
"k6/experimental/tracing has been removed. All of it functionality is available as pure javascript module." +
" More info available at the docs:" +
" https://grafana.com/docs/k6/latest/javascript-api/jslib/http-instrumentation-tempo"),
"k6/experimental/browser": newWarnExperimentalModule(browser.NewSync(),
"Please update your imports to use k6/browser instead of k6/experimental/browser,"+
" which will be removed after September 23rd, 2024 (v0.54.0). Ensure your scripts are migrated by then."+
" For more information, see the migration guide at the link:"+
"k6/experimental/browser": newRemovedModule(
"k6/experimental/browser has been graduated, please use k6/browser instead." +
"Please update your imports to use k6/browser instead of k6/experimental/browser," +
" For more information, see the migration guide at the link:" +
" https://grafana.com/docs/k6/latest/using-k6-browser/migrating-to-k6-v0-52/"),
"k6/browser": browser.New(),
"k6/experimental/fs": fs.New(),
Expand Down Expand Up @@ -80,12 +80,14 @@ func getJSModules() map[string]interface{} {
return result
}

//nolint:unused // this is likely going to be used again even if isn't currently used
type warnExperimentalModule struct {
once *sync.Once
msg string
base modules.Module
}

//nolint:unused // this is likely going to be used again even if isn't currently used
func newWarnExperimentalModule(base modules.Module, msg string) modules.Module {
return &warnExperimentalModule{
msg: msg,
Expand All @@ -94,6 +96,7 @@ func newWarnExperimentalModule(base modules.Module, msg string) modules.Module {
}
}

//nolint:unused // this is likely going to be used again even if isn't currently used
func (w *warnExperimentalModule) NewModuleInstance(vu modules.VU) modules.Instance {
w.once.Do(func() { vu.InitEnv().Logger.Warn(w.msg) })
return w.base.NewModuleInstance(vu)
Expand Down
21 changes: 1 addition & 20 deletions js/modules/k6/browser/browser/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type (
tracesMetadata map[string]string
filePersister filePersister
testRunID string
isSync bool // remove later
}

// JSModule exposes the properties available to the JS script.
Expand Down Expand Up @@ -68,17 +67,6 @@ func New() *RootModule {
}
}

// NewSync returns a pointer to a new RootModule instance that maps the
// browser's business logic to the synchronous version of the module's
// JS API.
func NewSync() *RootModule {
return &RootModule{
PidRegistry: &pidRegistry{},
initOnce: &sync.Once{},
isSync: true,
}
}

// NewModuleInstance implements the k6modules.Module interface to return
// a new instance for each VU.
func (m *RootModule) NewModuleInstance(vu k6modules.VU) k6modules.Instance {
Expand All @@ -91,16 +79,9 @@ func (m *RootModule) NewModuleInstance(vu k6modules.VU) k6modules.Instance {
m.initialize(vu)
})

// decide whether to map the browser module to the async JS API or
// the sync one.
mapper := mapBrowserToSobek
if m.isSync {
mapper = syncMapBrowserToSobek
}

return &ModuleInstance{
mod: &JSModule{
Browser: mapper(moduleVU{
Browser: mapBrowserToSobek(moduleVU{
VU: vu,
pidRegistry: m.PidRegistry,
browserRegistry: newBrowserRegistry(
Expand Down
131 changes: 0 additions & 131 deletions js/modules/k6/browser/browser/sync_browser_context_mapping.go

This file was deleted.

93 changes: 0 additions & 93 deletions js/modules/k6/browser/browser/sync_browser_mapping.go

This file was deleted.

31 changes: 0 additions & 31 deletions js/modules/k6/browser/browser/sync_console_message_mapping.go

This file was deleted.

Loading
Loading