Web Inspector: CSS Regions: Add layout tests for the new events in the DOMTreeManager
[WebKit-https.git] / LayoutTests / inspector-protocol / model / content-flow-list.html
1 <!doctype html>
2 <html>
3 <head>
4 <style>
5 #flow1
6 {
7     -webkit-flow-into: flow1;
8 }
9 </style>
10 <script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
11 <script>
12 function removeFlow()
13 {
14     document.getElementById("flow1").remove();
15 }
16
17 function test()
18 {
19     InspectorTest.importInspectorScripts();
20
21     WebInspector.frameResourceManager.addEventListener(WebInspector.FrameResourceManager.Event.MainFrameDidChange, function(event) {
22         var domTree = WebInspector.frameResourceManager.mainFrame.domTree;
23         domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, onRootDOMNodeInvalidated, null);
24         domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasAdded, onContentFlowWasAdded, null);
25         domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasRemoved, onContentFlowWasRemoved, null);
26         domTree.requestContentFlowList();
27     });
28
29     function onRootDOMNodeInvalidated()
30     {
31         WebInspector.frameResourceManager.mainFrame.domTree.requestContentFlowList();
32     }
33
34     function onContentFlowWasAdded(event)
35     {
36         InspectorTest.assert(event.data.flow.name === "flow1", "ContentFlow was added");
37         InspectorTest.assert(WebInspector.frameResourceManager.mainFrame.domTree.flowsCount === 1, "Flow count is 1");
38         
39         InspectorTest.sendCommand("Runtime.evaluate", {expression: "removeFlow()"});
40     }
41     
42     function onContentFlowWasRemoved(event)
43     {
44         InspectorTest.assert(event.data.flow.name === "flow1", "ContentFlow was removed");
45         InspectorTest.assert(WebInspector.frameResourceManager.mainFrame.domTree.flowsCount === 0, "Flow count is 0");
46         InspectorTest.completeTest();
47     }
48 }
49 </script>
50 </head>
51 <body onload="runTest()">
52     <p>Testing that the ContentFlows events are correctly dispatched when new flows are created/removed.</p>
53     
54     <div id="flow1"></div>
55 </body>
56 </html>