Bug 1819146, don't try to use destroyed global when accessing signal's reason, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D172131
This commit is contained in:
Olli Pettay 2023-03-10 15:14:32 +00:00
parent a11e1155cc
commit 2d7c41e636
3 changed files with 31 additions and 3 deletions

View file

@ -97,9 +97,13 @@ static bool ValidateRequestArguments(const nsAString& name,
return false;
}
if (options.mSignal.Value().Aborted()) {
AutoEntryScript aes(options.mSignal.Value().GetParentObject(),
"LockManager::Request");
JSContext* cx = aes.cx();
AutoJSAPI jsapi;
if (!jsapi.Init(options.mSignal.Value().GetParentObject())) {
aRv.ThrowNotSupportedError("Signal's realm isn't active anymore.");
return false;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> reason(cx);
options.mSignal.Value().GetReason(cx, &reason);
aRv.MightThrowJSException();

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<script id="worker1" type="javascript/worker">
self.onmessage = async function (e) {
const abort = new AbortController()
const signal = abort.signal
abort.abort()
close()
try { await fetch(undefined, { signal: signal }) } catch (e) {}
await navigator.locks.request("weblock_0", { signal: signal }, () => {})
await fetch(undefined, { headers: [] })
}
</script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const blob = new Blob([document.querySelector('#worker1').textContent], { type: 'text/javascript' })
const worker = new Worker(window.URL.createObjectURL(blob))
worker.postMessage([], [])
})
</script>
</head>
</html>

View file

@ -4,3 +4,4 @@ load 1153636.html
load 1158031.html
load 1228456.html
load 1348882.html
load 1819146.html