diff --git a/cdproto.go b/cdproto.go index 74d3258..e9253c6 100644 --- a/cdproto.go +++ b/cdproto.go @@ -549,6 +549,8 @@ const ( EventOverlayScreenshotRequested = "Overlay.screenshotRequested" EventOverlayInspectModeCanceled = "Overlay.inspectModeCanceled" CommandPWAGetOsAppState = pwa.CommandGetOsAppState + CommandPWAInstall = pwa.CommandInstall + CommandPWAUninstall = pwa.CommandUninstall CommandPageAddScriptToEvaluateOnNewDocument = page.CommandAddScriptToEvaluateOnNewDocument CommandPageBringToFront = page.CommandBringToFront CommandPageCaptureScreenshot = page.CommandCaptureScreenshot @@ -2243,6 +2245,12 @@ func UnmarshalMessage(msg *Message) (interface{}, error) { case CommandPWAGetOsAppState: v = new(pwa.GetOsAppStateReturns) + case CommandPWAInstall: + return emptyVal, nil + + case CommandPWAUninstall: + return emptyVal, nil + case CommandPageAddScriptToEvaluateOnNewDocument: v = new(page.AddScriptToEvaluateOnNewDocumentReturns) diff --git a/network/easyjson.go b/network/easyjson.go index 988de72..487b72a 100644 --- a/network/easyjson.go +++ b/network/easyjson.go @@ -2271,14 +2271,20 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork21(out *jwriter.Writer out.RawByte('{') first := true _ = first - { + if in.RuleIDMatched != 0 { const prefix string = ",\"ruleIdMatched\":" + first = false out.RawString(prefix[1:]) out.Int64(int64(in.RuleIDMatched)) } - { + if in.MatchedSourceType != "" { const prefix string = ",\"matchedSourceType\":" - out.RawString(prefix) + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } (in.MatchedSourceType).MarshalEasyJSON(out) } out.RawByte('}') diff --git a/network/types.go b/network/types.go index c334fb1..8a1462c 100644 --- a/network/types.go +++ b/network/types.go @@ -1071,8 +1071,8 @@ func (t *ServiceWorkerRouterSource) UnmarshalJSON(buf []byte) error { // // See: https://chromedevtools.github.io/devtools-protocol/tot/Network#type-ServiceWorkerRouterInfo type ServiceWorkerRouterInfo struct { - RuleIDMatched int64 `json:"ruleIdMatched"` - MatchedSourceType ServiceWorkerRouterSource `json:"matchedSourceType"` + RuleIDMatched int64 `json:"ruleIdMatched,omitempty"` // ID of the rule matched. If there is a matched rule, this field will be set, otherwiser no value will be set. + MatchedSourceType ServiceWorkerRouterSource `json:"matchedSourceType,omitempty"` // The router source of the matched rule. If there is a matched rule, this field will be set, otherwise no value will be set. } // Response HTTP response data. @@ -1094,7 +1094,7 @@ type Response struct { FromServiceWorker bool `json:"fromServiceWorker,omitempty"` // Specifies that the request was served from the ServiceWorker. FromPrefetchCache bool `json:"fromPrefetchCache,omitempty"` // Specifies that the request was served from the prefetch cache. FromEarlyHints bool `json:"fromEarlyHints,omitempty"` // Specifies that the request was served from the prefetch cache. - ServiceWorkerRouterInfo *ServiceWorkerRouterInfo `json:"serviceWorkerRouterInfo,omitempty"` // Information about how Service Worker Static Router was used. + ServiceWorkerRouterInfo *ServiceWorkerRouterInfo `json:"serviceWorkerRouterInfo,omitempty"` // Information about how ServiceWorker Static Router API was used. If this field is set with matchedSourceType field, a matching rule is found. If this field is set without matchedSource, no matching rule is found. Otherwise, the API is not used. EncodedDataLength float64 `json:"encodedDataLength"` // Total number of bytes received for this request so far. Timing *ResourceTiming `json:"timing,omitempty"` // Timing information for the given request. ServiceWorkerResponseSource ServiceWorkerResponseSource `json:"serviceWorkerResponseSource,omitempty"` // Response source of response from ServiceWorker. diff --git a/page/types.go b/page/types.go index af18db0..dbb230b 100644 --- a/page/types.go +++ b/page/types.go @@ -119,7 +119,6 @@ const ( PermissionsPolicyFeatureWebPrinting PermissionsPolicyFeature = "web-printing" PermissionsPolicyFeatureWebShare PermissionsPolicyFeature = "web-share" PermissionsPolicyFeatureWindowManagement PermissionsPolicyFeature = "window-management" - PermissionsPolicyFeatureWindowPlacement PermissionsPolicyFeature = "window-placement" PermissionsPolicyFeatureXrSpatialTracking PermissionsPolicyFeature = "xr-spatial-tracking" ) @@ -303,8 +302,6 @@ func (t *PermissionsPolicyFeature) UnmarshalEasyJSON(in *jlexer.Lexer) { *t = PermissionsPolicyFeatureWebShare case PermissionsPolicyFeatureWindowManagement: *t = PermissionsPolicyFeatureWindowManagement - case PermissionsPolicyFeatureWindowPlacement: - *t = PermissionsPolicyFeatureWindowPlacement case PermissionsPolicyFeatureXrSpatialTracking: *t = PermissionsPolicyFeatureXrSpatialTracking diff --git a/pwa/easyjson.go b/pwa/easyjson.go index fdb2702..ca44d80 100644 --- a/pwa/easyjson.go +++ b/pwa/easyjson.go @@ -17,7 +17,146 @@ var ( _ easyjson.Marshaler ) -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(in *jlexer.Lexer, out *GetOsAppStateReturns) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(in *jlexer.Lexer, out *UninstallParams) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "manifestId": + out.ManifestID = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(out *jwriter.Writer, in UninstallParams) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"manifestId\":" + out.RawString(prefix[1:]) + out.String(string(in.ManifestID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v UninstallParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v UninstallParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *UninstallParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *UninstallParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(l, v) +} +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(in *jlexer.Lexer, out *InstallParams) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "manifestId": + out.ManifestID = string(in.String()) + case "installUrlOrBundleUrl": + out.InstallURLOrBundleURL = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(out *jwriter.Writer, in InstallParams) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"manifestId\":" + out.RawString(prefix[1:]) + out.String(string(in.ManifestID)) + } + if in.InstallURLOrBundleURL != "" { + const prefix string = ",\"installUrlOrBundleUrl\":" + out.RawString(prefix) + out.String(string(in.InstallURLOrBundleURL)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v InstallParams) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v InstallParams) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *InstallParams) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *InstallParams) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(l, v) +} +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(in *jlexer.Lexer, out *GetOsAppStateReturns) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -79,7 +218,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(in *jlexer.Lexer, out *Ge in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(out *jwriter.Writer, in GetOsAppStateReturns) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(out *jwriter.Writer, in GetOsAppStateReturns) { out.RawByte('{') first := true _ = first @@ -118,27 +257,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(out *jwriter.Writer, in G // MarshalJSON supports json.Marshaler interface func (v GetOsAppStateReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v GetOsAppStateReturns) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *GetOsAppStateReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *GetOsAppStateReturns) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(in *jlexer.Lexer, out *GetOsAppStateParams) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *GetOsAppStateParams) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -169,7 +308,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(in *jlexer.Lexer, out *G in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(out *jwriter.Writer, in GetOsAppStateParams) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in GetOsAppStateParams) { out.RawByte('{') first := true _ = first @@ -184,27 +323,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v GetOsAppStateParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v GetOsAppStateParams) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa1(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *GetOsAppStateParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *GetOsAppStateParams) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa1(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(in *jlexer.Lexer, out *FileHandlerAccept) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(in *jlexer.Lexer, out *FileHandlerAccept) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -258,7 +397,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(in *jlexer.Lexer, out *F in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(out *jwriter.Writer, in FileHandlerAccept) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(out *jwriter.Writer, in FileHandlerAccept) { out.RawByte('{') first := true _ = first @@ -289,27 +428,27 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v FileHandlerAccept) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v FileHandlerAccept) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa2(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa4(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *FileHandlerAccept) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *FileHandlerAccept) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa2(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa4(l, v) } -func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *FileHandler) { +func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(in *jlexer.Lexer, out *FileHandler) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -373,7 +512,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(in *jlexer.Lexer, out *F in.Consumed() } } -func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in FileHandler) { +func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(out *jwriter.Writer, in FileHandler) { out.RawByte('{') first := true _ = first @@ -413,23 +552,23 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v FileHandler) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(&w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v FileHandler) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa3(w, v) + easyjsonC5a4559bEncodeGithubComChromedpCdprotoPwa5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *FileHandler) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(&r, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *FileHandler) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa3(l, v) + easyjsonC5a4559bDecodeGithubComChromedpCdprotoPwa5(l, v) } diff --git a/pwa/pwa.go b/pwa/pwa.go index 856e562..2c280c4 100644 --- a/pwa/pwa.go +++ b/pwa/pwa.go @@ -56,7 +56,79 @@ func (p *GetOsAppStateParams) Do(ctx context.Context) (badgeCount int64, fileHan return res.BadgeCount, res.FileHandlers, nil } +// InstallParams installs the given manifest identity, optionally using the +// given install_url or IWA bundle location. TODO(crbug.com/337872319) Support +// IWA to meet the following specific requirement. IWA-specific install +// description: If the manifest_id is isolated-app://, install_url_or_bundle_url +// is required, and can be either an http(s) URL or file:// URL pointing to a +// signed web bundle (.swbn). The .swbn file's signing key must correspond to +// manifest_id. If Chrome is not in IWA dev mode, the installation will fail, +// regardless of the state of the allowlist. +type InstallParams struct { + ManifestID string `json:"manifestId"` + InstallURLOrBundleURL string `json:"installUrlOrBundleUrl,omitempty"` // The location of the app or bundle overriding the one derived from the manifestId. +} + +// Install installs the given manifest identity, optionally using the given +// install_url or IWA bundle location. TODO(crbug.com/337872319) Support IWA to +// meet the following specific requirement. IWA-specific install description: If +// the manifest_id is isolated-app://, install_url_or_bundle_url is required, +// and can be either an http(s) URL or file:// URL pointing to a signed web +// bundle (.swbn). The .swbn file's signing key must correspond to manifest_id. +// If Chrome is not in IWA dev mode, the installation will fail, regardless of +// the state of the allowlist. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/PWA#method-install +// +// parameters: +// +// manifestID +func Install(manifestID string) *InstallParams { + return &InstallParams{ + ManifestID: manifestID, + } +} + +// WithInstallURLOrBundleURL the location of the app or bundle overriding the +// one derived from the manifestId. +func (p InstallParams) WithInstallURLOrBundleURL(installURLOrBundleURL string) *InstallParams { + p.InstallURLOrBundleURL = installURLOrBundleURL + return &p +} + +// Do executes PWA.install against the provided context. +func (p *InstallParams) Do(ctx context.Context) (err error) { + return cdp.Execute(ctx, CommandInstall, p, nil) +} + +// UninstallParams uninstals the given manifest_id and closes any opened app +// windows. +type UninstallParams struct { + ManifestID string `json:"manifestId"` +} + +// Uninstall uninstals the given manifest_id and closes any opened app +// windows. +// +// See: https://chromedevtools.github.io/devtools-protocol/tot/PWA#method-uninstall +// +// parameters: +// +// manifestID +func Uninstall(manifestID string) *UninstallParams { + return &UninstallParams{ + ManifestID: manifestID, + } +} + +// Do executes PWA.uninstall against the provided context. +func (p *UninstallParams) Do(ctx context.Context) (err error) { + return cdp.Execute(ctx, CommandUninstall, p, nil) +} + // Command names. const ( CommandGetOsAppState = "PWA.getOsAppState" + CommandInstall = "PWA.install" + CommandUninstall = "PWA.uninstall" )