2019-01-29 01:16:12 +00:00
|
|
|
/**
|
|
|
|
* Copyright 2019 Google Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const DEFAULT_TIMEOUT = 30000;
|
|
|
|
|
2020-07-06 11:37:16 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2020-04-28 14:35:43 +00:00
|
|
|
export class TimeoutSettings {
|
2020-04-20 10:32:08 +00:00
|
|
|
_defaultTimeout: number | null;
|
|
|
|
_defaultNavigationTimeout: number | null;
|
|
|
|
|
2019-01-29 01:16:12 +00:00
|
|
|
constructor() {
|
|
|
|
this._defaultTimeout = null;
|
|
|
|
this._defaultNavigationTimeout = null;
|
|
|
|
}
|
|
|
|
|
2020-04-20 10:32:08 +00:00
|
|
|
setDefaultTimeout(timeout: number): void {
|
2019-01-29 01:16:12 +00:00
|
|
|
this._defaultTimeout = timeout;
|
|
|
|
}
|
|
|
|
|
2020-04-20 10:32:08 +00:00
|
|
|
setDefaultNavigationTimeout(timeout: number): void {
|
2019-01-29 01:16:12 +00:00
|
|
|
this._defaultNavigationTimeout = timeout;
|
|
|
|
}
|
|
|
|
|
2020-04-20 10:32:08 +00:00
|
|
|
navigationTimeout(): number {
|
2019-01-29 01:16:12 +00:00
|
|
|
if (this._defaultNavigationTimeout !== null)
|
|
|
|
return this._defaultNavigationTimeout;
|
2020-05-07 10:54:55 +00:00
|
|
|
if (this._defaultTimeout !== null) return this._defaultTimeout;
|
2019-01-29 01:16:12 +00:00
|
|
|
return DEFAULT_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
2020-04-20 10:32:08 +00:00
|
|
|
timeout(): number {
|
2020-05-07 10:54:55 +00:00
|
|
|
if (this._defaultTimeout !== null) return this._defaultTimeout;
|
2019-01-29 01:16:12 +00:00
|
|
|
return DEFAULT_TIMEOUT;
|
|
|
|
}
|
|
|
|
}
|