Skip to content

Commit 055aeab

Browse files
committed
fixed looping bug. Now ax tree is console.logged upon state change
1 parent dd81c7b commit 055aeab

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/extension/background.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ chrome.runtime.onConnect.addListener((port) => {
207207
// ---------------------------------------------------------------
208208
const { action, payload, tabId } = msg;
209209

210+
console.log('background.js: port listener');
211+
210212
switch (action) {
211213
// import action comes through when the user uses the "upload" button on the front end to import an existing snapshot tree
212214
case 'import': // create a snapshot property on tabId and set equal to tabs object
@@ -250,19 +252,6 @@ chrome.runtime.onConnect.addListener((port) => {
250252
case 'jumpToSnap':
251253
// chrome.debugger.detach({ tabId: tabId });
252254
// 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-
});
266255
chrome.tabs.sendMessage(tabId, msg);
267256
return true; // attempt to fix message port closing error, consider return Promise
268257

@@ -303,7 +292,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
303292
action === 'jumpToSnap' ||
304293
action === 'injectScript' ||
305294
action === 'devToolsInstalled' ||
306-
action === 'aReactApp'
295+
action === 'aReactApp' ||
296+
action === 'recordAXSnap'
307297
) {
308298
isReactTimeTravel = true;
309299
} else {
@@ -313,8 +303,24 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
313303
if (isReactTimeTravel && !(tabId in tabsObj)) {
314304
tabsObj[tabId] = createTabObj(tabTitle);
315305
}
316-
306+
console.log('background.js: chrome.runtime event listener action:', action);
317307
switch (action) {
308+
case 'recordAXSnap': {
309+
console.log('background.js reached action case');
310+
chrome.debugger.attach({ tabId: tabId }, '1.3', () => {
311+
chrome.debugger.sendCommand({ tabId: tabId }, 'Accessibility.enable', () => {
312+
chrome.debugger.sendCommand(
313+
{ tabId: tabId },
314+
'Accessibility.getFullAXTree',
315+
{},
316+
(response) => {
317+
console.log(response);
318+
chrome.debugger.detach({ tabId: tabId });
319+
},
320+
);
321+
});
322+
});
323+
}
318324
case 'attemptReconnect': {
319325
const success = 'portSuccessfullyConnected';
320326
sendResponse({ success });

src/extension/contentScript.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ window.addEventListener('message', (msg) => {
3737
chrome.runtime.sendMessage(msg.data);
3838
}
3939
if (action === 'recordAXSnap') {
40-
// chrome.runtime.sendMessage()
40+
console.log('contentScript.ts: window received recordAXSnap');
41+
// chrome.runtime.sendMessage({ action: 'recordAXSnap' });
42+
chrome.runtime.sendMessage(msg.data);
4143
}
4244
});
4345

0 commit comments

Comments
 (0)