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

Async browser.closeContext #1311

Merged
merged 1 commit into from
May 8, 2024
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
14 changes: 8 additions & 6 deletions browser/browser_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ func mapBrowser(vu moduleVU) mapping { //nolint:funlen,cyclop
}
return mapBrowserContext(vu, b.Context()), nil
},
"closeContext": func() error {
b, err := vu.browser()
if err != nil {
return err
}
return b.CloseContext() //nolint:wrapcheck
"closeContext": func() *goja.Promise {
return k6ext.Promise(vu.Context(), func() (any, error) {
b, err := vu.browser()
if err != nil {
return nil, err
}
return nil, b.CloseContext() //nolint:wrapcheck
})
},
"isConnected": func() (bool, error) {
b, err := vu.browser()
Expand Down
2 changes: 1 addition & 1 deletion tests/browser_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func TestK6Object(t *testing.T) {
// Now test with browser.newContext
got, err = vu.TestRT.RunOnEventLoop(`
const test = async function() {
browser.closeContext();
await browser.closeContext();
const c = await browser.newContext();
const p2 = c.newPage();
p2.goto("about:blank");
Expand Down
Loading