Skip to content

Commit

Permalink
Refactor clearCookies to return error
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Aug 23, 2023
1 parent 9552502 commit 2d61d40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/browser_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type BrowserContext interface {
AddCookies(cookies goja.Value) error
AddInitScript(script goja.Value, arg goja.Value) error
Browser() Browser
ClearCookies()
ClearCookies() error
ClearPermissions()
Close()
Cookies() ([]any, error) // TODO: make it []Cookie later on
Expand Down
5 changes: 3 additions & 2 deletions common/browser_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,16 @@ func (b *BrowserContext) AddCookies(cookies goja.Value) error {
}

// ClearCookies clears cookies.
func (b *BrowserContext) ClearCookies() {
func (b *BrowserContext) ClearCookies() error {
b.logger.Debugf("BrowserContext:ClearCookies", "bctxid:%v", b.id)

clearCookies := storage.
ClearCookies().
WithBrowserContextID(b.id)
if err := clearCookies.Do(b.ctx); err != nil {
k6ext.Panic(b.ctx, "clearing cookies: %w", err)
return fmt.Errorf("clearing cookies: %w", err)
}
return nil
}

// Cookies is not implemented.
Expand Down

0 comments on commit 2d61d40

Please sign in to comment.