зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1558786 - Test console message for promise rejection in Worker/Worklet. r=baku
Differential Revision: https://phabricator.services.mozilla.com/D70448 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3521ab2e07
Коммит
c10bff4e57
|
@ -157,6 +157,7 @@ support-files =
|
|||
test-warning-groups.html
|
||||
test-websocket.html
|
||||
test-websocket.js
|
||||
test-worker-promise-error.html
|
||||
testscript.js
|
||||
!/devtools/client/netmonitor/test/sjs_cors-test-server.sjs
|
||||
!/image/test/mochitest/blue.png
|
||||
|
@ -382,5 +383,6 @@ skip-if = fission # Bug 1578594
|
|||
[browser_webconsole_websocket.js]
|
||||
[browser_webconsole_worker_error.js]
|
||||
[browser_webconsole_worker_evaluate.js]
|
||||
[browser_webconsole_worker_promise_error.js]
|
||||
[browser_webconsole_worklet_error.js]
|
||||
skip-if = fission #Bug 1580565
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Tests that an uncaught promise rejection inside a Worker or Worklet
|
||||
// is reported to the tabs' webconsole.
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI =
|
||||
"https://example.com/browser/devtools/client/webconsole/" +
|
||||
"test/browser/test-worker-promise-error.html";
|
||||
|
||||
add_task(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.audioworklet.enabled", true],
|
||||
["dom.worklet.enabled", true],
|
||||
],
|
||||
});
|
||||
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
await waitFor(() =>
|
||||
findMessage(hud, "uncaught exception: worker-error", ".message.error")
|
||||
);
|
||||
|
||||
await waitFor(() =>
|
||||
findMessage(hud, "uncaught exception: worklet-error", ".message.error")
|
||||
);
|
||||
|
||||
ok(true, "received error messages");
|
||||
});
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Worker/Worklet promise error</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// Promise rejection in Worker (via async function)
|
||||
const workerScript = `
|
||||
self.onmessage = async () => {
|
||||
throw "worker-error"
|
||||
}
|
||||
`;
|
||||
const workerScriptUrl = URL.createObjectURL(new Blob([workerScript]));
|
||||
const worker = new Worker(workerScriptUrl);
|
||||
worker.postMessage({});
|
||||
|
||||
// Promise rejection in Worklet (via async function)
|
||||
const workletScript = `
|
||||
async function throw_process() {
|
||||
throw "worklet-error";
|
||||
}
|
||||
|
||||
class ErrorProcessor extends AudioWorkletProcessor {
|
||||
process() {
|
||||
throw_process();
|
||||
}
|
||||
}
|
||||
registerProcessor("error", ErrorProcessor);
|
||||
`;
|
||||
const workletScriptUrl = URL.createObjectURL(new Blob([workletScript]));
|
||||
const context = new AudioContext();
|
||||
context.audioWorklet.addModule(workletScriptUrl).then(() => {
|
||||
const workletNode = new AudioWorkletNode(context, "error");
|
||||
const oscillator = new OscillatorNode(context);
|
||||
oscillator.connect(workletNode);
|
||||
oscillator.start();
|
||||
oscillator.stop();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче