extension

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package extension implements logic to prepare extensions to be installed to Chrome for testing.

Index

Constants

View Source
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"
)
View Source
const TastChromeOptionsJSVar = "tastChromeOptions"

TastChromeOptionsJSVar the JavaScript var name for storing the chrome options.

View Source
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

func BackgroundPageURL(id string) string

BackgroundPageURL returns the URL to the background page for the extension with the supplied ID.

func Checksums

func Checksums(destDir string) ([]string, error)

Checksums returns the MD5 checksums of the existing extensions' manifest file.

func ChownContentsToChrome

func ChownContentsToChrome(dir string) error

ChownContentsToChrome recursively changes the ownership of the directory contents to the uid and gid of the Chrome's browser process.

func ComputeExtensionID

func ComputeExtensionID(dir string) (string, error)

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

func (f *Files) ChromeArgs() []string

ChromeArgs returns a list of arguments to be passed to Chrome to enable extensions.

func (*Files) DeprecatedDirs

func (f *Files) DeprecatedDirs() []string

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
)

Jump to

Keyboard shortcuts

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