Skip to content

Commit

Permalink
Async browser.closeContext
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed May 8, 2024
1 parent 81b9e7d commit 7a82924
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit 7a82924

Please sign in to comment.