@@ -28,6 +28,7 @@ import type {
2828 SerializedAXNode ,
2929 Viewport ,
3030 Target ,
31+ Extension ,
3132} from './third_party/index.js' ;
3233import type { DevTools } from './third_party/index.js' ;
3334import { Locator } from './third_party/index.js' ;
@@ -47,10 +48,6 @@ import type {
4748 TextSnapshotNode ,
4849 ExtensionServiceWorker ,
4950} from './types.js' ;
50- import {
51- ExtensionRegistry ,
52- type InstalledExtension ,
53- } from './utils/ExtensionRegistry.js' ;
5451import { ensureExtension , saveTemporaryFile } from './utils/files.js' ;
5552import { getNetworkMultiplierFromString } from './WaitForHelper.js' ;
5653
@@ -83,7 +80,6 @@ export class McpContext implements Context {
8380 #networkCollector: NetworkCollector ;
8481 #consoleCollector: ConsoleCollector ;
8582 #devtoolsUniverseManager: UniverseManager ;
86- #extensionRegistry = new ExtensionRegistry ( ) ;
8783
8884 #isRunningTrace = false ;
8985 #screenRecorderData: { recorder : ScreenRecorder ; filePath : string } | null =
@@ -882,38 +878,30 @@ export class McpContext implements Context {
882878
883879 async installExtension ( extensionPath : string ) : Promise < string > {
884880 const id = await this . browser . installExtension ( extensionPath ) ;
885- await this . #extensionRegistry. registerExtension ( id , extensionPath ) ;
886881 return id ;
887882 }
888883
889884 async uninstallExtension ( id : string ) : Promise < void > {
890885 await this . browser . uninstallExtension ( id ) ;
891- this . #extensionRegistry. remove ( id ) ;
892886 }
893887
894888 async triggerExtensionAction ( id : string ) : Promise < void > {
895- const page = this . getSelectedPptrPage ( ) ;
896- // @ts -expect-error internal puppeteer api is needed since we don't have a way to get
897- // a tab id at the moment
898- const theTarget = page . _tabId ;
899- const session = await this . browser . target ( ) . createCDPSession ( ) ;
900-
901- try {
902- await session . send ( 'Extensions.triggerAction' , {
903- id,
904- targetId : theTarget ,
905- } ) ;
906- } finally {
907- await session . detach ( ) ;
889+ const extensions = await this . browser . extensions ( ) ;
890+ const extension = extensions . get ( id ) ;
891+ if ( ! extension ) {
892+ throw new Error ( `Extension with ID ${ id } not found.` ) ;
908893 }
894+ const page = this . getSelectedPptrPage ( ) ;
895+ await extension . triggerAction ( page ) ;
909896 }
910897
911- listExtensions ( ) : InstalledExtension [ ] {
912- return this . #extensionRegistry . list ( ) ;
898+ listExtensions ( ) : Promise < Map < string , Extension > > {
899+ return this . browser . extensions ( ) ;
913900 }
914901
915- getExtension ( id : string ) : InstalledExtension | undefined {
916- return this . #extensionRegistry. getById ( id ) ;
902+ async getExtension ( id : string ) : Promise < Extension | undefined > {
903+ const pptrExtensions = await this . browser . extensions ( ) ;
904+ return pptrExtensions . get ( id ) ;
917905 }
918906
919907 async getHeapSnapshotAggregates (
0 commit comments