@@ -207,6 +207,8 @@ chrome.runtime.onConnect.addListener((port) => {
207
207
// ---------------------------------------------------------------
208
208
const { action, payload, tabId } = msg ;
209
209
210
+ console . log ( 'background.js: port listener' ) ;
211
+
210
212
switch ( action ) {
211
213
// import action comes through when the user uses the "upload" button on the front end to import an existing snapshot tree
212
214
case 'import' : // create a snapshot property on tabId and set equal to tabs object
@@ -250,19 +252,6 @@ chrome.runtime.onConnect.addListener((port) => {
250
252
case 'jumpToSnap' :
251
253
// chrome.debugger.detach({ tabId: tabId });
252
254
// console.log('background.js: jumpToSnap:', getAccessibilityTree(tabId));
253
- chrome . debugger . attach ( { tabId : tabId } , '1.3' , ( ) => {
254
- chrome . debugger . sendCommand ( { tabId : tabId } , 'Accessibility.enable' , ( ) => {
255
- chrome . debugger . sendCommand (
256
- { tabId : tabId } ,
257
- 'Accessibility.getFullAXTree' ,
258
- { } ,
259
- ( response ) => {
260
- console . log ( response ) ;
261
- chrome . debugger . detach ( { tabId : tabId } ) ;
262
- } ,
263
- ) ;
264
- } ) ;
265
- } ) ;
266
255
chrome . tabs . sendMessage ( tabId , msg ) ;
267
256
return true ; // attempt to fix message port closing error, consider return Promise
268
257
@@ -303,7 +292,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
303
292
action === 'jumpToSnap' ||
304
293
action === 'injectScript' ||
305
294
action === 'devToolsInstalled' ||
306
- action === 'aReactApp'
295
+ action === 'aReactApp' ||
296
+ action === 'recordAXSnap'
307
297
) {
308
298
isReactTimeTravel = true ;
309
299
} else {
@@ -313,8 +303,24 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
313
303
if ( isReactTimeTravel && ! ( tabId in tabsObj ) ) {
314
304
tabsObj [ tabId ] = createTabObj ( tabTitle ) ;
315
305
}
316
-
306
+ console . log ( 'background.js: chrome.runtime event listener action:' , action ) ;
317
307
switch ( action ) {
308
+ case 'recordAXSnap' : {
309
+ console . log ( 'background.js reached action case' ) ;
310
+ chrome . debugger . attach ( { tabId : tabId } , '1.3' , ( ) => {
311
+ chrome . debugger . sendCommand ( { tabId : tabId } , 'Accessibility.enable' , ( ) => {
312
+ chrome . debugger . sendCommand (
313
+ { tabId : tabId } ,
314
+ 'Accessibility.getFullAXTree' ,
315
+ { } ,
316
+ ( response ) => {
317
+ console . log ( response ) ;
318
+ chrome . debugger . detach ( { tabId : tabId } ) ;
319
+ } ,
320
+ ) ;
321
+ } ) ;
322
+ } ) ;
323
+ }
318
324
case 'attemptReconnect' : {
319
325
const success = 'portSuccessfullyConnected' ;
320
326
sendResponse ( { success } ) ;
0 commit comments