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

View File

@@ -483,6 +483,73 @@ func (p *GetStyleSheetTextParams) Do(ctx context.Context) (text string, err erro
return res.Text, nil
}
// TrackComputedStyleUpdatesParams starts tracking the given computed styles
// for updates. The specified array of properties replaces the one previously
// specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
// to retrieve the list of nodes that had properties modified. The changes to
// computed style properties are only tracked for nodes pushed to the front-end
// by the DOM agent. If no changes to the tracked properties occur after the
// node has been pushed to the front-end, no updates will be issued for the
// node.
type TrackComputedStyleUpdatesParams struct {
PropertiesToTrack []*ComputedStyleProperty `json:"propertiesToTrack"`
}
// TrackComputedStyleUpdates starts tracking the given computed styles for
// updates. The specified array of properties replaces the one previously
// specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
// to retrieve the list of nodes that had properties modified. The changes to
// computed style properties are only tracked for nodes pushed to the front-end
// by the DOM agent. If no changes to the tracked properties occur after the
// node has been pushed to the front-end, no updates will be issued for the
// node.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-trackComputedStyleUpdates
//
// parameters:
// propertiesToTrack
func TrackComputedStyleUpdates(propertiesToTrack []*ComputedStyleProperty) *TrackComputedStyleUpdatesParams {
return &TrackComputedStyleUpdatesParams{
PropertiesToTrack: propertiesToTrack,
}
}
// Do executes CSS.trackComputedStyleUpdates against the provided context.
func (p *TrackComputedStyleUpdatesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandTrackComputedStyleUpdates, p, nil)
}
// TakeComputedStyleUpdatesParams polls the next batch of computed style
// updates.
type TakeComputedStyleUpdatesParams struct{}
// TakeComputedStyleUpdates polls the next batch of computed style updates.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeComputedStyleUpdates
func TakeComputedStyleUpdates() *TakeComputedStyleUpdatesParams {
return &TakeComputedStyleUpdatesParams{}
}
// TakeComputedStyleUpdatesReturns return values.
type TakeComputedStyleUpdatesReturns struct {
NodeIds []cdp.NodeID `json:"nodeIds,omitempty"` // The list of node Ids that have their tracked computed styles updated
}
// Do executes CSS.takeComputedStyleUpdates against the provided context.
//
// returns:
// nodeIds - The list of node Ids that have their tracked computed styles updated
func (p *TakeComputedStyleUpdatesParams) Do(ctx context.Context) (nodeIds []cdp.NodeID, err error) {
// execute
var res TakeComputedStyleUpdatesReturns
err = cdp.Execute(ctx, CommandTakeComputedStyleUpdates, nil, &res)
if err != nil {
return nil, err
}
return res.NodeIds, nil
}
// SetEffectivePropertyValueForNodeParams find a rule with the given active
// property for the given node and set the new value for this property.
type SetEffectivePropertyValueForNodeParams struct {
@@ -599,6 +666,49 @@ func (p *SetMediaTextParams) Do(ctx context.Context) (media *Media, err error) {
return res.Media, nil
}
// SetContainerQueryTextParams modifies the expression of a container query.
type SetContainerQueryTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
Text string `json:"text"`
}
// SetContainerQueryText modifies the expression of a container query.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setContainerQueryText
//
// parameters:
// styleSheetID
// range
// text
func SetContainerQueryText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetContainerQueryTextParams {
return &SetContainerQueryTextParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Text: text,
}
}
// SetContainerQueryTextReturns return values.
type SetContainerQueryTextReturns struct {
ContainerQuery *ContainerQuery `json:"containerQuery,omitempty"` // The resulting CSS container query rule after modification.
}
// Do executes CSS.setContainerQueryText against the provided context.
//
// returns:
// containerQuery - The resulting CSS container query rule after modification.
func (p *SetContainerQueryTextParams) Do(ctx context.Context) (containerQuery *ContainerQuery, err error) {
// execute
var res SetContainerQueryTextReturns
err = cdp.Execute(ctx, CommandSetContainerQueryText, p, &res)
if err != nil {
return nil, err
}
return res.ContainerQuery, nil
}
// SetRuleSelectorParams modifies the rule selector.
type SetRuleSelectorParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
@@ -804,6 +914,30 @@ func (p *TakeCoverageDeltaParams) Do(ctx context.Context) (coverage []*RuleUsage
return res.Coverage, res.Timestamp, nil
}
// SetLocalFontsEnabledParams enables/disables rendering of local CSS fonts
// (enabled by default).
type SetLocalFontsEnabledParams struct {
Enabled bool `json:"enabled"` // Whether rendering of local fonts is enabled.
}
// SetLocalFontsEnabled enables/disables rendering of local CSS fonts
// (enabled by default).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setLocalFontsEnabled
//
// parameters:
// enabled - Whether rendering of local fonts is enabled.
func SetLocalFontsEnabled(enabled bool) *SetLocalFontsEnabledParams {
return &SetLocalFontsEnabledParams{
Enabled: enabled,
}
}
// Do executes CSS.setLocalFontsEnabled against the provided context.
func (p *SetLocalFontsEnabledParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetLocalFontsEnabled, p, nil)
}
// Command names.
const (
CommandAddRule = "CSS.addRule"
@@ -819,13 +953,17 @@ const (
CommandGetMediaQueries = "CSS.getMediaQueries"
CommandGetPlatformFontsForNode = "CSS.getPlatformFontsForNode"
CommandGetStyleSheetText = "CSS.getStyleSheetText"
CommandTrackComputedStyleUpdates = "CSS.trackComputedStyleUpdates"
CommandTakeComputedStyleUpdates = "CSS.takeComputedStyleUpdates"
CommandSetEffectivePropertyValueForNode = "CSS.setEffectivePropertyValueForNode"
CommandSetKeyframeKey = "CSS.setKeyframeKey"
CommandSetMediaText = "CSS.setMediaText"
CommandSetContainerQueryText = "CSS.setContainerQueryText"
CommandSetRuleSelector = "CSS.setRuleSelector"
CommandSetStyleSheetText = "CSS.setStyleSheetText"
CommandSetStyleTexts = "CSS.setStyleTexts"
CommandStartRuleUsageTracking = "CSS.startRuleUsageTracking"
CommandStopRuleUsageTracking = "CSS.stopRuleUsageTracking"
CommandTakeCoverageDelta = "CSS.takeCoverageDelta"
CommandSetLocalFontsEnabled = "CSS.setLocalFontsEnabled"
)

File diff suppressed because it is too large Load Diff

View File

@@ -119,32 +119,35 @@ type SelectorList struct {
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSStyleSheetHeader
type StyleSheetHeader struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The stylesheet identifier.
FrameID cdp.FrameID `json:"frameId"` // Owner frame identifier.
SourceURL string `json:"sourceURL"` // Stylesheet resource URL.
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with the stylesheet (if any).
Origin StyleSheetOrigin `json:"origin"` // Stylesheet origin.
Title string `json:"title"` // Stylesheet title.
OwnerNode cdp.BackendNodeID `json:"ownerNode,omitempty"` // The backend id for the owner node of the stylesheet.
Disabled bool `json:"disabled"` // Denotes whether the stylesheet is disabled.
HasSourceURL bool `json:"hasSourceURL,omitempty"` // Whether the sourceURL field value comes from the sourceURL comment.
IsInline bool `json:"isInline"` // Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
StartLine float64 `json:"startLine"` // Line offset of the stylesheet within the resource (zero based).
StartColumn float64 `json:"startColumn"` // Column offset of the stylesheet within the resource (zero based).
Length float64 `json:"length"` // Size of the content (in characters).
EndLine float64 `json:"endLine"` // Line offset of the end of the stylesheet within the resource (zero based).
EndColumn float64 `json:"endColumn"` // Column offset of the end of the stylesheet within the resource (zero based).
StyleSheetID StyleSheetID `json:"styleSheetId"` // The stylesheet identifier.
FrameID cdp.FrameID `json:"frameId"` // Owner frame identifier.
SourceURL string `json:"sourceURL"` // Stylesheet resource URL.
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with the stylesheet (if any).
Origin StyleSheetOrigin `json:"origin"` // Stylesheet origin.
Title string `json:"title"` // Stylesheet title.
OwnerNode cdp.BackendNodeID `json:"ownerNode,omitempty"` // The backend id for the owner node of the stylesheet.
Disabled bool `json:"disabled"` // Denotes whether the stylesheet is disabled.
HasSourceURL bool `json:"hasSourceURL,omitempty"` // Whether the sourceURL field value comes from the sourceURL comment.
IsInline bool `json:"isInline"` // Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
IsMutable bool `json:"isMutable"` // Whether this stylesheet is mutable. Inline stylesheets become mutable after they have been modified via CSSOM API. <link> element's stylesheets become mutable only if DevTools modifies them. Constructed stylesheets (new CSSStyleSheet()) are mutable immediately after creation.
IsConstructed bool `json:"isConstructed"` // Whether this stylesheet is a constructed stylesheet (created using new CSSStyleSheet()).
StartLine float64 `json:"startLine"` // Line offset of the stylesheet within the resource (zero based).
StartColumn float64 `json:"startColumn"` // Column offset of the stylesheet within the resource (zero based).
Length float64 `json:"length"` // Size of the content (in characters).
EndLine float64 `json:"endLine"` // Line offset of the end of the stylesheet within the resource (zero based).
EndColumn float64 `json:"endColumn"` // Column offset of the end of the stylesheet within the resource (zero based).
}
// Rule CSS rule representation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSRule
type Rule struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
SelectorList *SelectorList `json:"selectorList"` // Rule selector data.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
Style *Style `json:"style"` // Associated style declaration.
Media []*Media `json:"media,omitempty"` // Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
SelectorList *SelectorList `json:"selectorList"` // Rule selector data.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
Style *Style `json:"style"` // Associated style declaration.
Media []*Media `json:"media,omitempty"` // Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
ContainerQueries []*ContainerQuery `json:"containerQueries,omitempty"` // Container query list array (for rules involving container queries). The array enumerates container queries starting with the innermost one, going outwards.
}
// RuleUsage CSS coverage information.
@@ -240,6 +243,15 @@ type MediaQueryExpression struct {
ComputedLength float64 `json:"computedLength,omitempty"` // Computed length of media query expression (if applicable).
}
// ContainerQuery CSS container query rule descriptor.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSContainerQuery
type ContainerQuery struct {
Text string `json:"text"` // Container query text.
Range *SourceRange `json:"range,omitempty"` // The associated rule header range in the enclosing stylesheet (if available).
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the stylesheet containing this object (if exists).
}
// PlatformFontUsage information about amount of glyphs that were rendered
// with given font.
//
@@ -250,19 +262,33 @@ type PlatformFontUsage struct {
GlyphCount float64 `json:"glyphCount"` // Amount of glyphs that were rendered with this font.
}
// FontVariationAxis information about font variation axes for variable
// fonts.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-FontVariationAxis
type FontVariationAxis struct {
Tag string `json:"tag"` // The font-variation-setting tag (a.k.a. "axis tag").
Name string `json:"name"` // Human-readable variation name in the default language (normally, "en").
MinValue float64 `json:"minValue"` // The minimum value (inclusive) the font supports for this tag.
MaxValue float64 `json:"maxValue"` // The maximum value (inclusive) the font supports for this tag.
DefaultValue float64 `json:"defaultValue"` // The default value.
}
// FontFace properties of a web font:
// https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions.
// https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions and
// additional information such as platformFontFamily and fontVariationAxes.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-FontFace
type FontFace struct {
FontFamily string `json:"fontFamily"` // The font-family.
FontStyle string `json:"fontStyle"` // The font-style.
FontVariant string `json:"fontVariant"` // The font-variant.
FontWeight string `json:"fontWeight"` // The font-weight.
FontStretch string `json:"fontStretch"` // The font-stretch.
UnicodeRange string `json:"unicodeRange"` // The unicode-range.
Src string `json:"src"` // The src.
PlatformFontFamily string `json:"platformFontFamily"` // The resolved platform font family
FontFamily string `json:"fontFamily"` // The font-family.
FontStyle string `json:"fontStyle"` // The font-style.
FontVariant string `json:"fontVariant"` // The font-variant.
FontWeight string `json:"fontWeight"` // The font-weight.
FontStretch string `json:"fontStretch"` // The font-stretch.
UnicodeRange string `json:"unicodeRange"` // The unicode-range.
Src string `json:"src"` // The src.
PlatformFontFamily string `json:"platformFontFamily"` // The resolved platform font family
FontVariationAxes []*FontVariationAxis `json:"fontVariationAxes,omitempty"` // Available variation settings (a.k.a. "axes").
}
// KeyframesRule CSS keyframes rule representation.