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, interna
ls.LAYER_TREE_INCLUDES_COMPOSITING_REASONS)); |
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_in_array('compositorProxy', docLayer.children[0].children[0].comp
ositingReasons); |
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, interna
ls.LAYER_TREE_INCLUDES_COMPOSITING_REASONS)); |
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_in_array('compositorProxy', docLayer.children[0].children[0].comp
ositingReasons); |
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 |