ladybird/Tests/LibWeb/Text/input/error-stack-must-contain-full-url.html
Luke Wilde 847589404b LibWeb: Set filename of module scripts to full URL instead of basename
Atlassian login gets the base URL for its module scripts by throwing an
error and pulling out the current script's URL from error.stack with
regex.

Since we only returned a basename for module scripts, it would fail to
match and try and use `/` as a base URL (because it does
[matched_string] + "/"), which is not a valid base URL.
2025-08-26 15:46:45 +02:00

43 lines
1.4 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;
globalThis.println("${type}: " + e.stack.replace(uuidRegex, "[flaky-uuid-replaced]"));
}
`;
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>