equal-access
equal-access copied to clipboard
[BUG][Node] Poor error handling when using selenium hides actual errors
Any errors that occur when running Checker in selenium aren't handled properly
accessibility-checker
Detailed description
Node version: 12.20.1 Platform: Windows 10
ACHelper.getComplianceHelperSelenium does not properly handle if an exception occurs in the script it runs in the browser to execute the ace Checker.
For example, a protractor test that executes the following:
await browser.waitForAngularEnabled(false);
await browser.get('https://ace.c9.io/build/kitchen-sink.html');
const report = await aChecker.getCompliance(browser, 'test');
will throw the following exception
TypeError: Cannot read property 'length' of undefined
at Function.ACReportManager.setLevels (F:\repos\OSS\protractor-min-code\node_modules\src-ts\lib\ACReportManager.ts:532:34)
at F:\repos\OSS\protractor-min-code\node_modules\src-ts\lib\ACHelper.ts:255:34
at step (F:\repos\OSS\protractor-min-code\node_modules\accessibility-checker\lib\ACHelper.js:33:23)
at Object.next (F:\repos\OSS\protractor-min-code\node_modules\accessibility-checker\lib\ACHelper.js:14:53)
at fulfilled (F:\repos\OSS\protractor-min-code\node_modules\accessibility-checker\lib\ACHelper.js:5:58)
When in fact the script that ACHelper.getComplianceHelperSelenium runs to actually run the ace.Checker failed with an exception: TypeError: window.ace.Checker is not a function. This is because the page is using an embedded ace code editor causing the accessibility-checker framework to fail to load due to #331.
I would expect that if the report failed to generate it would throw an error with some detail of the underlying error instead of trying to continue processing and throwing an exception in a different location as a result.
Steps to reproduce the issue
- navigate a protractor browser to https://ace.c9.io/build/kitchen-sink.html
- run
aChecker.getCompliance(browser, test);
Additional information
- Sample protractor project that reproduces the bug: ace-test.zip
- Run
npm install && npm testto run.
- Run
Created #331 to track the issue of loading into a page that already has ace