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'); |
| 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'); |
| 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. commi
t). |
| 62 requestAnimationFrame(function() { |
| 63 worker.postMessage({}); |
| 64 }); |
| 65 } |
| 66 </script> |
OLD | NEW |