-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runner): add ace accessibility ibm
- Loading branch information
Showing
8 changed files
with
164 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const run = async (options) => { | ||
return new Promise((resolve, reject) => { | ||
if ( | ||
// @ts-ignore | ||
typeof window.define === "function" && | ||
// @ts-ignore | ||
window.define.amd && | ||
typeof window.require === "function" | ||
) { | ||
// @ts-ignore module load | ||
window.require(["accessibility-checker-engine"], (ace) => { | ||
Object.keys(ace).forEach((key) => { | ||
window[key] = ace[key]; | ||
}); | ||
// @ts-ignore set the window runner | ||
window.ace = ace; | ||
}); | ||
} | ||
|
||
// @ts-ignore | ||
const checker = new ace.Checker(); | ||
|
||
checker | ||
.check( | ||
(options.rootElement && | ||
window.document.querySelector(options.rootElement)) || | ||
window.document, | ||
["IBM_Accessibility"] | ||
) | ||
.then((report) => { | ||
resolve(report.results); | ||
}); | ||
}); | ||
}; | ||
|
||
const aceRunner = { | ||
en: { | ||
scripts: [require.resolve("accessibility-checker-engine/ace.js")], | ||
run, | ||
}, | ||
}; | ||
|
||
// // hard code locales to the list to htmlcs locales not EN | ||
// const locales = ["fr", "es", "it", "ja", "nl", "pl", "zh_CN", "zh_TW"]; | ||
|
||
// for (const lang of locales) { | ||
// ibmRunner[lang.replace("_", "-")] = { | ||
// scripts: [require.resolve(`fast_htmlcs/build/HTMLCS.${lang}.js`)], | ||
// run, | ||
// }; | ||
// } | ||
|
||
export { aceRunner }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import assert from "assert"; | ||
import puppeteer from "puppeteer"; | ||
import { kayle } from "kayle"; | ||
import { drakeMock } from "./mocks/html-mock"; | ||
import { performance } from "perf_hooks"; | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({ headless: "new" }); | ||
const page = await browser.newPage(); | ||
if (process.env.LOG_ENABLED) { | ||
page.on("console", (msg) => console.log("PAGE LOG:", msg.text())); | ||
} | ||
const startTime = performance.now(); | ||
const { issues, pageUrl, documentTitle, meta, automateable } = await kayle({ | ||
page, | ||
browser, | ||
runners: ["ace"], | ||
includeWarnings: true, | ||
html: drakeMock, | ||
origin: "https://www.drake.com", // origin is the fake url in place of the raw content | ||
}); | ||
const nextTime = performance.now() - startTime; | ||
|
||
console.log(issues); | ||
console.log(meta); | ||
console.log(automateable); | ||
console.log("time took", nextTime); | ||
|
||
// valid list | ||
assert(Array.isArray(issues)); | ||
assert(meta.errorCount === 55); | ||
assert(meta.warningCount === 42); | ||
// TODO: IBM ACE accessibility error handling | ||
// assert(meta.accessScore === 50); | ||
|
||
assert(typeof pageUrl === "string"); | ||
assert(typeof documentTitle === "string"); | ||
|
||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters