Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 4d17e22

Browse files
committed
Add onCloud input param to NewLaunchOptions
The param will determine how to parse the launch options. Some options will be ignored when running in the cloud.
1 parent cd3d01f commit 4d17e22

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

chromium/browser_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (b *BrowserType) Launch(opts goja.Value) api.Browser {
132132
k6ext.Panic(ctx, "setting up logger: %w", err)
133133
}
134134

135-
launchOpts := common.NewLaunchOptions()
135+
launchOpts := common.NewLaunchOptions(false)
136136
if err := launchOpts.Parse(ctx, opts, b.logger); err != nil {
137137
k6ext.Panic(ctx, "parsing launch options: %w", err)
138138
}

common/browser_options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ type LaunchPersistentContextOptions struct {
4444
}
4545

4646
// NewLaunchOptions returns a new LaunchOptions.
47-
func NewLaunchOptions() *LaunchOptions {
47+
func NewLaunchOptions(onCloud bool) *LaunchOptions {
4848
return &LaunchOptions{
4949
Env: make(map[string]string),
5050
Headless: true,
5151
LogCategoryFilter: ".*",
5252
Timeout: DefaultTimeout,
53+
onCloud: onCloud,
5354
}
5455
}
5556

common/browser_options_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func TestBrowserLaunchOptionsParse(t *testing.T) {
212212
t.Parallel()
213213
var (
214214
vu = k6test.NewVU(t)
215-
lo = NewLaunchOptions()
215+
lo = NewLaunchOptions(false)
216216
)
217217
err := lo.Parse(vu.Context(), vu.ToGojaValue(tt.opts), log.NewNullLogger())
218218
if tt.err != "" {

common/browser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestBrowserNewPageInContext(t *testing.T) {
2424
newTestCase := func(id cdp.BrowserContextID) *testCase {
2525
ctx, cancel := context.WithCancel(context.Background())
2626
logger := log.NewNullLogger()
27-
b := newBrowser(ctx, cancel, nil, NewLaunchOptions(), logger)
27+
b := newBrowser(ctx, cancel, nil, NewLaunchOptions(false), logger)
2828
// set a new browser context in the browser with `id`, so that newPageInContext can find it.
2929
b.contexts[id] = NewBrowserContext(ctx, b, id, nil, nil)
3030
return &testCase{

0 commit comments

Comments
 (0)