Source code
Revision control
Copy as Markdown
Other Tools
// Any copyright is dedicated to the Public Domain.
"use strict";
// A shared worker that, on request, parks itself in a nested sync loop by
// running a synchronous XHR whose response the server delays. The bfcache
// freeze/thaw driven by the test then lands while the worker is stuck in that
// sync loop, which is the scenario that used to deadlock the content process
/* global onconnect */
onconnect = function (e) {
const port = e.ports[0];
port.onmessage = function (ev) {
if (ev.data !== "start") {
return;
}
// Tell the test we are about to enter the sync loop, then block in a
// synchronous XHR. Posting first is safe: delivery to the frame is not
// gated on this worker thread, which is about to block.
port.postMessage("insync");
try {
const xhr = new XMLHttpRequest();
xhr.open("GET", "remoteDebugger_freeze_syncloop_hang.sjs", false);
xhr.send();
port.postMessage("done:" + xhr.responseText);
} catch (err) {
port.postMessage("error:" + err);
}
};
port.start();
};