a91dbe41a1199cad191a00c78ff9c993d4d24339
[WebKit-https.git] / LayoutTests / inspector-protocol / model / content-node-region-info.html
1 <!doctype html>
2 <html>
3 <head>
4 <style>
5 #flow
6 {
7     -webkit-flow-into: flow;
8 }
9 .contentNode1
10 {
11     width: 100%;
12     height: 50px;
13 }
14 .contentNode2
15 {
16     width: 100%;
17     height: 150px;
18 }
19 .region
20 {
21     -webkit-flow-from: flow;
22     width: 100px;
23     height: 100px;
24 }
25 </style>
26 <script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
27 <script>
28 function test()
29 {
30     var queryList = ["#flow", ".contentNode1", ".contentNode2", "body", "#region1", "#region2"];
31     var documentNodeId;
32
33     InspectorTest.importInspectorScripts();
34     WebInspector.domTreeManager.requestDocument(function(documentNode) {
35         documentNodeId = documentNode.id;
36         WebInspector.domTreeManager.getNamedFlowCollection(documentNodeId);
37         next();
38     });
39
40     function query(selector, callback)
41     {
42         InspectorTest.log("\nSelector: " + selector);
43         WebInspector.domTreeManager.querySelector(documentNodeId, selector, function(contentNodeId) {
44             if (!contentNodeId) {
45                 InspectorTest.log("DOM node not found.");
46                 callback();
47             }
48             var domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
49             WebInspector.domTreeManager.getNodeContentFlowInfo(domNode, function(error, result) {
50                 console.assert(!error);
51                 if (result) {
52                     InspectorTest.log("Region flow name: " + (result.regionFlow ? result.regionFlow.name : "none"));
53                     InspectorTest.log("Content flow name: " + (result.contentFlow ? result.contentFlow.name : "none"));
54                     InspectorTest.log("Regions count: " + (result.regions ? result.regions.length : "N/A"));
55                     InspectorTest.log("Regions: " + (result.regions ? result.regions.map(WebInspector.displayNameForNode).join(", ") : "N/A"));
56                 } else
57                     InspectorTest.log("No region flow information.");
58                 callback();
59             });
60         });
61     }
62
63     function next()
64     {
65         if (!queryList.length)
66             return InspectorTest.completeTest();
67         query(queryList.shift(), next);
68     }
69 }
70 </script>
71 </head>
72 <body onload="runTest()">
73     <p>Testing that the DOMTreeManager.getNodeContentFlowInfo returns the containing regions.</p>
74
75     <div id="flow">
76         <div class="contentNode1"></div>
77         <div class="contentNode2"></div>
78     </div>
79
80     <div id="region1" class="region"></div>
81     <div id="region2" class="region"></div>
82 </body>
83 </html>