Files
ladybird/Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html
Shannon Booth 4a79bd98d2 Tests/LibWeb: Support opaque file origins for error stack test
When files have an opaque origin, the "file" scheme is omitted from the
blob URL serialization in the stack trace.

This change normalizes the output in the test so that both tuple
file origins and opaque file origins (which may serialize as
'blob:ladybird/') is accepted, ensuring the test passes in
both scenarios.
2026-02-21 23:00:57 +01:00

47 lines
1.6 KiB
HTML

<!DOCTYPE html>
<script src="include.js"></script>
<div id="script-container"></div>
<script>
asyncTest(async (done) => {
const scriptContainer = document.getElementById("script-container");
const createScript = (type) => {
return new Promise((resolve) => {
const scriptSource = `
try {
throw Error();
} catch (e) {
const uuidRegex = /[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+/g;
const normalizedStack = e.stack
.replace(uuidRegex, "[flaky-uuid-replaced]")
.replace(/blob:(file:\\/\\/\\/|ladybird\\/)/g, "blob:<origin>/");
globalThis.println("${type}: " + normalizedStack);
}
`;
const scriptBlob = new Blob([scriptSource], { type: "text/javascript" });
const scriptBlobUrl = URL.createObjectURL(scriptBlob);
const script = document.createElement("script");
script.onload = () => {
resolve();
};
script.src = scriptBlobUrl;
if (type !== "classic")
script.type = type;
scriptContainer.appendChild(script);
});
};
const scriptPromises = [
createScript("classic"),
createScript("module"),
];
await Promise.all(scriptPromises);
done();
});
</script>