27 lines
828 B
JavaScript
27 lines
828 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { renderPage } from "../src/archiver.mjs";
|
|
|
|
test("renderPage serializes CSSOM-inserted style rules", async () => {
|
|
const html = `<!doctype html>
|
|
<html>
|
|
<head>
|
|
<style id="runtime-style"></style>
|
|
<script>
|
|
document
|
|
.getElementById("runtime-style")
|
|
.sheet
|
|
.insertRule(".runtime-rule { color: rgb(1, 2, 3); }", 0);
|
|
</script>
|
|
</head>
|
|
<body><div class="runtime-rule">Styled by CSSOM</div></body>
|
|
</html>`;
|
|
|
|
const rendered = await renderPage(`data:text/html,${encodeURIComponent(html)}`, {
|
|
userscriptDelay: 0
|
|
});
|
|
|
|
assert.match(rendered, /<style id="runtime-style">[\s\S]*\.runtime-rule/);
|
|
assert.match(rendered, /color:\s*rgb\(1,\s*2,\s*3\)/);
|
|
});
|