Update chromedp to fix console errors (#1521)

This commit is contained in:
peolic
2021-06-23 01:05:58 +03:00
committed by GitHub
parent ae3400a9b1
commit be2fe1de26
526 changed files with 55061 additions and 30300 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -187,6 +187,7 @@ type SetDeviceMetricsOverrideParams struct {
DontSetVisibleSize bool `json:"dontSetVisibleSize,omitempty"` // Do not set visible view size, rely upon explicit setVisibleSize call.
ScreenOrientation *ScreenOrientation `json:"screenOrientation,omitempty"` // Screen orientation override.
Viewport *page.Viewport `json:"viewport,omitempty"` // If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions.
DisplayFeature *DisplayFeature `json:"displayFeature,omitempty"` // If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
}
// SetDeviceMetricsOverride overrides the values of device screen dimensions
@@ -265,6 +266,13 @@ func (p SetDeviceMetricsOverrideParams) WithViewport(viewport *page.Viewport) *S
return &p
}
// WithDisplayFeature if set, the display feature of a multi-segment screen.
// If not set, multi-segment support is turned-off.
func (p SetDeviceMetricsOverrideParams) WithDisplayFeature(displayFeature *DisplayFeature) *SetDeviceMetricsOverrideParams {
p.DisplayFeature = displayFeature
return &p
}
// Do executes Emulation.setDeviceMetricsOverride against the provided context.
func (p *SetDeviceMetricsOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDeviceMetricsOverride, p, nil)
@@ -441,6 +449,46 @@ func (p *SetGeolocationOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetGeolocationOverride, p, nil)
}
// SetIdleOverrideParams overrides the Idle state.
type SetIdleOverrideParams struct {
IsUserActive bool `json:"isUserActive"` // Mock isUserActive
IsScreenUnlocked bool `json:"isScreenUnlocked"` // Mock isScreenUnlocked
}
// SetIdleOverride overrides the Idle state.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setIdleOverride
//
// parameters:
// isUserActive - Mock isUserActive
// isScreenUnlocked - Mock isScreenUnlocked
func SetIdleOverride(isUserActive bool, isScreenUnlocked bool) *SetIdleOverrideParams {
return &SetIdleOverrideParams{
IsUserActive: isUserActive,
IsScreenUnlocked: isScreenUnlocked,
}
}
// Do executes Emulation.setIdleOverride against the provided context.
func (p *SetIdleOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetIdleOverride, p, nil)
}
// ClearIdleOverrideParams clears Idle state overrides.
type ClearIdleOverrideParams struct{}
// ClearIdleOverride clears Idle state overrides.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearIdleOverride
func ClearIdleOverride() *ClearIdleOverrideParams {
return &ClearIdleOverrideParams{}
}
// Do executes Emulation.clearIdleOverride against the provided context.
func (p *ClearIdleOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearIdleOverride, nil, nil)
}
// SetPageScaleFactorParams sets a specified page scale factor.
type SetPageScaleFactorParams struct {
PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor.
@@ -643,6 +691,28 @@ func (p *SetTimezoneOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetTimezoneOverride, p, nil)
}
// SetDisabledImageTypesParams [no description].
type SetDisabledImageTypesParams struct {
ImageTypes []DisabledImageType `json:"imageTypes"` // Image types to disable.
}
// SetDisabledImageTypes [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDisabledImageTypes
//
// parameters:
// imageTypes - Image types to disable.
func SetDisabledImageTypes(imageTypes []DisabledImageType) *SetDisabledImageTypesParams {
return &SetDisabledImageTypesParams{
ImageTypes: imageTypes,
}
}
// Do executes Emulation.setDisabledImageTypes against the provided context.
func (p *SetDisabledImageTypesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDisabledImageTypes, p, nil)
}
// SetUserAgentOverrideParams allows overriding user agent with the given
// string.
type SetUserAgentOverrideParams struct {
@@ -704,11 +774,14 @@ const (
CommandSetEmulatedMedia = "Emulation.setEmulatedMedia"
CommandSetEmulatedVisionDeficiency = "Emulation.setEmulatedVisionDeficiency"
CommandSetGeolocationOverride = "Emulation.setGeolocationOverride"
CommandSetIdleOverride = "Emulation.setIdleOverride"
CommandClearIdleOverride = "Emulation.clearIdleOverride"
CommandSetPageScaleFactor = "Emulation.setPageScaleFactor"
CommandSetScriptExecutionDisabled = "Emulation.setScriptExecutionDisabled"
CommandSetTouchEmulationEnabled = "Emulation.setTouchEmulationEnabled"
CommandSetVirtualTimePolicy = "Emulation.setVirtualTimePolicy"
CommandSetLocaleOverride = "Emulation.setLocaleOverride"
CommandSetTimezoneOverride = "Emulation.setTimezoneOverride"
CommandSetDisabledImageTypes = "Emulation.setDisabledImageTypes"
CommandSetUserAgentOverride = "Emulation.setUserAgentOverride"
)

View File

@@ -18,6 +18,15 @@ type ScreenOrientation struct {
Angle int64 `json:"angle"` // Orientation angle.
}
// DisplayFeature [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-DisplayFeature
type DisplayFeature struct {
Orientation DisplayFeatureOrientation `json:"orientation"` // Orientation of a display feature in relation to screen
Offset int64 `json:"offset"` // The offset from the screen origin in either the x (for vertical orientation) or y (for horizontal orientation) direction.
MaskLength int64 `json:"maskLength"` // A display feature may mask content such that it is not physically displayed - this length along with the offset describes this area. A display feature that only splits content will have a 0 mask_length.
}
// MediaFeature [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-MediaFeature
@@ -87,12 +96,13 @@ type UserAgentBrandVersion struct {
}
// UserAgentMetadata used to specify User Agent Cient Hints to emulate. See
// https://wicg.github.io/ua-client-hints.
// https://wicg.github.io/ua-client-hints Missing optional values will be filled
// in by the target with what it would normally use.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-UserAgentMetadata
type UserAgentMetadata struct {
Brands []*UserAgentBrandVersion `json:"brands"`
FullVersion string `json:"fullVersion"`
Brands []*UserAgentBrandVersion `json:"brands,omitempty"`
FullVersion string `json:"fullVersion,omitempty"`
Platform string `json:"platform"`
PlatformVersion string `json:"platformVersion"`
Architecture string `json:"architecture"`
@@ -100,6 +110,53 @@ type UserAgentMetadata struct {
Mobile bool `json:"mobile"`
}
// DisabledImageType enum of image types that can be disabled.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-DisabledImageType
type DisabledImageType string
// String returns the DisabledImageType as string value.
func (t DisabledImageType) String() string {
return string(t)
}
// DisabledImageType values.
const (
DisabledImageTypeAvif DisabledImageType = "avif"
DisabledImageTypeJxl DisabledImageType = "jxl"
DisabledImageTypeWebp DisabledImageType = "webp"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DisabledImageType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DisabledImageType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DisabledImageType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DisabledImageType(in.String()) {
case DisabledImageTypeAvif:
*t = DisabledImageTypeAvif
case DisabledImageTypeJxl:
*t = DisabledImageTypeJxl
case DisabledImageTypeWebp:
*t = DisabledImageTypeWebp
default:
in.AddError(errors.New("unknown DisabledImageType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DisabledImageType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// OrientationType orientation type.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-ScreenOrientation
@@ -150,6 +207,51 @@ func (t *OrientationType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// DisplayFeatureOrientation orientation of a display feature in relation to
// screen.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-DisplayFeature
type DisplayFeatureOrientation string
// String returns the DisplayFeatureOrientation as string value.
func (t DisplayFeatureOrientation) String() string {
return string(t)
}
// DisplayFeatureOrientation values.
const (
DisplayFeatureOrientationVertical DisplayFeatureOrientation = "vertical"
DisplayFeatureOrientationHorizontal DisplayFeatureOrientation = "horizontal"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DisplayFeatureOrientation) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DisplayFeatureOrientation) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DisplayFeatureOrientation) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch DisplayFeatureOrientation(in.String()) {
case DisplayFeatureOrientationVertical:
*t = DisplayFeatureOrientationVertical
case DisplayFeatureOrientationHorizontal:
*t = DisplayFeatureOrientationHorizontal
default:
in.AddError(errors.New("unknown DisplayFeatureOrientation value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DisplayFeatureOrientation) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// SetEmitTouchEventsForMouseConfiguration touch/gesture events
// configuration. Default: current platform.
//