timeoutSettings.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.TimeoutSettings = exports.DEFAULT_TIMEOUT = exports.DEFAULT_LAUNCH_TIMEOUT = void 0;
  6. var _utils = require("../utils");
  7. /**
  8. * Copyright 2019 Google Inc. All rights reserved.
  9. * Modifications copyright (c) Microsoft Corporation.
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. const DEFAULT_TIMEOUT = 30000;
  24. exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
  25. const DEFAULT_LAUNCH_TIMEOUT = 3 * 60 * 1000; // 3 minutes
  26. exports.DEFAULT_LAUNCH_TIMEOUT = DEFAULT_LAUNCH_TIMEOUT;
  27. class TimeoutSettings {
  28. constructor(parent) {
  29. this._parent = void 0;
  30. this._defaultTimeout = void 0;
  31. this._defaultNavigationTimeout = void 0;
  32. this._parent = parent;
  33. }
  34. setDefaultTimeout(timeout) {
  35. this._defaultTimeout = timeout;
  36. }
  37. setDefaultNavigationTimeout(timeout) {
  38. this._defaultNavigationTimeout = timeout;
  39. }
  40. defaultNavigationTimeout() {
  41. return this._defaultNavigationTimeout;
  42. }
  43. defaultTimeout() {
  44. return this._defaultTimeout;
  45. }
  46. navigationTimeout(options) {
  47. if (typeof options.timeout === 'number') return options.timeout;
  48. if (this._defaultNavigationTimeout !== undefined) return this._defaultNavigationTimeout;
  49. if ((0, _utils.debugMode)()) return 0;
  50. if (this._defaultTimeout !== undefined) return this._defaultTimeout;
  51. if (this._parent) return this._parent.navigationTimeout(options);
  52. return DEFAULT_TIMEOUT;
  53. }
  54. timeout(options) {
  55. if (typeof options.timeout === 'number') return options.timeout;
  56. if ((0, _utils.debugMode)()) return 0;
  57. if (this._defaultTimeout !== undefined) return this._defaultTimeout;
  58. if (this._parent) return this._parent.timeout(options);
  59. return DEFAULT_TIMEOUT;
  60. }
  61. static timeout(options) {
  62. if (typeof options.timeout === 'number') return options.timeout;
  63. if ((0, _utils.debugMode)()) return 0;
  64. return DEFAULT_TIMEOUT;
  65. }
  66. static launchTimeout(options) {
  67. if (typeof options.timeout === 'number') return options.timeout;
  68. if ((0, _utils.debugMode)()) return 0;
  69. return DEFAULT_LAUNCH_TIMEOUT;
  70. }
  71. }
  72. exports.TimeoutSettings = TimeoutSettings;