Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / reveal-objects.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/elements-test.js"></script>
5 <script>
6 function loadResource(url)
7 {
8     var xhr = new XMLHttpRequest();
9     xhr.open("GET", url, false);
10     xhr.send();
11 }
12
13 function test() {
14     var node;
15     var resource;
16     var uiLocation;
17     var requestWithResource;
18     var requestWithoutResource;
19
20     InspectorTest.runTestSuite([
21         function init(next)
22         {
23             WebInspector.inspectorView.showPanel("elements");
24             installHooks();
25
26             WebInspector.resourceTreeModel.forAllResources(function(r) {
27                 if (r.url.indexOf("inspector-test.js") !== -1) {
28                     resource = r;
29                     return true;
30                 }
31             });
32             uiLocation = WebInspector.workspace.uiSourceCodeForOriginURL(resource.url).uiLocation(2, 1);
33
34             InspectorTest.nodeWithId("div", nodeCallback);
35
36             function nodeCallback(foundNode)
37             {
38                 node = foundNode;
39                 InspectorTest.recordNetwork();
40                 InspectorTest.evaluateInPage("loadResource('../http/tests/inspector/inspector-test.js')", firstXhrCallback);
41             }
42
43             function firstXhrCallback()
44             {
45                 requestWithResource = WebInspector.networkLog.requestForURL(resource.url);
46                 InspectorTest.evaluateInPage("loadResource('missing.js')", secondXhrCallback);
47             }
48
49             function secondXhrCallback()
50             {
51                 var requests = WebInspector.networkLog.requests;
52                 for (var i = 0; i < requests.length; ++i) {
53                     if (requests[i].url.indexOf("missing.js") !== -1) {
54                         requestWithoutResource = requests[i];
55                         break;
56                     }
57                 }
58                 next();
59             }
60         },
61
62         function revealNode(next)
63         {
64             WebInspector.Revealer.reveal(node);
65             next();
66         },
67
68         function revealUILocation(next)
69         {
70             WebInspector.Revealer.reveal(uiLocation);
71             next();
72         },
73
74         function revealResource(next)
75         {
76             WebInspector.Revealer.reveal(resource);
77             next();
78         },
79
80         function revealRequestWithResource(next)
81         {
82             WebInspector.Revealer.reveal(requestWithResource);
83             next();
84         },
85
86         function revealRequestWithoutResource(next)
87         {
88             WebInspector.Revealer.reveal(requestWithoutResource);
89             next();
90         }
91     ]);
92
93     function installHooks()
94     {
95         WebInspector.inspectorView.panel("elements");
96         InspectorTest.addSniffer(WebInspector.ElementsPanel.prototype, "revealAndSelectNode", nodeRevealed, true);
97         WebInspector.inspectorView.panel("sources");
98         InspectorTest.addSniffer(WebInspector.SourcesPanel.prototype, "showUILocation", uiLocationRevealed, true);
99         WebInspector.inspectorView.panel("resources");
100         InspectorTest.addSniffer(WebInspector.ResourcesPanel.prototype, "showResource", resourceRevealed, true);
101         WebInspector.inspectorView.panel("network");
102         InspectorTest.addSniffer(WebInspector.NetworkPanel.prototype, "revealAndHighlightRequest", requestRevealed, true);
103     }
104
105     function nodeRevealed(node)
106     {
107         InspectorTest.addResult("Node revealed in the Elements panel");
108     }
109
110     function uiLocationRevealed(uiLocation)
111     {
112         InspectorTest.addResult("UILocation " + uiLocation.uiSourceCode.name() + ":" + uiLocation.lineNumber + ":" + uiLocation.columnNumber + " revealed in the Sources panel");
113     }
114
115     function resourceRevealed(resource, lineNumber)
116     {
117         InspectorTest.addResult("Resource " + resource.displayName + " revealed in the Resources panel");
118     }
119
120     function requestRevealed(request)
121     {
122         InspectorTest.addResult("Request " + new WebInspector.ParsedURL(request.url).lastPathComponent + " revealed in the Network panel");
123     }
124 }
125
126 </script>
127 </head>
128 <body onload="runTest()">
129 <p>Tests object revelation in the UI.</p>
130 <div id="div" />
131 </body>
132 </html>