OLD | NEW |
| (Empty) |
1 // Test runner for the paint worklet. | |
2 // | |
3 // Calls a given function with a newly created element, and prints the expected | |
4 // geometry to the console. | |
5 // | |
6 // Runs each test sequentially after a layout and a paint. | |
7 // | |
8 // Usage: | |
9 // testRunnerGeometryLogging([{ | |
10 // func: function(el) { | |
11 // el.style.width = '100px'; | |
12 // el.style.height = '100px'; | |
13 // }, | |
14 // expected: {width: 100, height: 100}, | |
15 // ]); | |
16 | |
17 function testRunnerGeometryLogging(tests, workletCode) { | |
18 if (window.testRunner) { | |
19 testRunner.waitUntilDone(); | |
20 testRunner.dumpAsText(); | |
21 } | |
22 | |
23 paintWorklet.addModule('resources/paint-logging-green.js').then(function() { | |
24 tests.reduce(function(chain, obj) { | |
25 return chain.then(function() { | |
26 console.log('The worklet should log: \'width: ' + obj.expected.w
idth + ', height: ' + obj.expected.height + '\''); | |
27 var el = document.createElement('div'); | |
28 document.body.appendChild(el); | |
29 obj.func(el); | |
30 return new Promise(function(resolve) { | |
31 runAfterLayoutAndPaint(function() { | |
32 document.body.removeChild(el); | |
33 resolve(); | |
34 }); | |
35 }); | |
36 }); | |
37 }, Promise.resolve()).then(function() { | |
38 if (window.testRunner) { | |
39 testRunner.notifyDone(); | |
40 } | |
41 }); | |
42 }); | |
43 } | |
OLD | NEW |