-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is to enable us to still work with the sync keyboard APIs with the Sobek changes removed from the business logic side of keyboard.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package browser | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/grafana/sobek" | ||
|
||
"github.com/grafana/xk6-browser/common" | ||
) | ||
|
||
func syncMapKeyboard(vu moduleVU, kb *common.Keyboard) mapping { | ||
return mapping{ | ||
"down": kb.Down, | ||
"up": kb.Up, | ||
"press": func(key string, opts sobek.Value) error { | ||
kbdOpts := common.NewKeyboardOptions() | ||
if err := kbdOpts.Parse(vu.Context(), opts); err != nil { | ||
return fmt.Errorf("parsing keyboard options: %w", err) | ||
} | ||
|
||
return kb.Press(key, kbdOpts) //nolint:wrapcheck | ||
}, | ||
"type": func(text string, opts sobek.Value) error { | ||
kbdOpts := common.NewKeyboardOptions() | ||
if err := kbdOpts.Parse(vu.Context(), opts); err != nil { | ||
return fmt.Errorf("parsing keyboard options: %w", err) | ||
} | ||
|
||
return kb.Type(text, kbdOpts) //nolint:wrapcheck | ||
}, | ||
"insertText": kb.InsertText, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters