Documentation ¶
Overview ¶
Package simbrowser provides facilities for simulating aspects of web browsers.
Index ¶
Constants ¶
const ( Chrome BrowserType = "Chrome" Firefox = "Firefox" Safari = "Safari" Edge = "Edge" ThreeSixtySecureBrowser = "ThreeSixtySecure" QQBrowser = "QQBrowser" )
Possible browser types.
Variables ¶
This section is empty.
Functions ¶
func SetMarketShareData ¶
func SetMarketShareData(global MarketShareData, regional map[CountryCode]MarketShareData) error
SetMarketShareData sets the data used by ChooseForUser. The total share of the global market and each regional market must fall within the bounds established by AcceptableMinTotalMarketShare and AcceptableMaxTotalMarketShare.
Types ¶
type Browser ¶
type Browser struct { Type BrowserType SessionTicketLifetime time.Duration ClientHelloID tls.ClientHelloID }
Browser represents a specific web browser, e.g. Chrome or Firefox.
func ChooseForUser ¶
func ChooseForUser(ctx context.Context, uc common.UserConfig) Browser
ChooseForUser chooses a web browser for the input user. If it is possible to determine the system's default web browser, a corresponding Browser instance will be returned. If not, this function chooses a browser to mimic. This choice is deterministic for a given user ID, and the distribution of choices across user IDs will reflect the market share of the top 4 browsers.
If necessary, we use region-specific market share figures. This is based on the client's geolocation and thus this function may block for a period while geolocation is determined. If the context expires before the client's geolocation can be determined, global market shares will be used.
type CountryCode ¶
type CountryCode string
CountryCode is a 2-letter ISO country code.
func (CountryCode) String ¶
func (cc CountryCode) String() string
type MarketShare ¶
type MarketShare float64
MarketShare is a value between 0 and 1 representing a fraction of the global market.
const ()
Bounds for data accepted by SetMarketShareData.
type MarketShareData ¶
type MarketShareData map[BrowserType]MarketShare
MarketShareData encapsulates market share information for a region.