forked from mirrors/gecko-dev
		
	Bug 1578623 add test for syntax errors and uncaught exceptions in worklet 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
This commit is contained in:
		
							parent
							
								
									934b121f44
								
							
						
					
					
						commit
						8b101b80b5
					
				
					 7 changed files with 89 additions and 1 deletions
				
			
		|  | @ -149,6 +149,9 @@ devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js | |||
| devtools/server/tests/unit/setBreakpoint* | ||||
| devtools/server/tests/unit/sourcemapped.js | ||||
| 
 | ||||
| # Testing syntax error | ||||
| devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js | ||||
| 
 | ||||
| # devtools specific format test file | ||||
| devtools/server/tests/unit/xpcshell_debugging_script.js | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,7 +4,10 @@ module.exports = { | |||
|   // Extend from the shared list of defined globals for mochitests.
 | ||||
|   "extends": "../../../../.eslintrc.mochitests.js", | ||||
|   "overrides": [{ | ||||
|     "files": ["test-dynamic-import.js"], | ||||
|     "files": [ | ||||
|       "test-dynamic-import.js", | ||||
|       "test-error-worklet.js", | ||||
|     ], | ||||
|     "parserOptions": { | ||||
|       "sourceType": "module", | ||||
|     }, | ||||
|  |  | |||
|  | @ -59,6 +59,8 @@ support-files = | |||
|   test-error-worker.html | ||||
|   test-error-worker.js | ||||
|   test-error-worker2.js | ||||
|   test-error-worklet.html | ||||
|   test-error-worklet.js | ||||
|   test-eval-error.html | ||||
|   test-eval-in-stackframe.html | ||||
|   test-eval-sources.html | ||||
|  | @ -140,6 +142,7 @@ support-files = | |||
|   test-subresource-security-error.html | ||||
|   test-subresource-security-error.js | ||||
|   test-subresource-security-error.js^headers^ | ||||
|   test-syntaxerror-worklet.js | ||||
|   test-time-methods.html | ||||
|   test-trackingprotection-securityerrors.html | ||||
|   test-warning-groups.html | ||||
|  | @ -501,3 +504,4 @@ skip-if = (os == "win" && bits == 32) && !debug # Bug 1560261 | |||
| [browser_webconsole_websocket.js] | ||||
| [browser_webconsole_worker_error.js] | ||||
| [browser_webconsole_worker_evaluate.js] | ||||
| [browser_webconsole_worklet_error.js] | ||||
|  |  | |||
|  | @ -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]); | ||||
| }); | ||||
|  | @ -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> | ||||
|  | @ -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(); | ||||
|  | @ -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) {} | ||||
		Loading…
	
		Reference in a new issue
	
	 Karl Tomlinson
						Karl Tomlinson