fake

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fake is an in-memory platform.Backend for testing the public API without a GUI. Its event loop runs on the goroutine that calls Run, which is treated as the main thread.

Index

Constants

This section is empty.

Variables

Apps are the applications Applications lists, which tests set.

View Source
var DefaultAppURLs []string

DefaultAppURLs are the URLs DefaultApp was asked about, in order.

View Source
var ErrNoReply = errors.New("fake: no reply")

ErrNoReply makes Window.CallAsyncFunction never call back, like a promise that never settles.

View Source
var Opened []string

Opened are the paths OpenApplication was given.

View Source
var OpenedExternal []string

OpenedExternal are the URLs OpenExternal was given. Main thread only.

View Source
var Previewed []string

Previewed are the paths PreviewItem was given.

View Source
var Trashed []string

Trashed are the paths TrashItem was given.

Functions

This section is empty.

Types

type Backend

type Backend struct {

	// IgnoresQuit makes Quit leave the event loop running, as AppKit's
	// has been seen to; Quits counts the calls.
	IgnoresQuit bool
	Quits       int

	// ClipboardConcealed is whether the last write marked its content
	// confidential.
	ClipboardConcealed bool
	// ClipboardError injects a failed write while preserving existing ownership.
	ClipboardError error
	// ClipboardDuringFlush simulates a toolkit pumping a nested event loop
	// after releasing providers but before its storage operation returns.
	ClipboardDuringFlush func()

	// KeepsLocale makes the backend keep the app's language, as macOS
	// does, in SavedLocale; without it the core keeps it in a file.
	KeepsLocale bool

	// UILanguages are the languages SetLanguages told last, and
	// UIRightToLeft its direction.
	UILanguages   []string
	UIRightToLeft bool
	// Watching reports whether power events were asked for, Awake counts the
	// KeepAwake calls not released yet, and Running the KeepRunning calls.
	Watching bool
	Awake    int
	Running  int
	// Playing is what NowPlaying.Set showed last, nil once removed, and
	// NowPlayingSets counts the calls.
	Playing        *platform.NowPlayingInfo
	NowPlayingSets int
	// Online and Metered are what Network.Status answers with, and
	// WatchingNetwork whether Network.Watch was called.
	Online, Metered bool
	WatchingNetwork bool
	// FileWatches are the file watches made, FileWatchError what making
	// one fails with, FileWatchSubtree whether they take Subtree targets
	// and FileWatchNoFiles whether they refuse files.
	FileWatches      []*FileWatch
	FileWatchError   error
	FileWatchSubtree bool
	FileWatchNoFiles bool
	// FileWatchAddHook is the AddHook of the file watches made.
	FileWatchAddHook func(platform.FileWatchTarget) error
	// ReplaceFileHook, when set, replaces files in place of ReplaceFile,
	// as a system that fails halfway would.
	ReplaceFileHook func(target, replacement string) error
	// URLSchemes are the registered URL schemes, by scheme: "id name".
	URLSchemes map[string]string
	// LoginItem is the command that starts the app at login: "id name arg".
	LoginItem string
	// DockMenu is the menu of the Dock icon.
	DockMenu *platform.Menu
	// Active is what App.IsActive answers; SetActive changes it.
	Active bool
	// FramesOnShow makes a window draw the frame its content asked for as
	// it shows, as AppKit may display a window it orders in. Main thread
	// only.
	FramesOnShow bool
	// ForegroundAllowed counts AllowForeground calls.
	ForegroundAllowed int
	// ActivationToken is the token of WithActivationToken while its
	// function runs.
	ActivationToken string
	// Cleared counts ClearBrowsingData calls for the default store.
	Cleared int

	// DataStores are the stores NewDataStore made, in order.
	DataStores []*DataStore

	ContentRuleCompiles int
	// CookiesCleared counts ClearCookies calls.
	CookiesCleared int
	// RecentDocuments are the paths AddRecentDocument recorded, in order,
	// without the ones ClearRecentDocuments removed.
	RecentDocuments []string
	// RecentCleared counts ClearRecentDocuments calls.
	RecentCleared int
	// JumpList is the list of the last SetJumpList call, JumpListCommits
	// the number of calls.
	JumpList        platform.JumpList
	JumpListCommits int
	// Dialog results returned by the next dialog.
	OpenResult    []string
	SaveResult    string
	MessageResult platform.MessageBoxResult
	// OnOpenDialog, OnSaveDialog and OnMessageBox, when set, answer the
	// dialogs instead of the results above. They run on the main thread.
	OnOpenDialog func(opts *platform.OpenDialogOptions) []string
	OnSaveDialog func(opts *platform.SaveDialogOptions) string
	OnMessageBox func(opts *platform.MessageBoxOptions) platform.MessageBoxResult
	// NotificationError, when set, is what showing a notification fails
	// with.
	NotificationError error
	// OnNotification, when set, handles delivery on the main thread, allowing
	// tests to model an authorization answer that arrives asynchronously.
	OnNotification func(*platform.Notification, func(error))
	// NoWebView makes WebViewAvailable report no system webview, as a
	// machine without one does.
	NoWebView bool
	// StyleSheet is the sheet SetStyleSheet loaded last, as GTK styles the
	// widgets it draws with it. StyleSheetError, when set, is what loading
	// one fails with, as a sheet that does not parse, which keeps the one
	// before. Main thread only.
	StyleSheet      string
	StyleSheetError error
	// StartButtons and EndButtons are the desktop's window buttons that
	// WindowButtons reports, as Linux's button layout gives them.
	StartButtons, EndButtons []string
	// contains filtered or unexported fields
}

