@@ -20,10 +20,9 @@ const metrics = {};
2020// function pruning the chrome ax tree and pulling the relevant properties
2121const pruneAxTree = ( axTree ) => {
2222 const axArr = [ ] ;
23- let orderCounter = 0
24-
25- for ( const node of axTree ) {
23+ let orderCounter = 0 ;
2624
25+ for ( const node of axTree ) {
2726 let {
2827 backendDOMNodeId,
2928 childIds,
@@ -36,26 +35,17 @@ const pruneAxTree = (axTree) => {
3635 role,
3736 } = node ;
3837
39- // let order;
40-
41- if ( ! name ) {
42- if ( ignored ) {
43- name = { value : 'ignored node' } ;
44- }
45- else {
46- name = { value : 'no name' } ;
38+ if ( ! name ) {
39+ if ( ignored ) {
40+ name = { value : 'ignored node' } ;
41+ } else {
42+ name = { value : 'no name' } ;
4743 }
4844 }
49- if ( ! name . value ) {
45+ if ( ! name . value ) {
5046 name . value = 'no name' ;
5147 }
5248 //if the node is ignored, it should be given an order number as it won't be read at all
53- // if(ignored){
54- // order = null;
55- // }
56- // else{
57- // order = orderCounter++;
58- // }
5949 if ( role . type === 'role' ) {
6050 const axNode = {
6151 backendDOMNodeId : backendDOMNodeId ,
@@ -67,33 +57,26 @@ const pruneAxTree = (axTree) => {
6757 ignoredReasons : ignoredReasons ,
6858 parentId : parentId ,
6959 properties : properties ,
70- // order: order,
7160 } ;
7261 axArr . push ( axNode ) ;
7362 }
7463 }
75-
64+
7665 // Sort nodes by backendDOMNodeId in ascending order
77- //try with deep copy
78- // //aria properties
79- // console.log('axArr before : ', axArr);
80- // axArr.sort((a, b) => b.backendDOMNodeId - a.backendDOMNodeId);
81-
66+
8267 // Assign order based on sorted position
8368 for ( const axNode of axArr ) {
84- // console.log('current axnode order number: ', axNode.order)
85- // console.log('this iterations node', axNode);
86- if ( ! axNode . ignored ) { // Assuming you only want to assign order to non-ignored nodes
69+ if ( ! axNode . ignored ) {
70+ // Assuming you only want to assign order to non-ignored nodes
8771 axNode . order = orderCounter ++ ;
8872 } else {
8973 axNode . order = null ; // Or keep it undefined, based on your requirement
9074 }
91- // console.log('current axnode order number: ', axNode.order)
9275 }
93- // console.log('axArr after: ', axArr);
9476 return axArr ;
9577} ;
9678
79+ // attaches Chrome Debugger API to tab for running future commands
9780function attachDebugger ( tabId , version ) {
9881 return new Promise ( ( resolve , reject ) => {
9982 chrome . debugger . attach ( { tabId : tabId } , version , ( ) => {
@@ -106,6 +89,7 @@ function attachDebugger(tabId, version) {
10689 } ) ;
10790}
10891
92+ // sends commands with Chrome Debugger API
10993function sendDebuggerCommand ( tabId , command , params = { } ) {
11094 return new Promise ( ( resolve , reject ) => {
11195 chrome . debugger . sendCommand ( { tabId : tabId } , command , params , ( response ) => {
@@ -118,6 +102,7 @@ function sendDebuggerCommand(tabId, command, params = {}) {
118102 } ) ;
119103}
120104
105+ // detaches Chrome Debugger API from tab
121106function detachDebugger ( tabId ) {
122107 return new Promise ( ( resolve , reject ) => {
123108 chrome . debugger . detach ( { tabId : tabId } , ( ) => {
@@ -130,6 +115,7 @@ function detachDebugger(tabId) {
130115 } ) ;
131116}
132117
118+ // returns a pruned accessibility tree obtained using the Chrome Debugger API
133119async function axRecord ( tabId ) {
134120 try {
135121 await attachDebugger ( tabId , '1.3' ) ;
@@ -143,6 +129,8 @@ async function axRecord(tabId) {
143129 }
144130}
145131
132+ // Chrome Debugger API is unused unless accessibility features are toggled on with UI.
133+ // This function will replace the current empty snapshot if accessibility features are toggled on and the current location's accessibility snapshot has not yet been recorded.
146134async function replaceEmptySnap ( tabsObj , tabId , toggleAxRecord ) {
147135 if ( tabsObj [ tabId ] . currLocation . axSnapshot === 'emptyAxSnap' && toggleAxRecord === true ) {
148136 // add new ax snapshot to currlocation
@@ -166,8 +154,7 @@ function createTabObj(title) {
166154 // snapshots is an array of ALL state snapshots for stateful and stateless
167155 // components the Reactime tab working on a specific user application
168156 snapshots : [ ] ,
169- // axSnapshots is an array of the chrome ax tree at different points for state and stateless applications
170- // functionality to add snapshots is done later
157+ // axSnapshots is an array of the chrome accessibility tree at different points for state and stateless applications
171158 axSnapshots : [ ] ,
172159 // index here is the tab index that shows total amount of state changes
173160 index : 0 ,
@@ -413,7 +400,6 @@ chrome.runtime.onConnect.addListener((port) => {
413400
414401 case 'toggleAxRecord' :
415402 toggleAxRecord = ! toggleAxRecord ;
416- console . log ( 'background.js: toggleAxRecord:' , toggleAxRecord ) ;
417403
418404 await replaceEmptySnap ( tabsObj , tabId , toggleAxRecord ) ;
419405
@@ -620,11 +606,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
620606 ) ;
621607 }
622608 }
623- console . log ( 'postMessage sending snapshots from background js:' , {
624- action : 'sendSnapshots' ,
625- payload : tabsObj ,
626- sourceTab,
627- } )
609+
628610 // sends new tabs obj to devtools
629611 if ( portsArr . length > 0 ) {
630612 portsArr . forEach ( ( bg ) =>
0 commit comments