OLD | NEW |
| (Empty) |
1 // Given a set of 'tests', runs them in the worklet, then comparing the | |
2 // expectedError or the expectedMessage. | |
3 // | |
4 // Usage: | |
5 // runner([{/* test1 */}, { /* test2 */}]); | |
6 function runner(tests) { | |
7 if (window.testRunner) { | |
8 testRunner.waitUntilDone(); | |
9 testRunner.dumpAsText(); | |
10 } | |
11 | |
12 tests.reduce(function(chain, obj) { | |
13 return chain.then(function() { | |
14 if (obj.expectedError) { | |
15 console.log('The worklet should throw an error with: "' + obj.ex
pectedError + '"'); | |
16 } else if (obj.expectedMessage) { | |
17 console.log('The worklet should log a warning with: "' + obj.exp
ectedMessage + '"'); | |
18 } else { | |
19 console.log('The worklet should not throw an error.'); | |
20 } | |
21 var blob = new Blob([obj.script], {type: 'text/javascript'}); | |
22 return paintWorklet.addModule(URL.createObjectURL(blob)); | |
23 }); | |
24 }, Promise.resolve()).then(function() { | |
25 if (window.testRunner) { | |
26 testRunner.notifyDone(); | |
27 } | |
28 }); | |
29 } | |
OLD | NEW |