Backend is a fake platform backend.

func New

func New() *Backend

New creates a fake backend.

func (*Backend) App

func (b *Backend) App() platform.AppController

func (*Backend) AppMenu

func (b *Backend) AppMenu() *platform.Menu

AppMenu returns the last application menu.

func (*Backend) Applications

func (b *Backend) Applications() ([]platform.Application, error)

func (*Backend) ClickMenuItem

func (b *Backend) ClickMenuItem(id int)

ClickMenuItem simulates choosing a menu item.

func (*Backend) ClickNotification

func (b *Backend) ClickNotification(id string)

ClickNotification reports a click on a notification, as the platform does. It runs on the main thread, like the backends report it.

func (*Backend) Clipboard

func (b *Backend) Clipboard() platform.Clipboard

func (*Backend) ContentRuleLists added in v0.1.8

func (b *Backend) ContentRuleLists() []string

ContentRuleLists returns the identifiers of the lists kept.

func (*Backend) Delivered

func (b *Backend) Delivered(n *platform.Notification)

Delivered adds a notification the platform still shows from an earlier run of the app, which the app did not show in this one.

func (*Backend) Dialogs

func (b *Backend) Dialogs() platform.Dialogs

func (*Backend) EmitMediaCommand added in v0.1.13

func (b *Backend) EmitMediaCommand(cmd platform.MediaCommand, position time.Duration)

EmitMediaCommand simulates a media key or a command of the system's media controls.

func (*Backend) EmitNetwork

func (b *Backend) EmitNetwork(status platform.NetworkStatus)

EmitNetwork reports a network status to the app, as a backend does when it may have changed.

func (*Backend) EmitPower

func (b *Backend) EmitPower(event string)

EmitPower simulates a power or session event.

func (*Backend) EndSession added in v0.1.18

func (b *Backend) EndSession()

EndSession simulates the OS ending the session (WM_ENDSESSION, applicationWillTerminate:): the app is told it terminates, and its event loop does not stop first.

func (*Backend) Init

func (*Backend) IsMainThread

func (b *Backend) IsMainThread() bool

func (*Backend) LastFileWatch

func (b *Backend) LastFileWatch() *FileWatch

LastFileWatch returns the FileWatch created last.

func (*Backend) MenuUpdates

func (b *Backend) MenuUpdates() []*platform.MenuItem

MenuUpdates returns the items passed to UpdateMenuItem.

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) Network

func (b *Backend) Network() platform.Network

func (*Backend) NewFileWatch

func (b *Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)

func (*Backend) NewTray

func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)

func (*Backend) NewWindow

func (*Backend) Notification

func (b *Backend) Notification(id string) *platform.Notification

Notification returns the notification with an id, or nil.

func (*Backend) Notifications

func (b *Backend) Notifications() []*platform.Notification

Notifications returns the notifications shown and not yet removed.

func (*Backend) NotificationsSupported

func (b *Backend) NotificationsSupported() bool

Notifications are recorded rather than shown, so that a test can see what the app asked for and report a click as a platform does.

func (*Backend) NowPlaying added in v0.1.13

func (b *Backend) NowPlaying() platform.NowPlaying

func (*Backend) PopupMenu

