Documentation ¶
Overview ¶
Package extension implements logic to prepare extensions to be installed to Chrome for testing.
Index ¶
Constants ¶
const ( // TestExtensionID is an extension ID of the autotest extension. It // corresponds to testExtensionKey. TestExtensionID = "behllobkkfkfnphdnhnkndlbkcpglgmj" // SigninProfileTestExtensionID is an id of the test extension which is // allowed for signin profile (see http://crrev.com/772709 for details). // It corresponds to Var("ui.signinProfileTestExtensionManifestKey"). SigninProfileTestExtensionID = "mecfefiddjlmabpeilblgegnbioikfmp" )
const TastChromeOptionsJSVar = "tastChromeOptions"
TastChromeOptionsJSVar the JavaScript var name for storing the chrome options.
const ( // TastLibraryJS defines the utility library for Tast tests in JavaScript. // tast.promisify: // it takes Chrome style async API, which satisfies: // - The last param is a completion callback. // - The completion callback may take an argument, which will be // the result value. // - API error is reported via chrome.runtime.lastError. // Returned value is an async function to call the API. // tast.bind: // It takes two arguments: an object, and the name of its method, // then returns a closure that is bound to the given object. // Background: Some Chrome APIs are tied to a JavaScript object, but they // may not be bound to the object. Thus, e.g. // // tast.promisify(chrome.accessibilityFeatures.spokenFeedback.set) // // returns a Promise instance, which do not call the function on the // expected context. tast.bind can help the situation: // // tast.promisify(tast.bind(chrome.accessibilityFeatures.spokenFeedback, "set")) TastLibraryJS = `` /* 353-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func BackgroundPageURL ¶
BackgroundPageURL returns the URL to the background page for the extension with the supplied ID.
func ChownContentsToChrome ¶
ChownContentsToChrome recursively changes the ownership of the directory contents to the uid and gid of the Chrome's browser process.
func ComputeExtensionID ¶
ComputeExtensionID computes the 32-character ID that Chrome will use for an unpacked extension in dir. The extension's manifest file must contain the "key" field. Use the following command to generate a new key:
openssl genrsa 2048 | openssl rsa -pubout -outform der | openssl base64 -A
Types ¶
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files manages local files of extensions to be installed to Chrome for testing.
func PrepareExtensions ¶
func PrepareExtensions(destDir string, cfg *config.Config, guestMode GuestModeLogin) (files *Files, retErr error)
PrepareExtensions writes test extensions to the local disk. destDir is a path to a directory under which extensions are written. The directory should not exist at the beginning. Callers are responsible for deleting the directory after they're done with it. cfg is the chrome configuration that will be used by the chrome session. The user test extension is always created. If SigninExtKey of cfg is a non-empty string, the sign-in profile test extension is also created using the key. Extra extensions specified by extraExtDirs of cfg will also be installed. cfg will further be stored into test extension's background.js. It can be retrieved later for session reuse comparison. If guestMode is true, we load the tast extension as a component extension.
func (*Files) ChromeArgs ¶
ChromeArgs returns a list of arguments to be passed to Chrome to enable extensions.
func (*Files) DeprecatedDirs ¶
DeprecatedDirs returns a list of directories where extensions are available.
DEPRECATED: Use ChromeArgs instead. This method does not handle sign-in profile extensions correctly.
type GuestModeLogin ¶
type GuestModeLogin bool
GuestModeLogin maintains whether the session is a guest session or not.
const ( // GuestModeEnabled indicates session is a guest session. GuestModeEnabled GuestModeLogin = true // GuestModeDisabled indicates session is not guest session. GuestModeDisabled GuestModeLogin = false )