Skip to content

Commit 10b2796

Browse files
committed
pulling develop Merge branch 'develop' into jesse/toggleaccess
2 parents 14891b9 + 5168e97 commit 10b2796

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
@@ -47,14 +47,31 @@ export const mainSlice = createSlice({
4747
tabs[currentTab].viewIndex = 0;
4848
tabs[currentTab].playing = false;
4949

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

5673
// resets currLocation to page last state recorded
57-
tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
74+
// tabs[currentTab].currLocation = tabs[currentTab].hierarchy;
5875
tabs[currentTab].index = 1;
5976
tabs[currentTab].currParent = 0;
6077
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,
@@ -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

Comments
 (0)