func (b *Backend) PopupMenu(m *platform.Menu, _ platform.Window, pos *platform.Point)

PopupMenu notes the context menu shown, which Popups returns.

func (*Backend) Popups

func (b *Backend) Popups() []Popup

Popups returns the context menus shown, in order.

func (*Backend) Power

func (b *Backend) Power() platform.Power

func (*Backend) PreferenceReads

func (b *Backend) PreferenceReads() int

PreferenceReads returns how many times Preferences() read the backend, for tests.

func (*Backend) PressHotkey

func (b *Backend) PressHotkey(acc string)

PressHotkey simulates a global shortcut.

func (*Backend) Quit

func (b *Backend) Quit()

func (*Backend) QuitRequested

func (b *Backend) QuitRequested() bool

QuitRequested simulates Cmd+Q and reports whether the app agreed.

func (*Backend) RegisterHotkey

func (b *Backend) RegisterHotkey(id int, acc string) error

func (*Backend) RemoveAllNotifications

func (b *Backend) RemoveAllNotifications()

func (*Backend) RemoveNotification

func (b *Backend) RemoveNotification(id string)

func (*Backend) ReplaceFile

func (b *Backend) ReplaceFile(target, replacement string) error

ReplaceFile renames replacement over target, with the target's permissions. On Windows it gives a reader holding the target open without sharing deletes a moment to let go, as the Windows backend does: a test reading the file while the app saves it is such a reader.

func (*Backend) Run

func (b *Backend) Run() error

func (*Backend) Screen

func (b *Backend) Screen() platform.Screen

func (*Backend) Secrets

func (b *Backend) Secrets() platform.Secrets

func (*Backend) SetActive added in v0.1.13

func (b *Backend) SetActive(active bool)

SetActive makes the app the active one, or not, and reports it as the system does when it changes (main thread).

func (*Backend) SetApplicationMenu

func (b *Backend) SetApplicationMenu(m *platform.Menu)

func (*Backend) SetNoSessionState added in v0.1.13

func (b *Backend) SetNoSessionState(v bool)

SetNoSessionState makes the pages keep no session state, as WebView2's: SessionState returns nil and RestoreSessionState fails.

func (*Backend) SetPreferences

func (b *Backend) SetPreferences(p platform.Preferences)

SetPreferences changes the desktop's preferences, as the user does in the system's settings.

func (*Backend) SetSavedLocale

func (b *Backend) SetSavedLocale(tag string)

SetSavedLocale sets what the system keeps of the app's language, as the user does choosing it in macOS's System Settings while the app is not running.

func (*Backend) SetSecretError

func (b *Backend) SetSecretError(err error)

SetSecretError makes every Secrets call fail with err, or work again when err is nil. It may be called from any goroutine.

func (*Backend) SetStyleSheet added in v0.1.17

func (b *Backend) SetStyleSheet(css string) error

SetStyleSheet loads css in place of the sheet before, as Linux's GTK does (platform.StyleBackend).

func (*Backend) SetSystemLanguages

func (b *Backend) SetSystemLanguages(tags ...string)

SetSystemLanguages changes the languages the user prefers, as the user does in the system's settings, and reports it; none goes back to en-US.

func (*Backend) SetSystemRegion

func (b *Backend) SetSystemRegion(r platform.Region)

SetSystemRegion changes the user's regional formats, as the user does in the system's settings, and reports it.

func (*Backend) SetTrayDark

func (b *Backend) SetTrayDark(dark bool)

SetTrayDark turns the menu bar the icons show on dark or light, as the system's appearance or the wallpaper does, and tells the icons.

func (*Backend) Shell

func (b *Backend) Shell() platform.Shell

func (*Backend) ShowNotification

func (b *Backend) ShowNotification(n *platform.Notification, done func(error))

func (*Backend) Signal

func (b *Backend) Signal()

func (*Backend) Step

func (b *Backend) Step()

func (*Backend) StoredSecret

func (b *Backend) StoredSecret(service, account string) ([]byte, bool)

StoredSecret returns the secret stored for service and account, as the system's store would show it.

func (*Backend) Theme

func (b *Backend) Theme() platform.Theme

func (*Backend) TrayIDs

func (b *Backend) TrayIDs() []string

TrayIDs returns the IDs the tray icons were given, in order.

func (*Backend) UnregisterHotkey

func (b *Backend) UnregisterHotkey(id int)

func (*Backend) UpdateMenuItem

func (b *Backend) UpdateMenuItem(it *platform.MenuItem)

