OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 | |
3 <style> | |
4 #box { | |
5 width: 100px; | |
6 height: 100px; | |
7 overflow: scroll; | |
8 } | |
9 | |
10 #scrolled { | |
11 background: white; | |
12 width: 300px; | |
13 height: 300px; | |
14 } | |
15 </style> | |
16 | |
17 <div id="box"> | |
18 <div id="scrolled"></div> | |
19 </div> | |
20 | |
21 <script src="../../../../resources/testharness.js"></script> | |
22 <script src="../../../../resources/testharnessreport.js"></script> | |
23 <script> | |
24 if (window.internals) | |
25 internals.settings.setCompositorWorkerEnabled(true); | |
26 | |
27 var test = async_test('Tests that a change from the main thread is received on t he compositor thread'); | |
jbroman
2016/06/13 19:45:17
This test is a little weird to read, because of th
majidvp
2016/06/13 21:52:51
Acknowledged.
| |
28 var worker; | |
29 | |
30 test.step(function(){ | |
31 worker = new CompositorWorker('resources/basic-plumbing-main-to-worker.js'); | |
32 worker.onmessage = test.step_func(function(e){ | |
33 assert_equals(e.data.opacity, 1); | |
34 assert_equals(e.data.scrollLeft, 0); | |
35 assert_equals(e.data.scrollTop, 0); | |
36 assert_equals(JSON.stringify(e.data.transform), '{"0":1,"1":0,"2":0,"3":0,"4 ":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1}'); | |
37 | |
38 updateElementAndVerify(); | |
39 }); | |
40 | |
41 var keys = ['opacity', 'transform', 'scrollTop', 'scrollLeft']; | |
42 worker.postMessage({'proxy': new CompositorProxy(document.getElementById('box' ), keys)}); | |
43 }); | |
44 | |
45 function updateElementAndVerify(e) { | |
46 var element = document.getElementById('box'); | |
jbroman
2016/06/13 19:45:17
nit: inconsistent indentation (I think Blink still
majidvp
2016/06/13 21:52:51
Done.
| |
47 element.scrollLeft = 10; | |
48 element.scrollTop = 20; | |
49 element.style.transform = 'translate3d(30px, 0, 0)'; | |
50 element.style.opacity = 0.5; | |
51 | |
52 worker.onmessage = test.step_func(function(e){ | |
53 assert_equals(e.data.opacity, 0.5); | |
54 assert_equals(e.data.scrollLeft, 10); | |
55 assert_equals(e.data.scrollTop, 20); | |
56 assert_equals(JSON.stringify(e.data.transform), '{"0":1,"1":0,"2":0,"3":0, "4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":30,"13":0,"14":0,"15":1}' ); | |
57 | |
58 test.done(); | |
59 }); | |
60 | |
61 // Delay posting to the compositor until we have had another frame (i.e. com mit). | |
62 setTimeout(function(){ | |
jbroman
2016/06/13 19:45:17
Are you sure you want setTimeout and not requestAn
majidvp
2016/06/13 21:52:51
Actually, setTimeout is not needed here. Removed.
| |
63 requestAnimationFrame(function() { | |
64 worker.postMessage({}); | |
65 }) | |
66 }, 0); | |
67 } | |
68 </script> | |
OLD | NEW |