@@ -13,6 +13,39 @@ let activeTab;
13
13
const tabsObj = { } ;
14
14
// Will store Chrome web vital metrics and their corresponding values.
15
15
const metrics = { } ;
16
+
17
+ // function pruning the chrome ax tree and pulling the relevant properties
18
+ const pruneAxTree = ( axTree ) => {
19
+ const axArr = [ ] ;
20
+ for ( const node of axTree ) {
21
+ const {
22
+ backendDOMNodeId,
23
+ childIds,
24
+ ignored,
25
+ name,
26
+ nodeId,
27
+ ignoredReasons,
28
+ parentId,
29
+ properties } = node ;
30
+
31
+ const axNode = {
32
+ "backendDOMNodeId" : backendDOMNodeId ,
33
+ "childIds" : childIds ,
34
+ "ignored" : ignored ,
35
+ "name" : name ,
36
+ "nodeId" : nodeId ,
37
+ "ignoredReasons" : ignoredReasons ,
38
+ "parentId" : parentId ,
39
+ "properties" : properties
40
+ } ;
41
+
42
+ axArr . push ( axNode ) ;
43
+ }
44
+
45
+ return axArr ;
46
+ } ;
47
+
48
+
16
49
// This function will create the first instance of the test app's tabs object
17
50
// which will hold test app's snapshots, link fiber tree info, chrome tab info, etc.
18
51
function createTabObj ( title ) {
@@ -26,6 +59,9 @@ function createTabObj(title) {
26
59
// snapshots is an array of ALL state snapshots for stateful and stateless
27
60
// components the Reactime tab working on a specific user application
28
61
snapshots : [ ] ,
62
+ // axSnapshots is an array of the chrome ax tree at different points for state and stateless applications
63
+ // functionality to add snapshots is done later
64
+ axSnapshots : [ ] ,
29
65
// index here is the tab index that shows total amount of state changes
30
66
index : 0 ,
31
67
//* currLocation points to the current state the user is checking
@@ -308,7 +344,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
308
344
'Accessibility.getFullAXTree' ,
309
345
{ } ,
310
346
( response ) => {
311
- console . log ( response ) ;
347
+ // function pruning the ax tree
348
+ tabsObj [ tabId ] . axSnapshots = pruneAxTree ( response . nodes ) ;
312
349
chrome . debugger . detach ( { tabId : tabId } ) ;
313
350
} ,
314
351
) ;
0 commit comments