func (*Backend) Wake

func (b *Backend) Wake()

func (*Backend) WebViewAvailable

func (b *Backend) WebViewAvailable() bool

WebViewAvailable reports whether the fake system webview is there: windows showing web pages work, unless NoWebView says otherwise.

func (*Backend) WindowButtons added in v0.1.17

func (b *Backend) WindowButtons() (start, end []string)

WindowButtons returns StartButtons and EndButtons, as Linux's desktop layout gives them (platform.WindowButtonsBackend).

func (*Backend) Windows

func (b *Backend) Windows() []*Window

Windows returns the windows created so far.

type ContentRuleList added in v0.1.8

type ContentRuleList struct {
	ID, Identifier, Rules string
}

ContentRuleList is a list CompileContentRules made: the handle SetContentRules gets.

type DataStore added in v0.1.13

type DataStore struct {
	Opts platform.DataStoreOptions
	// Closed tells that Close was called; Cleared lists the types of
	// ClearBrowsingData calls.
	Closed  bool
	Cleared []platform.SiteData
	// contains filtered or unexported fields
}

DataStore is a website data store NewDataStore made, with cookies of its own.

func (*DataStore) Close added in v0.1.13

func (s *DataStore) Close()

Close marks the store closed: its cookies go.

type FileWatch

type FileWatch struct {

	// Subtree makes Add accept Subtree targets, as Windows does.
	Subtree bool
	// NoFiles makes Add refuse targets that aren't directories, as every
	// system backend does.
	NoFiles bool
	// AddHook, when set, runs in Add before the target is enrolled; an
	// error it returns is Add's.
	AddHook func(platform.FileWatchTarget) error
	// contains filtered or unexported fields
}

FileWatch records the targets the core enrolls; tests report changes with Notify.

func (*FileWatch) Add

func (*FileWatch) Close

func (w *FileWatch) Close()

func (*FileWatch) Notify

func (w *FileWatch) Notify(n platform.FileWatchNotice)

Notify reports n, as a backend's goroutine would, unless the watch is closed.

func (*FileWatch) Remove

func (w *FileWatch) Remove(id uint64)

func (*FileWatch) Targets

func (w *FileWatch) Targets() []platform.FileWatchTarget

Targets returns the enrolled targets.

type Popup struct {
	Menu *platform.Menu
	Pos  *platform.Point
}

Popup is a context menu shown at Pos.

type Surface

type Surface struct {

	// Scale is the device pixels per DIP.
	Scale float64
	// contains filtered or unexported fields
}

Surface is a fake window surface: it records what the content asks of it, and tests deliver events through Send.

func (*Surface) Accessibility

func (s *Surface) Accessibility() (*platform.AccessTree, int)

Accessibility returns the last accessibility tree the content gave, and how many it gave.

func (*Surface) CancelDataDrag

func (s *Surface) CancelDataDrag()

func (*Surface) Cursor

func (s *Surface) Cursor() platform.Cursor

Cursor returns the pointer shape the content set; TextInput whether it asked for text input.

func (*Surface) DataDrag

func (s *Surface) DataDrag() *platform.DragRequest

DataDrag returns the active native-source request. Main thread only.

func (*Surface) FinishDataDrag

func (s *Surface) FinishDataDrag(r transfer.Result)

FinishDataDrag delivers the native source's result once. Main thread only.

func (*Surface) Frame

func (s *Surface) Frame() bool

Frame draws a frame when the content asked for one since the last, as the display would, and reports whether it did.

func (*Surface) FrameRate added in v0.1.13

func (s *Surface) FrameRate() float64

FrameRate returns what SetFrameRate last set, 0 for the display's rate.

func (*Surface) Frames

func (s *Surface) Frames() int

Frames returns how many frames were presented.

func (*Surface) Native

func (s *Surface) Native() platform.SurfaceNative

func (*Surface) NewWebView

func (*Surface) Pixel

func (s *Surface) Pixel(x, y int) [4]byte

Pixel returns the color of a pixel of the last frame, as BGRA.

func (*Surface) PlaceWebViews

func (s *Surface) PlaceWebViews(views []platform.WebViewPlacement)

func (*Surface) Placements

func (s *Surface) Placements() int

Placements counts the PlaceWebViews calls.

func (*Surface) PresentPixels

func (s *Surface) PresentPixels(pix []byte, stride, width, height int)

func (*Surface) Press

