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

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: İnanç Gümüş <[email protected]>
  • Loading branch information
ankur22 and inancgumus committed Oct 19, 2023
1 parent 74822b1 commit df6fc1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions common/browser_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (b *BrowserContext) ExposeFunction(name string, callback goja.Callable) {
}

// GrantPermissions enables the specified permissions, all others will be disabled.
func (b *BrowserContext) GrantPermissions(permissions []string, parsedOpts *GrantPermissionsOptions) error {
func (b *BrowserContext) GrantPermissions(permissions []string, opts *GrantPermissionsOptions) error {
b.logger.Debugf("BrowserContext:GrantPermissions", "bctxid:%v", b.id)

permsToProtocol := map[string]cdpbrowser.PermissionType{
Expand Down Expand Up @@ -247,9 +247,9 @@ func (b *BrowserContext) GrantPermissions(permissions []string, parsedOpts *Gran
perms = append(perms, proto)
}

action := cdpbrowser.GrantPermissions(perms).WithOrigin(parsedOpts.Origin).WithBrowserContextID(b.id)
action := cdpbrowser.GrantPermissions(perms).WithOrigin(opts.Origin).WithBrowserContextID(b.id)
if err := action.Do(cdp.WithExecutor(b.ctx, b.browser.conn)); err != nil {
return fmt.Errorf("error granting browser permissions: %w", err)
return fmt.Errorf("granting browser permissions: %w", err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions common/browser_context_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ type GrantPermissionsOptions struct {
Origin string
}

// NewGrantPermissionsOptions creates a new instance of GrantPermissionsOptions.
// NewGrantPermissionsOptions returns a new GrantPermissionsOptions.
func NewGrantPermissionsOptions() *GrantPermissionsOptions {
return &GrantPermissionsOptions{}
}

// Parse will parse the options. It can parse origin out of the supplied object.
// Parse parses the options from opts if opts exists in the Goja runtime.
func (g *GrantPermissionsOptions) Parse(ctx context.Context, opts goja.Value) {
rt := k6ext.Runtime(ctx)

Expand Down

0 comments on commit df6fc1c

Please sign in to comment.