2021-12-09 21:37:01 -05:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google LLC All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-16 02:00:43 -05:00
|
|
|
/// <reference types="chrome"/>
|
|
|
|
|
|
2021-12-09 00:44:17 -05:00
|
|
|
import {ApplicationOperations} from 'ng-devtools';
|
|
|
|
|
import {DirectivePosition, ElementPosition} from 'protocol';
|
2020-02-07 16:09:36 -05:00
|
|
|
|
2024-03-04 22:54:58 -05:00
|
|
|
function runInInspectedWindow(script: string, frameURL?: URL): void {
|
|
|
|
|
chrome.devtools.inspectedWindow.eval(script, {frameURL: frameURL?.toString?.()});
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-07 16:09:36 -05:00
|
|
|
export class ChromeApplicationOperations extends ApplicationOperations {
|
2024-03-04 22:54:58 -05:00
|
|
|
override viewSource(position: ElementPosition, directiveIndex?: number, target?: URL): void {
|
|
|
|
|
const viewSource = `inspect(inspectedApplication.findConstructorByPosition('${position}', ${directiveIndex}))`;
|
|
|
|
|
runInInspectedWindow(viewSource, target);
|
2020-02-07 16:09:36 -05:00
|
|
|
}
|
2020-02-07 22:56:11 -05:00
|
|
|
|
2024-03-04 22:54:58 -05:00
|
|
|
override selectDomElement(position: ElementPosition, target?: URL): void {
|
|
|
|
|
const selectDomElement = `inspect(inspectedApplication.findDomElementByPosition('${position}'))`;
|
|
|
|
|
runInInspectedWindow(selectDomElement, target);
|
2020-02-07 22:56:11 -05:00
|
|
|
}
|
2020-04-06 18:02:51 -04:00
|
|
|
|
2024-03-04 22:54:58 -05:00
|
|
|
override inspect(directivePosition: DirectivePosition, objectPath: string[], target?: URL): void {
|
|
|
|
|
const args = {
|
|
|
|
|
directivePosition,
|
|
|
|
|
objectPath,
|
|
|
|
|
};
|
|
|
|
|
const inspect = `inspect(inspectedApplication.findPropertyByPosition('${JSON.stringify(
|
|
|
|
|
args,
|
|
|
|
|
)}'))`;
|
|
|
|
|
runInInspectedWindow(inspect, target);
|
2020-04-06 18:02:51 -04:00
|
|
|
}
|
2020-02-07 16:09:36 -05:00
|
|
|
}
|