func (s *Surface) Press(x, y float64) *WebView

Press presses the pointer at x, y as the platform would: on the web view taking it there, which tells the content (WebViewPress) and returns it, else on the content, and reports nil.

func (*Surface) RefreshRate

func (s *Surface) RefreshRate() float64

RefreshRate returns the display's refresh rate, 60 unless SetRefreshRate set another.

func (*Surface) RequestFrame

func (s *Surface) RequestFrame()

func (*Surface) Send

func (s *Surface) Send(ev platform.SurfaceEvent) bool

Send delivers an event to the window's content, on the main thread, and returns what the content answered.

func (*Surface) SetCursor

func (s *Surface) SetCursor(c platform.Cursor)

func (*Surface) SetDropFormats

func (s *Surface) SetDropFormats(f []transfer.Format)

func (*Surface) SetFrameRate added in v0.1.13

func (s *Surface) SetFrameRate(fps float64)

SetFrameRate records the frames a second the content asks for (platform.FrameRateSurface), which FrameRate returns.

func (*Surface) SetMaximizeButton added in v0.1.8

func (s *Surface) SetMaximizeButton(r platform.RectF)

SetMaximizeButton records the button in the window's MaximizeButton (platform.MaximizeButtonSurface).

func (*Surface) SetRefreshRate

func (s *Surface) SetRefreshRate(hz float64)

SetRefreshRate sets the display's refresh rate.

func (*Surface) SetTextInput

func (s *Surface) SetTextInput(t platform.TextInputState)

func (*Surface) Size

func (s *Surface) Size() (float64, float64, float64)

func (*Surface) StartDataDrag

func (s *Surface) StartDataDrag(r platform.DragRequest)

func (*Surface) TextInput

func (s *Surface) TextInput() (bool, platform.RectF)

TextInput reports whether text input is on, and the caret.

func (*Surface) TextInputState

func (s *Surface) TextInputState() platform.TextInputState

TextInputState returns the last state of text input the content set.

func (*Surface) UpdateAccessibility

func (s *Surface) UpdateAccessibility(tree *platform.AccessTree)

func (*Surface) WebViewAt

func (s *Surface) WebViewAt(x, y float64) *WebView

WebViewAt returns the web view that takes the pointer at x, y: the last shown, in the order the content painted them, whose placement takes it.

func (*Surface) WebViews

func (s *Surface) WebViews() []*WebView

WebViews returns the surface's web views not closed, in the order they were made.

type WebView

type WebView struct {
	*Window

	// Placement is where the content last showed the web view, while
	// Shown; Focused tells that Focus or TabInto gave it the keyboard
	// since, TabbedBack that TabInto did so going back.
	Placement  platform.WebViewPlacement
	Shown      bool
	Focused    bool
	TabbedBack bool
	// contains filtered or unexported fields
}

WebView is a web view under a fake Surface (Surface.NewWebView): a Window of its own for its page, which its handler hears of, without the window's methods.

func (*WebView) Close

func (v *WebView) Close()

Close closes the web view; its handler hears no more of it.

func (*WebView) Focus

func (v *WebView) Focus()

func (*WebView) Host

func (v *WebView) Host() *Window

Host returns the window the web view is in.

func (*WebView) TabInto

func (v *WebView) TabInto(back bool)

func (*WebView) TabOut

func (v *WebView) TabOut(back bool)

TabOut moves the keyboard out of the web view as Tab past its page's last element does, or Shift+Tab past its first when back.

func (*WebView) UnhandledKey added in v0.1.17

func (v *WebView) UnhandledKey(mods platform.Modifiers, key platform.Key)

UnhandledKey presses a key in the page that the page leaves unhandled, which the platform passes on to the content (WebViewKey).

type Window

