Skip to content

Commit 83e6d0d

Browse files
authored
Merge pull request #3 from oslabs-beta/new_ax_tree
New ax tree
2 parents 6664123 + d84a449 commit 83e6d0d

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

src/backend/routers/linkFiber.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ export default function linkFiber(mode: Status): () => Promise<void> {
133133
// Obtain the updated FiberRootNode, after the target React application re-renders
134134
const fiberRoot = args[1];
135135
// If the target React application is visible, send a request to update the snapShot tree displayed on Chrome Extension
136-
if (isVisible) throttledUpdateSnapshot(fiberRoot, mode);
136+
if (isVisible) {
137+
throttledUpdateSnapshot(fiberRoot, mode);
138+
// SEND COMMAND TO FRONT END TO GET NEW AX TREE
139+
window.postMessage(
140+
{
141+
action: 'recordAXSnap',
142+
payload: 'recordAXSnap',
143+
},
144+
'*',
145+
);
146+
}
137147
// After our added work is completed we invoke the original onComitFiberRoot function
138148
return onCommitFiberRoot(...args);
139149
};

src/extension/background.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,6 @@ chrome.runtime.onConnect.addListener((port) => {
248248
return true;
249249

250250
case 'jumpToSnap':
251-
// chrome.debugger.detach({ tabId: tabId });
252-
// console.log('background.js: jumpToSnap:', getAccessibilityTree(tabId));
253-
chrome.debugger.attach({ tabId: tabId }, '1.3', () => {
254-
chrome.debugger.sendCommand({ tabId: tabId }, 'Accessibility.enable', () => {
255-
chrome.debugger.sendCommand(
256-
{ tabId: tabId },
257-
'Accessibility.getFullAXTree',
258-
{},
259-
(response) => {
260-
console.log(response);
261-
chrome.debugger.detach({ tabId: tabId });
262-
},
263-
);
264-
});
265-
});
266251
chrome.tabs.sendMessage(tabId, msg);
267252
return true; // attempt to fix message port closing error, consider return Promise
268253

@@ -303,7 +288,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
303288
action === 'jumpToSnap' ||
304289
action === 'injectScript' ||
305290
action === 'devToolsInstalled' ||
306-
action === 'aReactApp'
291+
action === 'aReactApp' ||
292+
action === 'recordAXSnap'
307293
) {
308294
isReactTimeTravel = true;
309295
} else {
@@ -313,8 +299,22 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
313299
if (isReactTimeTravel && !(tabId in tabsObj)) {
314300
tabsObj[tabId] = createTabObj(tabTitle);
315301
}
316-
317302
switch (action) {
303+
case 'recordAXSnap': {
304+
chrome.debugger.attach({ tabId: tabId }, '1.3', () => {
305+
chrome.debugger.sendCommand({ tabId: tabId }, 'Accessibility.enable', () => {
306+
chrome.debugger.sendCommand(
307+
{ tabId: tabId },
308+
'Accessibility.getFullAXTree',
309+
{},
310+
(response) => {
311+
console.log(response);
312+
chrome.debugger.detach({ tabId: tabId });
313+
},
314+
);
315+
});
316+
});
317+
}
318318
case 'attemptReconnect': {
319319
const success = 'portSuccessfullyConnected';
320320
sendResponse({ success });

src/extension/contentScript.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ window.addEventListener('message', (msg) => {
3636
if (action === 'aReactApp') {
3737
chrome.runtime.sendMessage(msg.data);
3838
}
39+
if (action === 'recordAXSnap') {
40+
console.log('contentScript.ts: window received recordAXSnap');
41+
// chrome.runtime.sendMessage({ action: 'recordAXSnap' });
42+
chrome.runtime.sendMessage(msg.data);
43+
}
3944
});
4045

4146
// FROM BACKGROUND TO CONTENT SCRIPT

0 commit comments

Comments
 (0)