Documentation ¶
Overview ¶
Package browser implements a layer of abstraction over Ash and Lacros Chrome instances.
Index ¶
- func ClearNotification(ctx context.Context, tconn *TestConn, id string) error
- func CreateTestNotification(ctx context.Context, tconn *TestConn, notificationType NotificationType, ...) (string, error)
- type Browser
- func (b *Browser) CloseTarget(ctx context.Context, id TargetID) error
- func (b *Browser) CloseWithURL(ctx context.Context, url string) error
- func (b *Browser) FindTargets(ctx context.Context, tm TargetMatcher) ([]*Target, error)
- func (b *Browser) IsTargetAvailable(ctx context.Context, tm TargetMatcher) (bool, error)
- func (b *Browser) NewConn(ctx context.Context, url string, opts ...CreateTargetOption) (*Conn, error)
- func (b *Browser) NewConnForTarget(ctx context.Context, tm TargetMatcher) (*Conn, error)
- func (b *Browser) ReloadActiveTab(ctx context.Context) error
- func (b *Browser) StartTracing(ctx context.Context, categories []string, opts ...TraceOption) error
- func (b *Browser) StopTracing(ctx context.Context) (*perfetto_proto.Trace, error)
- func (b *Browser) TestAPIConn(ctx context.Context) (*TestConn, error)
- type Conn
- type CreateTargetOption
- type NotificationItem
- type NotificationType
- type Target
- type TargetID
- type TargetMatcher
- type TestConn
- type TraceOption
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearNotification ¶
ClearNotification clear a notification with the given id.
func CreateTestNotification ¶
func CreateTestNotification(ctx context.Context, tconn *TestConn, notificationType NotificationType, title, message string) (string, error)
CreateTestNotification creates a notification with a custom title and message. iconUrl is a required field to the chrome.notifiations.create() call so a 1px transparent data-url is hardcoded. tconn is an arg to be passed in from active browser under test (either ash-chrome or lacros-chrome).
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser consists of just a Chrome session.
func (*Browser) CloseTarget ¶
CloseTarget closes the target identified by the given id.
func (*Browser) CloseWithURL ¶
CloseWithURL finds all targets with the given url, closes them, and waits until they are closed. Note that if this closes all lacros pages, lacros will exit, and we won't be able to verify closing was done successfully. If this turns out to cause flakes, we can additionally poll to see if the lacros process still exists, and if it does then poll each target to see if it closed.
func (*Browser) FindTargets ¶
FindTargets returns the info about Targets, which satisfies the given cond condition. This must not be called after Close().
func (*Browser) IsTargetAvailable ¶
IsTargetAvailable checks if there is any matched target.
func (*Browser) NewConn ¶
func (b *Browser) NewConn(ctx context.Context, url string, opts ...CreateTargetOption) (*Conn, error)
NewConn creates a new Chrome renderer and returns a connection to it. If url is empty, an empty page (about:blank) is opened. Otherwise, the page from the specified URL is opened. You can assume that the page loading has been finished when this function returns.
func (*Browser) NewConnForTarget ¶
NewConnForTarget iterates through all available targets and returns a connection to the first one that is matched by tm.
func (*Browser) ReloadActiveTab ¶
ReloadActiveTab reloads the active tab.
func (*Browser) StartTracing ¶
StartTracing starts trace events collection for the selected categories. Android categories must be prefixed with "disabled-by-default-android ", e.g. for the gfx category, use "disabled-by-default-android gfx", including the space.
func (*Browser) StopTracing ¶
StopTracing stops trace collection and returns the collected trace events.
type CreateTargetOption ¶
type CreateTargetOption = cdputil.CreateTargetOption
CreateTargetOption is cpdutil.CreateTargetOption.
func WithNewWindow ¶
func WithNewWindow() CreateTargetOption
WithNewWindow behaves like cpdutil.WithNewWindow.
type NotificationItem ¶
NotificationItem describes an individual item in a list notification. As defined in https://developer.chrome.com/docs/extensions/reference/notifications/#type-NotificationItem
type NotificationType ¶
type NotificationType string
NotificationType describes the types of notifications you can create with chrome.notifications.create()
const ( NotificationTypeBasic NotificationType = "basic" NotificationTypeImage NotificationType = "image" NotificationTypeList NotificationType = "list" NotificationTypeProgress NotificationType = "progress" )
As defined in https://developer.chrome.com/apps/notifications#type-TemplateType
type TargetMatcher ¶
type TargetMatcher = driver.TargetMatcher
TargetMatcher is chrome.TargetMatcher.
type TraceOption ¶
type TraceOption = cdputil.TraceOption
TraceOption is cpdutil.TraceOption.
func DisableSystrace ¶
func DisableSystrace() TraceOption
DisableSystrace behaves like cpdutil.DisableSystrace.
Directories ¶
Path | Synopsis |
---|---|
Package browserfixt provides a function for obtaining a Browser instance for a given tast fixture and browser type.
|
Package browserfixt provides a function for obtaining a Browser instance for a given tast fixture and browser type. |