serviceworker.go 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. // Package serviceworker provides the Chrome DevTools Protocol
  2. // commands, types, and events for the ServiceWorker domain.
  3. //
  4. // Generated by the cdproto-gen command.
  5. package serviceworker
  6. // Code generated by cdproto-gen. DO NOT EDIT.
  7. import (
  8. "context"
  9. "github.com/chromedp/cdproto/cdp"
  10. )
  11. // DeliverPushMessageParams [no description].
  12. type DeliverPushMessageParams struct {
  13. Origin string `json:"origin"`
  14. RegistrationID RegistrationID `json:"registrationId"`
  15. Data string `json:"data"`
  16. }
  17. // DeliverPushMessage [no description].
  18. //
  19. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-deliverPushMessage
  20. //
  21. // parameters:
  22. //
  23. // origin
  24. // registrationID
  25. // data
  26. func DeliverPushMessage(origin string, registrationID RegistrationID, data string) *DeliverPushMessageParams {
  27. return &DeliverPushMessageParams{
  28. Origin: origin,
  29. RegistrationID: registrationID,
  30. Data: data,
  31. }
  32. }
  33. // Do executes ServiceWorker.deliverPushMessage against the provided context.
  34. func (p *DeliverPushMessageParams) Do(ctx context.Context) (err error) {
  35. return cdp.Execute(ctx, CommandDeliverPushMessage, p, nil)
  36. }
  37. // DisableParams [no description].
  38. type DisableParams struct{}
  39. // Disable [no description].
  40. //
  41. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-disable
  42. func Disable() *DisableParams {
  43. return &DisableParams{}
  44. }
  45. // Do executes ServiceWorker.disable against the provided context.
  46. func (p *DisableParams) Do(ctx context.Context) (err error) {
  47. return cdp.Execute(ctx, CommandDisable, nil, nil)
  48. }
  49. // DispatchSyncEventParams [no description].
  50. type DispatchSyncEventParams struct {
  51. Origin string `json:"origin"`
  52. RegistrationID RegistrationID `json:"registrationId"`
  53. Tag string `json:"tag"`
  54. LastChance bool `json:"lastChance"`
  55. }
  56. // DispatchSyncEvent [no description].
  57. //
  58. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-dispatchSyncEvent
  59. //
  60. // parameters:
  61. //
  62. // origin
  63. // registrationID
  64. // tag
  65. // lastChance
  66. func DispatchSyncEvent(origin string, registrationID RegistrationID, tag string, lastChance bool) *DispatchSyncEventParams {
  67. return &DispatchSyncEventParams{
  68. Origin: origin,
  69. RegistrationID: registrationID,
  70. Tag: tag,
  71. LastChance: lastChance,
  72. }
  73. }
  74. // Do executes ServiceWorker.dispatchSyncEvent against the provided context.
  75. func (p *DispatchSyncEventParams) Do(ctx context.Context) (err error) {
  76. return cdp.Execute(ctx, CommandDispatchSyncEvent, p, nil)
  77. }
  78. // DispatchPeriodicSyncEventParams [no description].
  79. type DispatchPeriodicSyncEventParams struct {
  80. Origin string `json:"origin"`
  81. RegistrationID RegistrationID `json:"registrationId"`
  82. Tag string `json:"tag"`
  83. }
  84. // DispatchPeriodicSyncEvent [no description].
  85. //
  86. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-dispatchPeriodicSyncEvent
  87. //
  88. // parameters:
  89. //
  90. // origin
  91. // registrationID
  92. // tag
  93. func DispatchPeriodicSyncEvent(origin string, registrationID RegistrationID, tag string) *DispatchPeriodicSyncEventParams {
  94. return &DispatchPeriodicSyncEventParams{
  95. Origin: origin,
  96. RegistrationID: registrationID,
  97. Tag: tag,
  98. }
  99. }
  100. // Do executes ServiceWorker.dispatchPeriodicSyncEvent against the provided context.
  101. func (p *DispatchPeriodicSyncEventParams) Do(ctx context.Context) (err error) {
  102. return cdp.Execute(ctx, CommandDispatchPeriodicSyncEvent, p, nil)
  103. }
  104. // EnableParams [no description].
  105. type EnableParams struct{}
  106. // Enable [no description].
  107. //
  108. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-enable
  109. func Enable() *EnableParams {
  110. return &EnableParams{}
  111. }
  112. // Do executes ServiceWorker.enable against the provided context.
  113. func (p *EnableParams) Do(ctx context.Context) (err error) {
  114. return cdp.Execute(ctx, CommandEnable, nil, nil)
  115. }
  116. // InspectWorkerParams [no description].
  117. type InspectWorkerParams struct {
  118. VersionID string `json:"versionId"`
  119. }
  120. // InspectWorker [no description].
  121. //
  122. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-inspectWorker
  123. //
  124. // parameters:
  125. //
  126. // versionID
  127. func InspectWorker(versionID string) *InspectWorkerParams {
  128. return &InspectWorkerParams{
  129. VersionID: versionID,
  130. }
  131. }
  132. // Do executes ServiceWorker.inspectWorker against the provided context.
  133. func (p *InspectWorkerParams) Do(ctx context.Context) (err error) {
  134. return cdp.Execute(ctx, CommandInspectWorker, p, nil)
  135. }
  136. // SetForceUpdateOnPageLoadParams [no description].
  137. type SetForceUpdateOnPageLoadParams struct {
  138. ForceUpdateOnPageLoad bool `json:"forceUpdateOnPageLoad"`
  139. }
  140. // SetForceUpdateOnPageLoad [no description].
  141. //
  142. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-setForceUpdateOnPageLoad
  143. //
  144. // parameters:
  145. //
  146. // forceUpdateOnPageLoad
  147. func SetForceUpdateOnPageLoad(forceUpdateOnPageLoad bool) *SetForceUpdateOnPageLoadParams {
  148. return &SetForceUpdateOnPageLoadParams{
  149. ForceUpdateOnPageLoad: forceUpdateOnPageLoad,
  150. }
  151. }
  152. // Do executes ServiceWorker.setForceUpdateOnPageLoad against the provided context.
  153. func (p *SetForceUpdateOnPageLoadParams) Do(ctx context.Context) (err error) {
  154. return cdp.Execute(ctx, CommandSetForceUpdateOnPageLoad, p, nil)
  155. }
  156. // SkipWaitingParams [no description].
  157. type SkipWaitingParams struct {
  158. ScopeURL string `json:"scopeURL"`
  159. }
  160. // SkipWaiting [no description].
  161. //
  162. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-skipWaiting
  163. //
  164. // parameters:
  165. //
  166. // scopeURL
  167. func SkipWaiting(scopeURL string) *SkipWaitingParams {
  168. return &SkipWaitingParams{
  169. ScopeURL: scopeURL,
  170. }
  171. }
  172. // Do executes ServiceWorker.skipWaiting against the provided context.
  173. func (p *SkipWaitingParams) Do(ctx context.Context) (err error) {
  174. return cdp.Execute(ctx, CommandSkipWaiting, p, nil)
  175. }
  176. // StartWorkerParams [no description].
  177. type StartWorkerParams struct {
  178. ScopeURL string `json:"scopeURL"`
  179. }
  180. // StartWorker [no description].
  181. //
  182. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-startWorker
  183. //
  184. // parameters:
  185. //
  186. // scopeURL
  187. func StartWorker(scopeURL string) *StartWorkerParams {
  188. return &StartWorkerParams{
  189. ScopeURL: scopeURL,
  190. }
  191. }
  192. // Do executes ServiceWorker.startWorker against the provided context.
  193. func (p *StartWorkerParams) Do(ctx context.Context) (err error) {
  194. return cdp.Execute(ctx, CommandStartWorker, p, nil)
  195. }
  196. // StopAllWorkersParams [no description].
  197. type StopAllWorkersParams struct{}
  198. // StopAllWorkers [no description].
  199. //
  200. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-stopAllWorkers
  201. func StopAllWorkers() *StopAllWorkersParams {
  202. return &StopAllWorkersParams{}
  203. }
  204. // Do executes ServiceWorker.stopAllWorkers against the provided context.
  205. func (p *StopAllWorkersParams) Do(ctx context.Context) (err error) {
  206. return cdp.Execute(ctx, CommandStopAllWorkers, nil, nil)
  207. }
  208. // StopWorkerParams [no description].
  209. type StopWorkerParams struct {
  210. VersionID string `json:"versionId"`
  211. }
  212. // StopWorker [no description].
  213. //
  214. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-stopWorker
  215. //
  216. // parameters:
  217. //
  218. // versionID
  219. func StopWorker(versionID string) *StopWorkerParams {
  220. return &StopWorkerParams{
  221. VersionID: versionID,
  222. }
  223. }
  224. // Do executes ServiceWorker.stopWorker against the provided context.
  225. func (p *StopWorkerParams) Do(ctx context.Context) (err error) {
  226. return cdp.Execute(ctx, CommandStopWorker, p, nil)
  227. }
  228. // UnregisterParams [no description].
  229. type UnregisterParams struct {
  230. ScopeURL string `json:"scopeURL"`
  231. }
  232. // Unregister [no description].
  233. //
  234. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-unregister
  235. //
  236. // parameters:
  237. //
  238. // scopeURL
  239. func Unregister(scopeURL string) *UnregisterParams {
  240. return &UnregisterParams{
  241. ScopeURL: scopeURL,
  242. }
  243. }
  244. // Do executes ServiceWorker.unregister against the provided context.
  245. func (p *UnregisterParams) Do(ctx context.Context) (err error) {
  246. return cdp.Execute(ctx, CommandUnregister, p, nil)
  247. }
  248. // UpdateRegistrationParams [no description].
  249. type UpdateRegistrationParams struct {
  250. ScopeURL string `json:"scopeURL"`
  251. }
  252. // UpdateRegistration [no description].
  253. //
  254. // See: https://chromedevtools.github.io/devtools-protocol/tot/ServiceWorker#method-updateRegistration
  255. //
  256. // parameters:
  257. //
  258. // scopeURL
  259. func UpdateRegistration(scopeURL string) *UpdateRegistrationParams {
  260. return &UpdateRegistrationParams{
  261. ScopeURL: scopeURL,
  262. }
  263. }
  264. // Do executes ServiceWorker.updateRegistration against the provided context.
  265. func (p *UpdateRegistrationParams) Do(ctx context.Context) (err error) {
  266. return cdp.Execute(ctx, CommandUpdateRegistration, p, nil)
  267. }
  268. // Command names.
  269. const (
  270. CommandDeliverPushMessage = "ServiceWorker.deliverPushMessage"
  271. CommandDisable = "ServiceWorker.disable"
  272. CommandDispatchSyncEvent = "ServiceWorker.dispatchSyncEvent"
  273. CommandDispatchPeriodicSyncEvent = "ServiceWorker.dispatchPeriodicSyncEvent"
  274. CommandEnable = "ServiceWorker.enable"
  275. CommandInspectWorker = "ServiceWorker.inspectWorker"
  276. CommandSetForceUpdateOnPageLoad = "ServiceWorker.setForceUpdateOnPageLoad"
  277. CommandSkipWaiting = "ServiceWorker.skipWaiting"
  278. CommandStartWorker = "ServiceWorker.startWorker"
  279. CommandStopAllWorkers = "ServiceWorker.stopAllWorkers"
  280. CommandStopWorker = "ServiceWorker.stopWorker"
  281. CommandUnregister = "ServiceWorker.unregister"
  282. CommandUpdateRegistration = "ServiceWorker.updateRegistration"
  283. )