@@ -18,7 +18,7 @@ const metrics = {};
1818const pruneAxTree = ( axTree ) => {
1919 const axArr = [ ] ;
2020 for ( const node of axTree ) {
21- const {
21+ let {
2222 backendDOMNodeId,
2323 childIds,
2424 ignored,
@@ -35,6 +35,17 @@ const pruneAxTree = (axTree) => {
3535 // nameString = name.value;
3636 // }
3737
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+ }
3849 const axNode = {
3950 backendDOMNodeId : backendDOMNodeId ,
4051 childIds : childIds ,
@@ -272,16 +283,21 @@ chrome.runtime.onConnect.addListener((port) => {
272283
273284 // 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
274285 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
276290 tabsObj [ tabId ] . hierarchy . children = [ ] ; // resets hierarchy
277291 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
279294 ...tabsObj [ tabId ] . snapshots [ 0 ] ,
280295 } ;
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
285301 tabsObj [ tabId ] . index = 1 ; //reset index
286302 tabsObj [ tabId ] . currParent = 0 ; // reset currParent
287303 tabsObj [ tabId ] . currBranch = 1 ; // reset currBranch
@@ -508,10 +524,14 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
508524 const previousSnap =
509525 tabsObj [ tabId ] ?. currLocation ?. stateSnapshot ?. children [ 0 ] ?. componentData ?. actualDuration ;
510526 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+ }
512531
513532 // Or if it is a snapShot after a jump, we don't record it.
514533 if ( reloaded [ tabId ] ) {
534+ console . log ( 'background.js: reloaded[tabId]' ) ;
515535 // don't add anything to snapshot storage if tab is reloaded for the initial snapshot
516536 reloaded [ tabId ] = false ;
517537 } else {
@@ -527,6 +547,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
527547 'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
528548 JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
529549 ) ;
550+ } else {
551+ console . log ( 'background.js: tabsObj[tabId][index]' ) ;
530552 }
531553 }
532554
@@ -539,6 +561,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
539561 sourceTab,
540562 } ) ,
541563 ) ;
564+ } else {
565+ console . log ( 'background.js: portsArr.length < 0' ) ;
542566 }
543567 break ;
544568 }
0 commit comments