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