type Window struct {
	H    platform.WindowHandler
	Opts *platform.WindowOptions
	// Flyout is how a flyout was placed last.
	Flyout platform.Flyout

	// Restored is the last state RestoreSessionState put back.
	Restored []byte
	// Dropped is what DroppedFiles returns, once.
	Dropped []string
	// PDF holds the options of the last PrintToPDF.
	PDF platform.PDFOptions
	// HTML holds the documents LoadHTML loaded, in order.
	HTML []string
	// UserScriptUpdates counts the calls of SetUserScripts.
	UserScriptUpdates int

	ContentRuleUpdates int
	// What the window extras were last set to.
	Background      platform.Color
	Progress        string
	ProgressValue   float64
	Flashing        bool
	SkipsTaskbar    bool
	OnAllWorkspaces bool
	AutoHidesMenu   bool
	Icon            []byte
	// RepresentedFile and DocumentEdited are what SetRepresentedFile and
	// SetDocumentEdited set.
	RepresentedFile string
	DocumentEdited  bool
	// TitleBarRoom is what TitleBar returns: set for windows with a hidden
	// title bar, and changed by tests before they call H.TitleBarChanged.
	TitleBarRoom platform.TitleBar
	// MaximizeButton is where the content last said it shows the maximize
	// button.
	MaximizeButton platform.RectF
	// InputRegion is what SetInputRegion set last: nil for all of the
	// window.
	InputRegion []platform.Rect
	// AsyncFunction answers CallAsyncFunction.
	AsyncFunction func(body string) (string, error)
	// AsyncCallback, when set, receives CallAsyncFunction calls to answer
	// through reply whenever it wants, on the main thread.
	AsyncCallback func(body string, reply func(string, error))
	// OnEval, when set, receives the scripts passed to Eval instead of
	// recording them.
	OnEval func(js string)
	// contains filtered or unexported fields
}

Window is a fake native window. Scripts evaluated in it are recorded.

func (*Window) ActiveAppearance added in v0.1.13

func (w *Window) ActiveAppearance() bool

ActiveAppearance reports what SetActiveAppearance set last.

func (*Window) Blur

func (w *Window) Blur()

func (*Window) Bounds

func (w *Window) Bounds() platform.Rect

func (*Window) CallAsyncFunction

func (w *Window) CallAsyncFunction(body string, cb func(string, error))

func (*Window) CanGoBack

func (w *Window) CanGoBack() bool

func (*Window) CanGoForward

func (w *Window) CanGoForward() bool

func (*Window) CapturePage

func (w *Window) CapturePage(cb func([]byte, error))

func (*Window) CaptureState added in v0.1.13

func (w *Window) CaptureState(kind platform.CaptureKind) platform.CaptureState

func (*Window) Center

func (w *Window) Center()

func (*Window) ClearScripts

func (w *Window) ClearScripts()

ClearScripts forgets the scripts passed to Eval so far.

func (*Window) ClickMenuItem

func (w *Window) ClickMenuItem(id int)

ClickMenuItem simulates choosing an item of this window's menu.

func (*Window) Close

func (w *Window) Close()

func (*Window) CloseDevTools

func (w *Window) CloseDevTools()

func (*Window) ContentBounds

func (w *Window) ContentBounds() platform.Rect

func (*Window) ContentRules added in v0.1.8

func (w *Window) ContentRules() []*ContentRuleList

ContentRules returns the lists the page's loads go through.

func (*Window) Document

func (w *Window) Document() (path string, edited bool)

Document returns what SetRepresentedFile and SetDocumentEdited set.

func (*Window) DroppedFiles

func (w *Window) DroppedFiles() []string

func (*Window) Eval

func (w *Window) Eval(js string)

func (*Window) FakeSurface

func (w *Window) FakeSurface() *Surface

FakeSurface returns the window's surface, for tests.

func (*Window) FlashFrame

func (w *Window) FlashFrame(v bool)

func (*Window) Focus

func (w *Window) Focus()

func (*Window) GPUProcessID added in v0.1.17

func (w *Window) GPUProcessID() int

func (*Window) GoBack

func (w *Window) GoBack()

func (*Window) GoForward

func (w *Window) GoForward()

func (*Window) Handle

func (w *Window) Handle() uintptr

func (*Window) HasShadow

func (w *Window) HasShadow() bool

func (*Window) Hide

func (w *Window) Hide()

func (*Window) IsAlwaysOnTop

func (w *Window) IsAlwaysOnTop() bool

func (*Window) IsAudible added in v0.1.13

func (w *Window) IsAudible() bool

func (*Window) IsAudioMuted added in v0.1.13

func (w *Window) IsAudioMuted() bool

func (*Window) IsClosable

func (w *Window) IsClosable() bool

func (*Window) IsClosed

func (w *Window) IsClosed() bool

IsClosed reports whether Close was called.

func (*Window) IsDevToolsOpened

func (w *Window) IsDevToolsOpened() bool

func (*Window) IsFocused

func (w *Window) IsFocused() bool

func (*Window) IsFullScreen

func (w *Window) IsFullScreen() bool

func (*Window) IsLoading

