Skip to content

Commit 7c37f56

Browse files
committed
Merge branch 'develop' into amy/visualizeAxTree
2 parents 3b9b225 + 5168e97 commit 7c37f56

File tree

2 files changed

+54
-13
lines changed

2 files changed

+54
-13
lines changed

src/app/slices/mainSlice.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,31 @@ export const mainSlice = createSlice({
4646
tabs[currentTab].viewIndex = 0;
4747
tabs[currentTab].playing = false;
4848

49-
const lastSnapshot = tabs[currentTab].snapshots[tabs[currentTab].snapshots.length - 1]; // the most recent snapshot
50-
51-
tabs[currentTab].hierarchy.stateSnapshot = { ...lastSnapshot }; // resets hierarchy to page last state recorded
49+
// REFACTORED TO HAVE CLEAR BUTTON KEEP CURRENT STATE OF DEMO APP RATHER THAN JUST THE LAST STATE RECORDED
50+
// PRIOR IMPLEMENTATION WAS FAILING TO RESET STATE OF DEMO APP UPON CLEAR
51+
// IF CHANGING, CHANGE BACKGROUND.JS TOO
52+
53+
// const lastSnapshot = tabs[currentTab].snapshots[tabs[currentTab].snapshots.length - 1]; // the most recent snapshot
54+
// const lastAxSnapshot = tabs[currentTab].axSnapshots[tabs[currentTab].axSnapshots.length - 1]; // the most recent snapshot
55+
const currSnapshot = tabs[currentTab].snapshots[tabs[currentTab].currLocation.index]; // the most recent snapshot
56+
const currAxSnapshot = tabs[currentTab].axSnapshots[tabs[currentTab].currLocation.index]; // the most recent snapshot
57+
58+
// tabs[currentTab].hierarchy.stateSnapshot = { ...lastSnapshot }; // resets hierarchy to page last state recorded
59+
// // not sure why shallow deep copy
60+
// tabs[currentTab].hierarchy.axSnapshot = lastAxSnapshot; // resets hierarchy to page last state recorded
61+
// tabs[currentTab].hierarchy.children = []; // resets hierarchy
62+
// tabs[currentTab].snapshots = [lastSnapshot]; // resets snapshots to page last state recorded
63+
// tabs[currentTab].axSnapshots = [lastAxSnapshot]; // resets snapshots to page last state recorded
64+
65+
tabs[currentTab].hierarchy.stateSnapshot = { ...currSnapshot }; // resets hierarchy to page last state recorded
66+
// not sure why shallow deep copy
67+
tabs[currentTab].hierarchy.axSnapshot = currAxSnapshot; // resets hierarchy to page last state recorded
5268
tabs[currentTab].hierarchy.children = []; // resets hierarchy
53-
tabs[currentTab].snapshots = [lastSnapshot]; // resets snapshots to page last state recorded
69+
tabs[currentTab].snapshots = [currSnapshot]; // resets snapshots to page last state recorded
70+
tabs[currentTab].axSnapshots = [currAxSnapshot]; // resets snapshots to page last state recorded
5471

5572
// resets currLocation to page last state recorded
56-
tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
73+
// tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
5774
tabs[currentTab].index = 1;
5875
tabs[currentTab].currParent = 0;
5976
tabs[currentTab].currBranch = 1;

src/extension/background.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const metrics = {};
1818
const 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

Comments
 (0)