wdio-electron-service@9.2.1.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. diff --git a/dist/cjs/index.js b/dist/cjs/index.js
  2. index 600092c2e531c2a5a74abf9e4b1a9d8dc20e13ca..0318e15f7dfe80fc6b5342703cac71884f2ca2eb 100644
  3. --- a/dist/cjs/index.js
  4. +++ b/dist/cjs/index.js
  5. @@ -842,12 +842,16 @@ class ElectronCdpBridge extends cdpBridge.CdpBridge {
  6. }
  7. _ElectronCdpBridge_contextId = new WeakMap(), _ElectronCdpBridge_instances = new WeakSet(), _ElectronCdpBridge_getContextIdHandler = function _ElectronCdpBridge_getContextIdHandler() {
  8. return new Promise((resolve, reject) => {
  9. - this.on('Runtime.executionContextCreated', (params) => {
  10. + const onExecutionContextCreated = (params) => {
  11. if (params.context.auxData.isDefault) {
  12. + clearTimeout(timeout);
  13. + this.off('Runtime.executionContextCreated', onExecutionContextCreated);
  14. resolve(params.context.id);
  15. }
  16. - });
  17. - setTimeout(() => {
  18. + };
  19. + this.on('Runtime.executionContextCreated', onExecutionContextCreated);
  20. + const timeout = setTimeout(() => {
  21. + this.off('Runtime.executionContextCreated', onExecutionContextCreated);
  22. const err = new Error('Timeout exceeded to get the ContextId.');
  23. log$7.error(err.message);
  24. reject(err);
  25. diff --git a/dist/esm/index.js b/dist/esm/index.js
  26. index 68e76a2c4a87f0d6da3fbae2afbf55dbbd8d0548..a2896bdefd08fc0cca3a630c65f502090a3407a3 100644
  27. --- a/dist/esm/index.js
  28. +++ b/dist/esm/index.js
  29. @@ -819,12 +819,16 @@ class ElectronCdpBridge extends CdpBridge {
  30. }
  31. _ElectronCdpBridge_contextId = new WeakMap(), _ElectronCdpBridge_instances = new WeakSet(), _ElectronCdpBridge_getContextIdHandler = function _ElectronCdpBridge_getContextIdHandler() {
  32. return new Promise((resolve, reject) => {
  33. - this.on('Runtime.executionContextCreated', (params) => {
  34. + const onExecutionContextCreated = (params) => {
  35. if (params.context.auxData.isDefault) {
  36. + clearTimeout(timeout);
  37. + this.off('Runtime.executionContextCreated', onExecutionContextCreated);
  38. resolve(params.context.id);
  39. }
  40. - });
  41. - setTimeout(() => {
  42. + };
  43. + this.on('Runtime.executionContextCreated', onExecutionContextCreated);
  44. + const timeout = setTimeout(() => {
  45. + this.off('Runtime.executionContextCreated', onExecutionContextCreated);
  46. const err = new Error('Timeout exceeded to get the ContextId.');
  47. log$7.error(err.message);
  48. reject(err);