worker.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {Arg, RetVal, generateActorSpec} = require("devtools/shared/protocol");
  6. const workerSpec = generateActorSpec({
  7. typeName: "worker",
  8. methods: {
  9. attach: {
  10. request: {},
  11. response: RetVal("json")
  12. },
  13. detach: {
  14. request: {},
  15. response: RetVal("json")
  16. },
  17. connect: {
  18. request: {
  19. options: Arg(0, "json"),
  20. },
  21. response: RetVal("json")
  22. },
  23. push: {
  24. request: {},
  25. response: RetVal("json")
  26. },
  27. },
  28. });
  29. exports.workerSpec = workerSpec;
  30. const pushSubscriptionSpec = generateActorSpec({
  31. typeName: "pushSubscription",
  32. });
  33. exports.pushSubscriptionSpec = pushSubscriptionSpec;
  34. const serviceWorkerRegistrationSpec = generateActorSpec({
  35. typeName: "serviceWorkerRegistration",
  36. events: {
  37. "push-subscription-modified": {
  38. type: "push-subscription-modified"
  39. },
  40. "registration-changed": {
  41. type: "registration-changed"
  42. }
  43. },
  44. methods: {
  45. start: {
  46. request: {},
  47. response: RetVal("json")
  48. },
  49. unregister: {
  50. request: {},
  51. response: RetVal("json")
  52. },
  53. getPushSubscription: {
  54. request: {},
  55. response: {
  56. subscription: RetVal("nullable:pushSubscription")
  57. }
  58. },
  59. },
  60. });
  61. exports.serviceWorkerRegistrationSpec = serviceWorkerRegistrationSpec;
  62. const serviceWorkerSpec = generateActorSpec({
  63. typeName: "serviceWorker",
  64. });
  65. exports.serviceWorkerSpec = serviceWorkerSpec;