Add layout test for iframe contents disappearing on view unparent/reparent
[WebKit-https.git] / LayoutTests / compositing / iframes / remove-reinsert-webview-with-iframe.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5     <style>
6         iframe {
7             width: 400px;
8             height: 300px;
9         }
10         .composited {
11             transform: translateZ(1px);
12             padding: 10px;
13             width: 500px;
14         }
15
16         .masked {
17             -webkit-mask-image: url(../resources/alpha-gradient.png);
18             -webkit-mask-repeat: repeat-x;
19         }
20     </style>
21     <script>
22         if (window.testRunner) {
23             testRunner.dumpAsText();
24             testRunner.waitUntilDone();
25         }
26         
27         function geRemoveViewScript()
28         {
29             return `
30             (function() {
31                 uiController.removeViewFromWindow(function() {
32                     uiController.uiScriptComplete('');
33                 });
34             })();`
35         }
36         
37         function getReinsertViewScript()
38         {
39             return `
40             (function() {
41                 uiController.addViewToWindow(function() {
42                     uiController.uiScriptComplete('');
43                 });
44             })();`
45         }
46         
47         function getLayerTree()
48         {
49             if (window.internals)
50                 return internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
51             
52             return "";
53         }
54
55         function doTest()
56         {
57             if (!testRunner.runUIScript)
58                 return;
59
60             let beforeLayers = getLayerTree();
61
62             testRunner.runUIScript(geRemoveViewScript(), function(result) {
63                 
64                     testRunner.runUIScript(getReinsertViewScript(), function(result) {
65                         let afterLayers = getLayerTree();
66                         
67                         document.getElementById('before-layers').textContent = beforeLayers;
68                         document.getElementById('after-layers').textContent = afterLayers;
69                         
70                         testRunner.notifyDone();
71                     });
72             });
73         }
74         window.addEventListener('load', doTest, false);
75     </script>
76 </head>
77 <body>
78     <div class="composited">
79         <iframe src="resources/composited-subframe.html"></iframe>
80     </div>
81
82 <pre id="before-layers">Layer tree goes here</pre>
83 <pre id="after-layers">Layer tree goes here</pre>
84 </body>
85 </html>