@@ -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,
@@ -29,6 +29,17 @@ const pruneAxTree = (axTree) => {
2929 properties,
3030 } = node ;
3131
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+ }
3243 const axNode = {
3344 backendDOMNodeId : backendDOMNodeId ,
3445 childIds : childIds ,
@@ -264,16 +275,21 @@ chrome.runtime.onConnect.addListener((port) => {
264275
265276 // 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
266277 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
268282 tabsObj [ tabId ] . hierarchy . children = [ ] ; // resets hierarchy
269283 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
271286 ...tabsObj [ tabId ] . snapshots [ 0 ] ,
272287 } ;
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
277293 tabsObj [ tabId ] . index = 1 ; //reset index
278294 tabsObj [ tabId ] . currParent = 0 ; // reset currParent
279295 tabsObj [ tabId ] . currBranch = 1 ; // reset currBranch
@@ -500,10 +516,14 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
500516 const previousSnap =
501517 tabsObj [ tabId ] ?. currLocation ?. stateSnapshot ?. children [ 0 ] ?. componentData ?. actualDuration ;
502518 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+ }
504523
505524 // Or if it is a snapShot after a jump, we don't record it.
506525 if ( reloaded [ tabId ] ) {
526+ console . log ( 'background.js: reloaded[tabId]' ) ;
507527 // don't add anything to snapshot storage if tab is reloaded for the initial snapshot
508528 reloaded [ tabId ] = false ;
509529 } else {
@@ -519,6 +539,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
519539 'background.js: bottom of recordSnap: tabsObj[tabId]:' ,
520540 JSON . parse ( JSON . stringify ( tabsObj [ tabId ] ) ) ,
521541 ) ;
542+ } else {
543+ console . log ( 'background.js: tabsObj[tabId][index]' ) ;
522544 }
523545 }
524546
@@ -531,6 +553,8 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
531553 sourceTab,
532554 } ) ,
533555 ) ;
556+ } else {
557+ console . log ( 'background.js: portsArr.length < 0' ) ;
534558 }
535559 break ;
536560 }
0 commit comments