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.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-09-17 09:32:54 -07:00
|
|
|
import { BrowserContext, ContextListener, contextListeners } from '../server/browserContext';
|
2020-09-04 16:31:52 -07:00
|
|
|
import { isDebugMode } from '../utils/utils';
|
2020-12-23 14:15:16 -08:00
|
|
|
import * as consoleApiSource from '../generated/consoleApiSource';
|
2020-09-04 16:31:52 -07:00
|
|
|
|
2020-09-17 09:32:54 -07:00
|
|
|
export function installDebugController() {
|
|
|
|
|
contextListeners.add(new DebugController());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class DebugController 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())
|
2020-12-23 14:15:16 -08:00
|
|
|
context.extendInjectedScript(consoleApiSource.source);
|
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
|
|
|
}
|