Index: third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/basic-plumbing-main-to-worker.html |
diff --git a/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/basic-plumbing-main-to-worker.html b/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/basic-plumbing-main-to-worker.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1b30a154bbabe2f60c3b6e1e853ffd225d4b3a46 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/virtual/threaded/fast/compositorworker/basic-plumbing-main-to-worker.html |
@@ -0,0 +1,68 @@ |
+<!DOCTYPE html> |
+ |
+<style> |
+#box { |
+ width: 100px; |
+ height: 100px; |
+ overflow: scroll; |
+} |
+ |
+#scrolled { |
+ background: white; |
+ width: 300px; |
+ height: 300px; |
+} |
+</style> |
+ |
+<div id="box"> |
+ <div id="scrolled"></div> |
+</div> |
+ |
+<script src="../../../../resources/testharness.js"></script> |
+<script src="../../../../resources/testharnessreport.js"></script> |
+<script> |
+if (window.internals) |
+ internals.settings.setCompositorWorkerEnabled(true); |
+ |
+var test = async_test('Tests that a change from the main thread is received on the 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.
|
+var worker; |
+ |
+test.step(function(){ |
+ worker = new CompositorWorker('resources/basic-plumbing-main-to-worker.js'); |
+ worker.onmessage = test.step_func(function(e){ |
+ assert_equals(e.data.opacity, 1); |
+ assert_equals(e.data.scrollLeft, 0); |
+ assert_equals(e.data.scrollTop, 0); |
+ 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}'); |
+ |
+ updateElementAndVerify(); |
+ }); |
+ |
+ var keys = ['opacity', 'transform', 'scrollTop', 'scrollLeft']; |
+ worker.postMessage({'proxy': new CompositorProxy(document.getElementById('box'), keys)}); |
+}); |
+ |
+function updateElementAndVerify(e) { |
+ 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.
|
+ element.scrollLeft = 10; |
+ element.scrollTop = 20; |
+ element.style.transform = 'translate3d(30px, 0, 0)'; |
+ element.style.opacity = 0.5; |
+ |
+ worker.onmessage = test.step_func(function(e){ |
+ assert_equals(e.data.opacity, 0.5); |
+ assert_equals(e.data.scrollLeft, 10); |
+ assert_equals(e.data.scrollTop, 20); |
+ 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}'); |
+ |
+ test.done(); |
+ }); |
+ |
+ // Delay posting to the compositor until we have had another frame (i.e. commit). |
+ 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.
|
+ requestAnimationFrame(function() { |
+ worker.postMessage({}); |
+ }) |
+ }, 0); |
+} |
+</script> |