@@ -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,
@@ -35,6 +35,17 @@ const pruneAxTree = (axTree) => {
35
35
// nameString = name.value;
36
36
// }
37
37
38
+ if ( ! name ) {
39
+ if ( ignored ) {
40
+ name = { value : `ignored node: ${ ignoredReasons [ 0 ] . name } ` } ;
41
+ }
42
+ else {
43
+ name = { value : 'visible node with no name' } ;
44
+ }
45
+ }
46
+ if ( ! name . value ) {
47
+ name . value = 'visible node with no name' ;
48
+ }
38
49
const axNode = {
39
50
backendDOMNodeId : backendDOMNodeId ,
40
51
childIds : childIds ,
@@ -272,16 +283,21 @@ chrome.runtime.onConnect.addListener((port) => {
272
283
273
284
// 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
274
285
case 'emptySnap' :
275
- tabsObj [ tabId ] . snapshots = [ tabsObj [ tabId ] . snapshots [ tabsObj [ tabId ] . snapshots . length - 1 ] ] ; // reset snapshots to page last state recorded
286
+ // REFACTORED TO HAVE CLEAR BUTTON KEEP CURRENT STATE OF DEMO APP RATHER THAN JUST THE LAST STATE RECORDED
287
+ // PRIOR IMPLEMENTATION WAS FAILING TO RESET STATE OF DEMO APP UPON CLEAR
288
+ // IF CHANGING, CHANGE MAINSLICE.JS TOO
289
+ tabsObj [ tabId ] . snapshots = [ tabsObj [ tabId ] . snapshots [ tabsObj [ tabId ] . currLocation . index ] ] ; // reset snapshots to current page state
276
290
tabsObj [ tabId ] . hierarchy . children = [ ] ; // resets hierarchy
277
291
tabsObj [ tabId ] . hierarchy . stateSnapshot = {
278
- // resets hierarchy to page last state recorded
292
+ // resets hierarchy to current page state
293
+ // not sure why they are doing a "shallow" deep copy
279
294
...tabsObj [ tabId ] . snapshots [ 0 ] ,
280
295
} ;
281
- tabsObj [ tabId ] . axSnapshots =
282
- tabsObj [ tabId ] . axSnapshots [ tabsObj [ tabId ] . axSnapshots . length - 1 ] ;
283
- tabsObj [ tabId ] . hierarchy . axSnapshot = tabsObj [ tabId ] . axSnapshots [ 0 ] ; //what about other hierarchy properties? Shouldn't those be reset as well?
284
- tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ; // resets currLocation to page last state recorded
296
+ tabsObj [ tabId ] . axSnapshots = [
297
+ tabsObj [ tabId ] . axSnapshots [ tabsObj [ tabId ] . currLocation . index ] ,
298
+ ] ; // resets axSnapshots to current page state
299
+ tabsObj [ tabId ] . hierarchy . axSnapshot = tabsObj [ tabId ] . axSnapshots [ 0 ] ; // resets hierarchy to ax tree of current page state
300
+ // tabsObj[tabId].currLocation = tabsObj[tabId].hierarchy; // resets currLocation to page last state recorded
285
301
tabsObj [ tabId ] . index = 1 ; //reset index
286
302
tabsObj [ tabId ] . currParent = 0 ; // reset currParent
287
303
tabsObj [ tabId ] . currBranch = 1 ; // reset currBranch
@@ -508,10 +524,14 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
508
524
const previousSnap =
509
525
tabsObj [ tabId ] ?. currLocation ?. stateSnapshot ?. children [ 0 ] ?. componentData ?. actualDuration ;
510
526
const incomingSnap = request . payload . children [ 0 ] . componentData . actualDuration ;
511
- if ( previousSnap === incomingSnap ) break ;
527
+ if ( previousSnap === incomingSnap ) {
528
+ console . log ( 'background.js: previousSnap===incomingSnap' ) ;
529
+ break ;
530
+ }
512
531
513
532
// Or if it is a snapShot after a jump, we don't record it.
514
533
if ( reloaded [ tabId ] ) {
534
+ console . log ( 'background.js: reloaded[tabId]' ) ;
515
535
// don't add anything to snapshot storage if tab is reloaded for the initial snapshot
516
536
reloaded [ tabId ] = false ;
517
537
} else {
@@ -527,6 +547,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
527
547
'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
528
548
JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
529
549
) ;
550
+ } else {
551
+ console . log ( 'background.js: tabsObj[tabId][index]' ) ;
530
552
}
531
553
}
532
554
@@ -539,6 +561,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
539
561
sourceTab,
540
562
} ) ,
541
563
) ;
564
+ } else {
565
+ console . log ( 'background.js: portsArr.length < 0' ) ;
542
566
}
543
567
break ;
544
568
}
0 commit comments