Skip to content

Commit e9cc9a2

Browse files
authored
Merge pull request #1 from oslabs-beta/ax_tree
got ax tree console.logging in background.js
2 parents 902f70a + 619fb93 commit e9cc9a2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/extension/background.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ function changeCurrLocation(tabObj, rootNode, index, name) {
133133
}
134134
}
135135

136+
// get ax tree
137+
// function getAccessibilityTree(tabId) {
138+
// chrome.debugger.attach({ tabId: tabId }, '1.3', function () {
139+
// chrome.debugger.sendCommand({ tabId: tabId }, '1.3', 'Accessibility.enable', {}, function () {
140+
// chrome.debugger.sendCommand(
141+
// { tabId: tabId },
142+
// '1.3',
143+
// 'Accessibility.getFullAxTree',
144+
// {},
145+
// function (response) {
146+
// console.log(response);
147+
// },
148+
// );
149+
// });
150+
// });
151+
// }
152+
136153
/*
137154
The 'chrome.runtime' API allows a connection to the background service worker (background.js).
138155
This allows us to set up listener's for when we connect, message, and disconnect the script.
@@ -248,6 +265,19 @@ chrome.runtime.onConnect.addListener((port) => {
248265
return true;
249266

250267
case 'jumpToSnap':
268+
// console.log('background.js: jumpToSnap:', getAccessibilityTree(tabId));
269+
chrome.debugger.attach({ tabId: tabId }, '1.3', () => {
270+
chrome.debugger.sendCommand({ tabId: tabId }, 'Accessibility.enable', () => {
271+
chrome.debugger.sendCommand(
272+
{ tabId: tabId },
273+
'Accessibility.getFullAXTree',
274+
{},
275+
(response) => {
276+
console.log(response);
277+
},
278+
);
279+
});
280+
});
251281
chrome.tabs.sendMessage(tabId, msg);
252282
return true; // attempt to fix message port closing error, consider return Promise
253283

src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"matches": ["<all_urls>"]
2525
}
2626
],
27-
"permissions": ["contextMenus", "tabs", "activeTab", "scripting", "system.display"],
27+
"permissions": ["contextMenus", "tabs", "activeTab", "scripting", "system.display", "debugger"],
2828
"host_permissions": ["<all_urls>"]
2929
}

0 commit comments

Comments
 (0)