test_console_eval-01.js (867B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* 7 * Check that is possible to evaluate JS with evaluation timeouts in place. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ commands }) => { 12 await commands.scriptCommand.execute(` 13 function fib(n) { 14 if (n == 1 || n == 0) { 15 return 1; 16 } 17 18 return fib(n-1) + fib(n-2) 19 } 20 `); 21 22 const normalResult = await commands.scriptCommand.execute("fib(1)", { 23 eager: true, 24 }); 25 Assert.equal(normalResult.result, 1, "normal eval"); 26 27 const timeoutResult = await commands.scriptCommand.execute("fib(100)", { 28 eager: true, 29 }); 30 Assert.equal(typeof timeoutResult.result, "object", "timeout eval"); 31 Assert.equal(timeoutResult.result.type, "undefined", "timeout eval type"); 32 }) 33 );