// Configures various features of the Remote Debugging protocol and provides
// environment setup.
Configures various features of the Remote Debugging protocol and provides
environment setup.
// Configures various features of the Remote Debugging protocol and provides // environment setup .
func (self *Commands) Configure(args *ConfigureArgs) error {
	if args == nil {
		args = &ConfigureArgs{}
	}
	defaults.SetDefaults(args)
	lat := args.Latitude
	lon := args.Longitude
	if lat != 0 && lon != 0 {
		if _, err := self.browser.Tab().RPC(`Emulation`, `setGeolocationOverride`, map[string]interface{}{
			`latitude`:  lat,
			`longitude`: lon,
			`accuracy`:  args.Accuracy,
		}); err != nil {
			return err
		}
	} else {
		self.browser.Tab().RPC(`Emulation`, `clearGeolocationOverride`, nil)
	}
	if ua := args.UserAgent; ua != `` {
		if _, err := self.browser.Tab().RPC(`Emulation`, `setUserAgentOverride`, map[string]interface{}{
			`userAgent`: ua,
		}); err != nil {
			return err
		}
	}
	self.browser.Tab().AsyncRPC(`Emulation`, `setScriptExecutionDisabled`, map[string]interface{}{
		`value`: args.DisableScripts,
	})
	self.browser.Tab().AsyncRPC(`Emulation`, `setTouchEmulationEnabled`, map[string]interface{}{
		`value`: args.EmulateTouch,
	})
	self.browser.Tab().AsyncRPC(`Emulation`, `setScrollbarsHidden`, map[string]interface{}{
		`hidden`: args.HideScrollbars,
	})
	if bgcolor := args.BackgroundColor; bgcolor != `` {
		if col, err := colorutil.Parse(bgcolor); err == nil {
			r, g, b, a := col.RGBA255()
			self.browser.Tab().AsyncRPC(`Emulation`, `setDefaultBackgroundColorOverride`, map[string]interface{}{
				`r`: r,
				`g`: g,
				`b`: b,
				`a`: a,
			})
		} else {
			return fmt.Errorf("invalid background color: %v", err)
		}
	} else {
		self.browser.Tab().AsyncRPC(`Emulation`, `setDefaultBackgroundColorOverride`, nil)
	}
	return nil
}
func ( self * Commands ) Configure ( args * ConfigureArgs ) error { if args == nil { args = & ConfigureArgs { } } defaults . SetDefaults ( args ) lat := args . Latitude lon := args . Longitude if lat != 0 && lon != 0 { if _ , err := self . browser . Tab ( ) . RPC ( `Emulation` , `setGeolocationOverride` , map [ string ] interface { } { `latitude` : lat , `longitude` : lon , `accuracy` : args . Accuracy , } ) ; err != nil { return err } } else { self . browser . Tab ( ) . RPC ( `Emulation` , `clearGeolocationOverride` , nil ) } if ua := args . UserAgent ; ua != `` { if _ , err := self . browser . Tab ( ) . RPC ( `Emulation` , `setUserAgentOverride` , map [ string ] interface { } { `userAgent` : ua , } ) ; err != nil { return err } } self . browser . Tab ( ) . AsyncRPC ( `Emulation` , `setScriptExecutionDisabled` , map [ string ] interface { } { `value` : args . DisableScripts , } ) self . browser . Tab ( ) . AsyncRPC ( `Emulation` , `setTouchEmulationEnabled` , map [ string ] interface { } { `value` : args . EmulateTouch , } ) self . browser . Tab ( ) . AsyncRPC ( `Emulation` , `setScrollbarsHidden` , map [ string ] interface { } { `hidden` : args . HideScrollbars , } ) if bgcolor := args . BackgroundColor ; bgcolor != `` { if col , err := colorutil . Parse ( bgcolor ) ; err == nil { r , g , b , a := col . RGBA255 ( ) self . browser . Tab ( ) . AsyncRPC ( `Emulation` , `setDefaultBackgroundColorOverride` , map [ string ] interface { } { `r` : r , `g` : g , `b` : b , `a` : a , } ) } else { return fmt . Errorf ( " " , err ) } } else { self . browser . Tab ( ) . AsyncRPC ( `Emulation` , `setDefaultBackgroundColorOverride` , nil ) } return nil }
Configures various features of the Remote Debugging protocol and provides
environment setup.
Configures various features of the Remote Debugging protocol and provides environment setup .
// Geolocation // --------------------------------------------------------------------------------------------- // User Agent // --------------------------------------------------------------------------------------------- // Emulation Flags & Features // ---------------------------------------------------------------------------------------------