mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-22 08:00:45 +00:00
They are only valid in a Window context, and the spec only exposes them in Window contexts. Fixes workers crashing on: - https://web.whatsapp.com/ - https://pro.kraken.com/app/trade/btc-usd
36 lines
1.4 KiB
HTML
36 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<script type="worker">
|
|
globalThis.onmessage = () => {
|
|
const result = [];
|
|
result.push("(worker) navigation: " + typeof performance.navigation);
|
|
result.push("(worker) timing: " + typeof performance.timing);
|
|
result.push("(worker) performance JSON: " + JSON.stringify(performance));
|
|
postMessage(result);
|
|
}
|
|
</script>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
asyncTest((done) => {
|
|
const replacePotentiallyFlakyTimes = (string) => {
|
|
return string.replace(/("[a-zA-Z]+":)(\d+(\.\d+)?)/g, "$1[removed-potentially-flaky-time-value]");
|
|
};
|
|
|
|
println("(window) navigation: " + typeof performance.navigation);
|
|
println("(window) timing: " + typeof performance.timing);
|
|
println("(window) performance JSON: " + replacePotentiallyFlakyTimes(JSON.stringify(performance)));
|
|
|
|
const workerSource = document.querySelector('[type=worker]').innerText;
|
|
const workerBlob = new Blob([workerSource], { type: "text/javascript" });
|
|
const workerBlobURL = URL.createObjectURL(workerBlob);
|
|
const worker = new Worker(workerBlobURL);
|
|
worker.onmessage = ({ data }) => {
|
|
for (const string of data) {
|
|
println(replacePotentiallyFlakyTimes(string));
|
|
}
|
|
|
|
done();
|
|
};
|
|
|
|
worker.postMessage("start");
|
|
});
|
|
</script>
|