| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="resources/test-runner-paint-helper.js"></script> |
| 4 <script> | 5 <script> |
| 5 function runner(tests) { | |
| 6 if (window.testRunner) { | |
| 7 testRunner.waitUntilDone(); | |
| 8 testRunner.dumpAsText(); | |
| 9 } | |
| 10 | |
| 11 tests.reduce(function(chain, obj) { | |
| 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() { | 6 function runTest() { |
| 31 runner([{ | 7 runner([{ |
| 32 expectedError: "A class with name:'foo' is already registered.", | 8 expectedError: "A class with name:'foo' is already registered.", |
| 33 script: "registerPaint('foo', class { paint() { } }); registerPaint('foo
', class { paint() { } });", | 9 script: "registerPaint('foo', class { paint() { } }); registerPaint('foo
', class { paint() { } });", |
| 34 }, { | 10 }, { |
| 35 expectedError: "The empty string is not a valid name.", | 11 expectedError: "The empty string is not a valid name.", |
| 36 script: "registerPaint('', class { });", | 12 script: "registerPaint('', class { });", |
| 37 }, { | 13 }, { |
| 38 expectedError: "failed!", | 14 expectedError: "failed!", |
| 39 script: "registerPaint('foo3', class { static get inputProperties() { th
row Error('failed!'); } });", | 15 script: "registerPaint('foo3', class { static get inputProperties() { th
row Error('failed!'); } });", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 65 script: "registerPaint('foo13', class { static get alpha() { return true
; } paint() { } }); console.log('Success for \\'foo13\\'.');", | 41 script: "registerPaint('foo13', class { static get alpha() { return true
; } paint() { } }); console.log('Success for \\'foo13\\'.');", |
| 66 }]); | 42 }]); |
| 67 } | 43 } |
| 68 </script> | 44 </script> |
| 69 </head> | 45 </head> |
| 70 <body onload="runTest()"> | 46 <body onload="runTest()"> |
| 71 <p>This tests a series of PaintWorkletGlobalScope#registerPaint calls.</p> | 47 <p>This tests a series of PaintWorkletGlobalScope#registerPaint calls.</p> |
| 72 <p>See the devtools console for test output.</p> | 48 <p>See the devtools console for test output.</p> |
| 73 </body> | 49 </body> |
| 74 </html> | 50 </html> |
| OLD | NEW |