@@ -93,7 +93,7 @@ function createTabObj(title) {
93
93
// 1. param 'obj' : arg request.payload, which is an object containing a tree from snapShot.ts and a route property
94
94
// 2. param tabObj: arg tabsObj[tabId], which is an object that holds info about a specific tab. Should change the name of tabObj to tabCollection or something
95
95
class HistoryNode {
96
- constructor ( obj , tabObj ) {
96
+ constructor ( tabObj , newStateSnapshot , newAxSnapshot ) {
97
97
// continues the order of number of total state changes
98
98
this . index = tabObj . index ;
99
99
tabObj . index += 1 ;
@@ -102,8 +102,8 @@ class HistoryNode {
102
102
this . name = tabObj . currParent ;
103
103
// marks from what branch this node is originated
104
104
this . branch = tabObj . currBranch ;
105
- this . stateSnapshot = obj ;
106
- this . axSnapshot = tabObj . axSnapshots [ tabObj . axSnapshots . length - 1 ] ;
105
+ this . stateSnapshot = newStateSnapshot ;
106
+ this . axSnapshot = newAxSnapshot ;
107
107
this . children = [ ] ;
108
108
}
109
109
}
@@ -250,9 +250,11 @@ chrome.runtime.onConnect.addListener((port) => {
250
250
case 'import' : // create a snapshot property on tabId and set equal to tabs object
251
251
// may need do something like filter payload from stateless
252
252
tabsObj [ tabId ] . snapshots = payload . snapshots ; // reset snapshots to page last state recorded
253
+ tabsObj [ tabId ] . axSnapshots = payload . axSnapshots ; // TRYING to import axsnapshots
253
254
// tabsObj[tabId].hierarchy = savedSnapshot.hierarchy; // why don't we just use hierarchy? Because it breaks everything...
254
255
tabsObj [ tabId ] . hierarchy . children = payload . hierarchy . children ; // resets hierarchy to last state recorded
255
256
tabsObj [ tabId ] . hierarchy . stateSnapshot = payload . hierarchy . stateSnapshot ; // resets hierarchy to last state recorded
257
+ tabsObj [ tabId ] . hierarchy . axSnapshot = payload . hierarchy . axSnapshot ; // TRYING to import hierarchy axsnapshot
256
258
tabsObj [ tabId ] . currLocation = payload . currLocation ; // resets currLocation to last state recorded
257
259
tabsObj [ tabId ] . index = payload . index ; //reset index to last state recorded
258
260
tabsObj [ tabId ] . currParent = payload . currParent ; // reset currParent to last state recorded
@@ -268,10 +270,17 @@ chrome.runtime.onConnect.addListener((port) => {
268
270
// resets hierarchy to page last state recorded
269
271
...tabsObj [ tabId ] . snapshots [ 0 ] ,
270
272
} ;
273
+ tabsObj [ tabId ] . axSnapshots =
274
+ tabsObj [ tabId ] . axSnapshots [ tabsObj [ tabId ] . axSnapshots . length - 1 ] ;
275
+ tabsObj [ tabId ] . hierarchy . axSnapshot = tabsObj [ tabId ] . axSnapshots [ 0 ] ; //what about other hierarchy properties? Shouldn't those be reset as well?
271
276
tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ; // resets currLocation to page last state recorded
272
277
tabsObj [ tabId ] . index = 1 ; //reset index
273
278
tabsObj [ tabId ] . currParent = 0 ; // reset currParent
274
279
tabsObj [ tabId ] . currBranch = 1 ; // reset currBranch
280
+ console . log (
281
+ 'background.js: bottom of emptySnap: tabsObj[tabId]:' ,
282
+ JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
283
+ ) ;
275
284
return true ; // return true so that port remains open
276
285
277
286
case 'setPause' : // Pause = lock on tab
@@ -405,6 +414,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
405
414
function addAxSnap ( snap ) {
406
415
const pruned = pruneAxTree ( snap ) ;
407
416
tabsObj [ tabId ] . axSnapshots . push ( pruned ) ;
417
+ return pruned ;
408
418
}
409
419
410
420
function attachDebugger ( tabId , version ) {
@@ -448,8 +458,9 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
448
458
await attachDebugger ( tabId , '1.3' ) ;
449
459
await sendDebuggerCommand ( tabId , 'Accessibility.enable' ) ;
450
460
const response = await sendDebuggerCommand ( tabId , 'Accessibility.getFullAXTree' ) ;
451
- addAxSnap ( response . nodes ) ;
461
+ const addedAxSnap = addAxSnap ( response . nodes ) ;
452
462
await detachDebugger ( tabId ) ;
463
+ return addedAxSnap ;
453
464
} catch ( error ) {
454
465
console . error ( 'axRecord debugger command failed:' , error ) ;
455
466
}
@@ -458,12 +469,19 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
458
469
tabsObj [ tabId ] . webMetrics = metrics ;
459
470
460
471
if ( ! firstSnapshotReceived [ tabId ] ) {
461
- await axRecord ( tabId ) ;
462
472
firstSnapshotReceived [ tabId ] = true ;
463
473
reloaded [ tabId ] = false ;
464
474
tabsObj [ tabId ] . webMetrics = metrics ;
465
475
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
466
- sendToHierarchy ( tabsObj [ tabId ] , new HistoryNode ( request . payload , tabsObj [ tabId ] ) ) ;
476
+ const addedAxSnap = await axRecord ( tabId ) ;
477
+ sendToHierarchy (
478
+ tabsObj [ tabId ] ,
479
+ new HistoryNode ( tabsObj [ tabId ] , request . payload , addedAxSnap ) ,
480
+ ) ;
481
+ console . log (
482
+ 'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
483
+ JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
484
+ ) ;
467
485
if ( portsArr . length > 0 ) {
468
486
portsArr . forEach ( ( bg ) =>
469
487
bg . postMessage ( {
@@ -492,8 +510,15 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
492
510
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
493
511
// INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN
494
512
if ( ! tabsObj [ tabId ] [ index ] ) {
495
- await axRecord ( tabId ) ;
496
- sendToHierarchy ( tabsObj [ tabId ] , new HistoryNode ( request . payload , tabsObj [ tabId ] ) ) ;
513
+ const addedAxSnap = await axRecord ( tabId ) ;
514
+ sendToHierarchy (
515
+ tabsObj [ tabId ] ,
516
+ new HistoryNode ( tabsObj [ tabId ] , request . payload , addedAxSnap ) ,
517
+ ) ;
518
+ console . log (
519
+ 'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
520
+ JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
521
+ ) ;
497
522
}
498
523
}
499
524
0 commit comments