@@ -18,7 +18,7 @@ const metrics = {};
18
18
const pruneAxTree = ( axTree ) => {
19
19
const axArr = [ ] ;
20
20
for ( const node of axTree ) {
21
- const {
21
+ let {
22
22
backendDOMNodeId,
23
23
childIds,
24
24
ignored,
@@ -29,6 +29,17 @@ const pruneAxTree = (axTree) => {
29
29
properties,
30
30
} = node ;
31
31
32
+ if ( ! name ) {
33
+ if ( ignored ) {
34
+ name = { value : `ignored node: ${ ignoredReasons [ 0 ] . name } ` } ;
35
+ }
36
+ else {
37
+ name = { value : 'visible node with no name' } ;
38
+ }
39
+ }
40
+ if ( ! name . value ) {
41
+ name . value = 'visible node with no name' ;
42
+ }
32
43
const axNode = {
33
44
backendDOMNodeId : backendDOMNodeId ,
34
45
childIds : childIds ,
@@ -264,16 +275,21 @@ chrome.runtime.onConnect.addListener((port) => {
264
275
265
276
// emptySnap actions comes through when the user uses the 'clear' button on the front end to clear the snapshot history and move slider back to 0 position
266
277
case 'emptySnap' :
267
- tabsObj [ tabId ] . snapshots = [ tabsObj [ tabId ] . snapshots [ tabsObj [ tabId ] . snapshots . length - 1 ] ] ; // reset snapshots to page last state recorded
278
+ // REFACTORED TO HAVE CLEAR BUTTON KEEP CURRENT STATE OF DEMO APP RATHER THAN JUST THE LAST STATE RECORDED
279
+ // PRIOR IMPLEMENTATION WAS FAILING TO RESET STATE OF DEMO APP UPON CLEAR
280
+ // IF CHANGING, CHANGE MAINSLICE.JS TOO
281
+ tabsObj [ tabId ] . snapshots = [ tabsObj [ tabId ] . snapshots [ tabsObj [ tabId ] . currLocation . index ] ] ; // reset snapshots to current page state
268
282
tabsObj [ tabId ] . hierarchy . children = [ ] ; // resets hierarchy
269
283
tabsObj [ tabId ] . hierarchy . stateSnapshot = {
270
- // resets hierarchy to page last state recorded
284
+ // resets hierarchy to current page state
285
+ // not sure why they are doing a "shallow" deep copy
271
286
...tabsObj [ tabId ] . snapshots [ 0 ] ,
272
287
} ;
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?
276
- tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ; // resets currLocation to page last state recorded
288
+ tabsObj [ tabId ] . axSnapshots = [
289
+ tabsObj [ tabId ] . axSnapshots [ tabsObj [ tabId ] . currLocation . index ] ,
290
+ ] ; // resets axSnapshots to current page state
291
+ tabsObj [ tabId ] . hierarchy . axSnapshot = tabsObj [ tabId ] . axSnapshots [ 0 ] ; // resets hierarchy to ax tree of current page state
292
+ // tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy; // resets currLocation to page last state recorded
277
293
tabsObj [ tabId ] . index = 1 ; //reset index
278
294
tabsObj [ tabId ] . currParent = 0 ; // reset currParent
279
295
tabsObj [ tabId ] . currBranch = 1 ; // reset currBranch
@@ -500,10 +516,14 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
500
516
const previousSnap =
501
517
tabsObj [ tabId ] ?. currLocation ?. stateSnapshot ?. children [ 0 ] ?. componentData ?. actualDuration ;
502
518
const incomingSnap = request . payload . children [ 0 ] . componentData . actualDuration ;
503
- if ( previousSnap === incomingSnap ) break ;
519
+ if ( previousSnap === incomingSnap ) {
520
+ console . log ( 'background.js: previousSnap===incomingSnap' ) ;
521
+ break ;
522
+ }
504
523
505
524
// Or if it is a snapShot after a jump, we don't record it.
506
525
if ( reloaded [ tabId ] ) {
526
+ console . log ( 'background.js: reloaded[tabId]' ) ;
507
527
// don't add anything to snapshot storage if tab is reloaded for the initial snapshot
508
528
reloaded [ tabId ] = false ;
509
529
} else {
@@ -519,6 +539,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
519
539
'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
520
540
JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
521
541
) ;
542
+ } else {
543
+ console . log ( 'background.js: tabsObj[tabId][index]' ) ;
522
544
}
523
545
}
524
546
@@ -531,6 +553,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
531
553
sourceTab,
532
554
} ) ,
533
555
) ;
556
+ } else {
557
+ console . log ( 'background.js: portsArr.length < 0' ) ;
534
558
}
535
559
break ;
536
560
}
0 commit comments