2020-09-04 16:31:52 -07:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-01-24 08:44:11 -08:00
|
|
|
import { BrowserContext, ContextListener, contextListeners } from '../browserContext';
|
|
|
|
|
import { isDebugMode } from '../../utils/utils';
|
2020-09-04 16:31:52 -07:00
|
|
|
|
2021-01-24 08:44:11 -08:00
|
|
|
export function installInspectorController() {
|
|
|
|
|
contextListeners.add(new InspectorController());
|
2020-09-17 09:32:54 -07:00
|
|
|
}
|
|
|
|
|
|
2021-01-24 08:44:11 -08:00
|
|
|
class InspectorController implements ContextListener {
|
2020-09-04 16:31:52 -07:00
|
|
|
async onContextCreated(context: BrowserContext): Promise<void> {
|
2020-12-23 12:44:47 -08:00
|
|
|
if (isDebugMode())
|
2021-01-24 08:44:11 -08:00
|
|
|
context.exposeConsoleApi();
|
2020-09-04 16:31:52 -07:00
|
|
|
}
|
2020-10-26 14:32:07 -07:00
|
|
|
async onContextWillDestroy(context: BrowserContext): Promise<void> {}
|
|
|
|
|
async onContextDidDestroy(context: BrowserContext): Promise<void> {}
|
2020-09-04 16:31:52 -07:00
|
|
|
}
|