Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script> | |
| 5 function runner(tests) { | |
| 6 if (window.testRunner) { | |
| 7 testRunner.waitUntilDone(); | |
| 8 testRunner.dumpAsText(); | |
| 9 } | |
| 10 | |
| 11 tests.reduce(function(chain, obj) { | |
|
ikilpatrick
2017/01/13 18:50:18
can you pull this out into a common js file?
renjieliu1
2017/01/15 05:05:20
Done.
| |
| 12 return chain.then(function() { | |
| 13 if (obj.expectedError) { | |
| 14 console.log('The worklet should throw an error with: "' + obj.ex pectedError + '"'); | |
| 15 } else if (obj.expectedMessage) { | |
| 16 console.log('The worklet should log a warning with: "' + obj.exp ectedMessage + '"'); | |
| 17 } else { | |
| 18 console.log('The worklet should not throw an error.'); | |
| 19 } | |
| 20 var blob = new Blob([obj.script], {type: 'text/javascript'}); | |
| 21 return paintWorklet.import(URL.createObjectURL(blob)); | |
| 22 }); | |
| 23 }, Promise.resolve()).then(function() { | |
| 24 if (window.testRunner) { | |
| 25 testRunner.notifyDone(); | |
| 26 } | |
| 27 }); | |
| 28 } | |
| 29 | |
| 30 function runTest() { | |
| 31 runner([{ | |
| 32 expectedError: "failed!", | |
| 33 script: "registerPaint('foo', class { static get inputArguments() { throw Error('failed!'); } });", | |
| 34 }, { | |
| 35 expectedError: " Failed to execute 'registerPaint' on 'PaintWorkletGlobalS cope': The value provided is neither an array, nor does it have indexed properti es.", | |
| 36 script: "registerPaint('foo1', class { static get inputArguments() { retur n 'non sense stuff'; } });", | |
| 37 }, { | |
| 38 expectedError: "Failed to execute 'registerPaint' on 'PaintWorkletGlobalSc ope': Invalid argument types.", | |
| 39 script: "registerPaint('foo2', class { static get inputArguments() { retur n ['<non-sense-type>'] } });", | |
| 40 }, { | |
| 41 script: "registerPaint('foo3', class { static get inputArguments(){return ['<length>'];} paint() { } }); console.log('Success for \\'foo\\'.');", | |
| 42 }]); | |
| 43 } | |
| 44 </script> | |
| 45 </head> | |
| 46 <body onload="runTest()"> | |
| 47 <p>This tests a series of PaintWorkletGlobalScope#registerPaint Parse Input Argu ments calls.</p> | |
| 48 <p>See the devtools console for test output.</p> | |
| 49 </body> | |
| 50 </html> | |
| OLD | NEW |