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