Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <div id="container"></div> | 2 <div id="container"></div> |
| 3 <script src="../../../resources/testharness.js"></script> | 3 <script src="../../../resources/testharness.js"></script> |
| 4 <script src="../../../resources/testharnessreport.js"></script> | 4 <script src="../../../resources/testharnessreport.js"></script> |
| 5 <script> | 5 <script> |
| 6 async_test(function(test) { | 6 async_test(function(test) { |
| 7 if (!window.internals) | 7 if (!window.internals) |
| 8 return; | 8 return; |
| 9 window.addEventListener('load', function() { | 9 window.addEventListener('load', function() { |
| 10 // The container should not have a layer. | 10 // The container should not have a layer. |
| 11 var container = document.getElementById('container'); | 11 var container = document.getElementById('container'); |
| 12 var docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 12 var docLayer = JSON.parse(window.internals.layerTreeAsText(document)); |
| 13 assert_equals(1, docLayer.children.length); | 13 assert_equals(1, docLayer.children.length); |
| 14 assert_equals('undefined', typeof docLayer.children[0].children); | 14 assert_equals('undefined', typeof docLayer.children[0].children); |
| 15 | 15 |
| 16 // Creating a proxy should force the container to have a layer. | 16 // Creating a proxy should force the container to have a layer. |
| 17 var proxy = new CompositorProxy(container, ['opacity']); | 17 var proxy = new CompositorProxy(container, ['opacity']); |
| 18 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 18 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); |
| 19 assert_equals(1, docLayer.children.length); | 19 assert_equals(1, docLayer.children.length); |
| 20 assert_equals(1, docLayer.children[0].children.length); | 20 assert_equals(1, docLayer.children[0].children.length); |
| 21 assert_not_equals(docLayer.children[0].children[0].compositingReasons.in dexOf("compositorProxy"), -1); | |
|
esprehn
2015/05/25 21:05:43
assert_true(...compositingReasons.includes("compos
sadrul
2015/05/25 21:08:45
compositingReasons is actually an array, and there
esprehn
2015/05/25 21:13:13
Oh then you want to use assert_in_array then.
sadrul
2015/05/25 21:19:32
Nice! Done. Thanks! (I looked for something like a
| |
| 21 | 22 |
| 22 // Detach the element from the document. The corresponding layer should be removed. | 23 // Detach the element from the document. The corresponding layer should be removed. |
| 23 container.parentNode.removeChild(container); | 24 container.parentNode.removeChild(container); |
| 24 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 25 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); |
| 25 assert_equals(1, docLayer.children.length); | 26 assert_equals(1, docLayer.children.length); |
| 26 assert_equals('undefined', typeof docLayer.children[0].children); | 27 assert_equals('undefined', typeof docLayer.children[0].children); |
| 27 | 28 |
| 28 // Add the element back to the document. The corresponding layer should reappear. | 29 // Add the element back to the document. The corresponding layer should reappear. |
| 29 document.body.appendChild(container); | 30 document.body.appendChild(container); |
| 30 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 31 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); |
| 31 assert_equals(1, docLayer.children.length); | 32 assert_equals(1, docLayer.children.length); |
| 32 assert_equals(1, docLayer.children[0].children.length); | 33 assert_equals(1, docLayer.children[0].children.length); |
| 34 assert_not_equals(docLayer.children[0].children[0].compositingReasons.in dexOf("compositorProxy"), -1); | |
| 33 | 35 |
| 34 // Disconnecting the proxy should also remove the layer. | 36 // Disconnecting the proxy should also remove the layer. |
| 35 proxy.disconnect(); | 37 proxy.disconnect(); |
| 36 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 38 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); |
| 37 assert_equals(1, docLayer.children.length); | 39 assert_equals(1, docLayer.children.length); |
| 38 assert_equals('undefined', typeof docLayer.children[0].children); | 40 assert_equals('undefined', typeof docLayer.children[0].children); |
| 39 | 41 |
| 40 test.done(); | 42 test.done(); |
| 41 }); | 43 }); |
| 42 }, "This test checks that creating a CompositorProxy forces the element to have a layer"); | 44 }, "This test checks that creating a CompositorProxy forces the element to have a layer"); |
| 43 </script> | 45 </script> |
| OLD | NEW |