forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1578623 add test for syntax errors and uncaught exceptions in wor…
…klet scripts r=bhackett Depends on D44611 Differential Revision: https://phabricator.services.mozilla.com/D44612 --HG-- rename : devtools/client/webconsole/test/browser/browser_webconsole_worker_error.js => devtools/client/webconsole/test/browser/browser_webconsole_worklet_error.js extra : moz-landing-system : lando
- Loading branch information
Showing
7 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
devtools/client/webconsole/test/browser/browser_webconsole_worklet_error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
// Tests that syntax errors in worklet scripts show in the console and that | ||
// throwing uncaught errors and primitive values in worklets shows a stack. | ||
|
||
"use strict"; | ||
|
||
const TEST_URI = | ||
"https://example.com/browser/devtools/client/webconsole/" + | ||
"test/browser/test-error-worklet.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, "SyntaxError: duplicate formal argument") | ||
); | ||
ok(true, "Received expected SyntaxError"); | ||
|
||
await checkMessageStack(hud, "addModule", [18, 21]); | ||
await checkMessageStack(hud, "process", [7, 12]); | ||
}); |
24 changes: 24 additions & 0 deletions
24
devtools/client/webconsole/test/browser/test-error-worklet.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Worklet error generator</title> | ||
<!-- | ||
Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ | ||
--> | ||
</head> | ||
<script> | ||
"use strict"; | ||
const context = new AudioContext(); | ||
|
||
context.audioWorklet.addModule("test-syntaxerror-worklet.js").catch( | ||
() => context.audioWorklet.addModule("test-error-worklet.js") | ||
).then(() => { | ||
const workletNode = new AudioWorkletNode(context, "error"); | ||
const oscillator = new OscillatorNode(context); | ||
oscillator.connect(workletNode); | ||
oscillator.start(); | ||
}); | ||
|
||
</script> | ||
</html> |
21 changes: 21 additions & 0 deletions
21
devtools/client/webconsole/test/browser/test-error-worklet.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | ||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
function throw_process() { | ||
throw "process"; // eslint-disable-line no-throw-literal | ||
} | ||
|
||
class ErrorProcessor extends AudioWorkletProcessor { | ||
process() { | ||
throw_process(); | ||
} | ||
} | ||
registerProcessor("error", ErrorProcessor); | ||
|
||
function throw_error() { | ||
throw new Error("addModule"); | ||
} | ||
|
||
throw_error(); |
6 changes: 6 additions & 0 deletions
6
devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | ||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
function f(a, a) {} |