-
-
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.
chore(innate): add accessibility tree building
- Loading branch information
Showing
21 changed files
with
1,116 additions
and
86 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
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,17 @@ | ||
import type { RunnerConfig } from "../config"; | ||
|
||
// get all the css of the document to send to rust | ||
export const getAllCss = async (config: RunnerConfig) => { | ||
return await config.page.evaluate(() => { | ||
return [...document.styleSheets] | ||
.map((styleSheet) => { | ||
try { | ||
return [...styleSheet.cssRules].map((rule) => rule.cssText).join(""); | ||
} catch (e) { | ||
console.log("Access to stylesheet %s is denied.", styleSheet.href); | ||
} | ||
}) | ||
.filter(Boolean) | ||
.join("\n"); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export { extractLinks } from "./extract"; | ||
export { getAllCss } from "./css"; | ||
export { innateAudit } from "./rust-audit"; |
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,31 @@ | ||
import { audit } from "kayle_innate"; | ||
import { runActionsList } from "../action"; | ||
import { getAllCss } from "./css"; | ||
import type { RunnerConf } from "../common"; | ||
import { goToPage, setNetworkInterception } from "../utils/go-to-page"; | ||
import { RunnerConfig } from "../config"; | ||
import { Watcher } from "../watcher"; | ||
import { extractArgs } from "../option"; | ||
|
||
// perform audit using kayle innate @note: should not be used in production | ||
export const innateAudit = async (o: RunnerConf) => { | ||
console.log("NOT READY YET. Do not use."); | ||
const watcher = new Watcher(); | ||
const config = extractArgs(o, watcher); | ||
|
||
const navigate = | ||
config.page.url() === "about:blank" && (config.origin || o.html); | ||
|
||
if (navigate) { | ||
await goToPage(config); | ||
} else if (!config.noIntercept) { | ||
await setNetworkInterception(config); | ||
} | ||
|
||
await runActionsList(config as RunnerConfig); | ||
const html = await config.page.content(); | ||
const allCss = await getAllCss(config as RunnerConfig); | ||
const results = await audit(html, allCss); | ||
|
||
return results; | ||
}; |
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,26 @@ | ||
import puppeteer from "puppeteer"; | ||
import { innateAudit } from "kayle"; | ||
import { drakeMock } from "./mocks/html-mock"; | ||
import { performance } from "perf_hooks"; | ||
|
||
// setup test for rust wasm auditing | ||
(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(); | ||
await innateAudit({ | ||
page, | ||
browser, | ||
runners: ["htmlcs"], | ||
includeWarnings: true, | ||
origin: "https://www.drake.com", | ||
html: drakeMock | ||
}); | ||
const nextTime = performance.now() - startTime; | ||
console.log("time took", nextTime); | ||
|
||
await browser.close(); | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
// accessibility rules todo: |
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 @@ | ||
// support for based locales in readme |
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
Oops, something went wrong.