func (w *Window) IsLoading() bool

func (*Window) IsMaximizable

func (w *Window) IsMaximizable() bool

func (*Window) IsMaximized

func (w *Window) IsMaximized() bool

func (*Window) IsMinimizable

func (w *Window) IsMinimizable() bool

func (*Window) IsMinimized

func (w *Window) IsMinimized() bool

func (*Window) IsMovable

func (w *Window) IsMovable() bool

func (*Window) IsResizable

func (w *Window) IsResizable() bool

func (*Window) IsVisible

func (w *Window) IsVisible() bool

func (*Window) LoadFile

func (w *Window) LoadFile(path, _ string)

func (*Window) LoadHTML

func (w *Window) LoadHTML(html, _ string)

func (*Window) LoadURL

func (w *Window) LoadURL(url string)

func (*Window) Maximize

func (w *Window) Maximize()

func (*Window) Menu

func (w *Window) Menu() *platform.Menu

Menu returns the menu SetMenu set last.

func (*Window) Minimize

func (w *Window) Minimize()

func (*Window) Opacity

func (w *Window) Opacity() float64

func (*Window) OpenDevTools

func (w *Window) OpenDevTools()

func (*Window) PictureInPictureActive added in v0.1.13

func (w *Window) PictureInPictureActive(cb func(bool))

func (*Window) PlaceFlyout

func (w *Window) PlaceFlyout(f platform.Flyout, size platform.Size)

PlaceFlyout places a flyout as the real backends do, against the parent's content area and the fake display's work area.

func (*Window) Print

func (w *Window) Print()

func (*Window) PrintToPDF

func (w *Window) PrintToPDF(o platform.PDFOptions, cb func([]byte, error))

func (*Window) ProcessID added in v0.1.13

func (w *Window) ProcessID() int

func (*Window) Reload

func (w *Window) Reload(bool)

func (*Window) Restore

func (w *Window) Restore()

func (*Window) RestoreSessionState added in v0.1.13

func (w *Window) RestoreSessionState(state []byte) bool

RestoreSessionState puts back a state SessionState made, which goes to its URL, and records it in Restored; it can't while the backend keeps no session state, nor read other states.

func (*Window) Scripts

func (w *Window) Scripts() []string

Scripts returns the scripts passed to Eval.

func (*Window) SessionState added in v0.1.13

func (w *Window) SessionState() []byte

SessionState returns "fake session of " and the page's URL, as an engine returns its back/forward list, or nil while the backend keeps no session state (Backend.SetNoSessionState), as WebView2.

func (*Window) SetActiveAppearance added in v0.1.13

func (w *Window) SetActiveAppearance(v bool)

func (*Window) SetAlwaysOnTop

func (w *Window) SetAlwaysOnTop(bool)

func (*Window) SetAudible added in v0.1.13

func (w *Window) SetAudible(v bool)

SetAudible sets whether the page plays sound (IsAudible) and reports it to the handler (AudibleChanged), as a backend does whenever the page starts or stops playing; it reports it even when it did not change. Call it on the main thread, where backends report it.

func (*Window) SetAudioMuted added in v0.1.13

func (w *Window) SetAudioMuted(v bool)

func (*Window) SetAutoHideMenu

func (w *Window) SetAutoHideMenu(v bool)

func (*Window) SetBackgroundColor

func (w *Window) SetBackgroundColor(c platform.Color)

func (*Window) SetBounds

func (w *Window) SetBounds(r platform.Rect)

func (*Window) SetCapture added in v0.1.13

func (w *Window) SetCapture(kind platform.CaptureKind, state platform.CaptureState)

SetCapture sets the page's capture of kind (CaptureState) and reports it to the handler (CaptureStateChanged), as a backend does whenever the page starts, mutes or stops capturing; it reports it even when it did not change. Call it on the main thread, where backends report it.

func (*Window) SetCaptureState added in v0.1.13

func (w *Window) SetCaptureState(kind platform.CaptureKind, state platform.CaptureState)

SetCaptureState mutes, unmutes or stops the page's capture of kind, as a page takes it, and reports it to the handler; it does nothing while the page captures no such device.

func (*Window) SetClosable

func (w *Window) SetClosable(bool)

func (*Window) SetContentBounds

func (w *Window) SetContentBounds(r platform.Rect)

func (*Window) SetContentProtection

func (w *Window) SetContentProtection(bool)

func (*Window) SetContentRules added in v0.1.8

func (w *Window) SetContentRules(lists []any)

SetContentRules keeps the lists, which ContentRules returns.

func (*Window) SetDocumentEdited

func (w *Window) SetDocumentEdited(v bool)

func (*Window) SetFullScreen

func (w *Window) SetFullScreen(v bool)

func (*Window) SetGPUProcessID added in v0.1.17

func (w *Window) SetGPUProcessID(pid int)

SetGPUProcessID sets the GPU process ID the page reports (GPUProcessID); 0, the default, is none known.

func (*Window) SetHasShadow

func (w *Window) SetHasShadow(bool)

func (*Window) SetIcon

func (w *Window) SetIcon(png []byte) error

func (*Window) SetIgnoreMouseEvents

func (w *Window) SetIgnoreMouseEvents(bool)

func (*Window) SetInputRegion added in v0.1.18

func (w *Window) SetInputRegion(r []platform.Rect)

func (*Window) SetMaximizable

func (w *Window) SetMaximizable(bool)

func (*Window) SetMaximumSize

func (w *Window) SetMaximumSize(platform.Size)

func (*Window) SetMenu

func (w *Window) SetMenu(m *platform.Menu)

func (*Window) SetMinimizable

func (w *Window) SetMinimizable(bool)

func (*Window) SetMinimumSize

func (w *Window) SetMinimumSize(platform.Size)

func (*Window) SetMovable

func (w *Window) SetMovable(bool)

func (*Window) SetOpacity

func (w *Window) SetOpacity(float64)

func (*Window) SetProcessID added in v0.1.13

func (w *Window) SetProcessID(pid int)

SetProcessID sets the process ID the page reports, as a backend whose web view runs in a process of that ID; 0, the default, is none known.

func (*Window) SetProgressBar

func (w *Window) SetProgressBar(state string, value float64)

func (*Window) SetRepresentedFile

func (w *Window) SetRepresentedFile(p string)

func (*Window) SetResizable

func (w *Window) SetResizable(bool)

func (*Window) SetSkipTaskbar

func (w *Window) SetSkipTaskbar(v bool)

func (*Window) SetTitle

func (w *Window) SetTitle(t string)

func (*Window) SetUserAgent

func (w *Window) SetUserAgent(string)

func (*Window) SetUserScripts

func (w *Window) SetUserScripts(scripts []platform.UserScript)

SetUserScripts replaces Opts.UserScripts, which tests read and UserScripts returns.

func (*Window) SetVibrancy

func (w *Window) SetVibrancy(string)

func (*Window) SetVibrancyTint added in v0.1.17

func (w *Window) SetVibrancyTint(*platform.Color)

func (*Window) SetVisibleOnAllWorkspaces

func (w *Window) SetVisibleOnAllWorkspaces(v bool)

func (*Window) SetWindowButtonsTheme added in v0.1.13

func (w *Window) SetWindowButtonsTheme(string)

func (*Window) SetZoom

func (w *Window) SetZoom(f float64)

func (*Window) Show

func (w *Window) Show()

func (*Window) ShowInactive

func (w *Window) ShowInactive()

func (*Window) StartDrag

func (w *Window) StartDrag()

func (*Window) StopLoading

func (w *Window) StopLoading()

func (*Window) Surface

func (w *Window) Surface() platform.Surface

Surface returns the window's surface, nil unless it was created with WindowOptions.Surface.

func (*Window) Title

func (w *Window) Title() string

func (*Window) TitleBar

func (w *Window) TitleBar() platform.TitleBar

func (*Window) TitleBarDoubleClicked

func (w *Window) TitleBarDoubleClicked()

func (*Window) TogglePictureInPicture added in v0.1.13

func (w *Window) TogglePictureInPicture()

TogglePictureInPicture moves the page's video into picture in picture or back, as a page with a video it can move.

func (*Window) URL

func (w *Window) URL() string

func (*Window) Unmaximize

func (w *Window) Unmaximize()

func (*Window) UserAgent

func (w *Window) UserAgent() string

func (*Window) UserClose

func (w *Window) UserClose() bool

UserClose simulates a click on the close button.

func (*Window) UserScripts

func (w *Window) UserScripts() []platform.UserScript

UserScripts returns the scripts a page loaded now gets: those of the options, or the ones SetUserScripts set since.

func (*Window) WebViewHandle

func (w *Window) WebViewHandle() uintptr

func (*Window) Zoom

func (w *Window) Zoom() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL