| 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 layers = JSON.parse(window.internals.layerTreeAsText(document))["lay
ers"]; |
| 13 assert_equals(1, docLayer.children.length); | 13 assert_equals(1, layers.length); |
| 14 assert_equals('undefined', typeof docLayer.children[0].children); | |
| 15 | 14 |
| 16 // Creating a proxy should force the container to have a layer. | 15 // Creating a proxy should force the container to have a layer. |
| 17 var proxy = new CompositorProxy(container, ['opacity']); | 16 var proxy = new CompositorProxy(container, ['opacity']); |
| 18 docLayer = JSON.parse(window.internals.layerTreeAsText(document, interna
ls.LAYER_TREE_INCLUDES_COMPOSITING_REASONS)); | 17 layers = JSON.parse(window.internals.layerTreeAsText(document, |
| 19 assert_equals(1, docLayer.children.length); | 18 internals.LAYER_TREE_INCLUDES_COMPOSITING_REASONS))["layers"]; |
| 20 assert_equals(1, docLayer.children[0].children.length); | 19 assert_equals(2, layers.length); |
| 21 assert_in_array('compositorProxy', docLayer.children[0].children[0].comp
ositingReasons); | 20 assert_in_array('compositorProxy', layers[1].compositingReasons); |
| 22 | 21 |
| 23 // Detach the element from the document. The corresponding layer should
be removed. | 22 // Detach the element from the document. The corresponding layer should
be removed. |
| 24 container.parentNode.removeChild(container); | 23 container.parentNode.removeChild(container); |
| 25 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 24 layers = JSON.parse(window.internals.layerTreeAsText(document))["layers"
]; |
| 26 assert_equals(1, docLayer.children.length); | 25 assert_equals(1, layers.length); |
| 27 assert_equals('undefined', typeof docLayer.children[0].children); | |
| 28 | 26 |
| 29 // Add the element back to the document. The corresponding layer should
reappear. | 27 // Add the element back to the document. The corresponding layer should
reappear. |
| 30 document.body.appendChild(container); | 28 document.body.appendChild(container); |
| 31 docLayer = JSON.parse(window.internals.layerTreeAsText(document, interna
ls.LAYER_TREE_INCLUDES_COMPOSITING_REASONS)); | 29 layers = JSON.parse(window.internals.layerTreeAsText(document, internals
.LAYER_TREE_INCLUDES_COMPOSITING_REASONS))["layers"]; |
| 32 assert_equals(1, docLayer.children.length); | 30 assert_equals(2, layers.length); |
| 33 assert_equals(1, docLayer.children[0].children.length); | 31 assert_in_array('compositorProxy', layers[1].compositingReasons); |
| 34 assert_in_array('compositorProxy', docLayer.children[0].children[0].comp
ositingReasons); | |
| 35 | 32 |
| 36 // Disconnecting the proxy should also remove the layer. | 33 // Disconnecting the proxy should also remove the layer. |
| 37 proxy.disconnect(); | 34 proxy.disconnect(); |
| 38 docLayer = JSON.parse(window.internals.layerTreeAsText(document)); | 35 layers = JSON.parse(window.internals.layerTreeAsText(document))["layers"
]; |
| 39 assert_equals(1, docLayer.children.length); | 36 assert_equals(1, layers.length); |
| 40 assert_equals('undefined', typeof docLayer.children[0].children); | |
| 41 | 37 |
| 42 test.done(); | 38 test.done(); |
| 43 }); | 39 }); |
| 44 }, "This test checks that creating a CompositorProxy forces the element to have
a layer"); | 40 }, "This test checks that creating a CompositorProxy forces the element to have
a layer"); |
| 45 </script> | 41 </script> |
| OLD | NEW |