3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="../http/tests/inspector/elements-test.js"></script>
6 function loadResource(url)
8 var xhr = new XMLHttpRequest();
9 xhr.open("GET", url, false);
17 var requestWithResource;
18 var requestWithoutResource;
20 InspectorTest.runTestSuite([
23 WebInspector.inspectorView.showPanel("elements");
26 WebInspector.resourceTreeModel.forAllResources(function(r) {
27 if (r.url.indexOf("inspector-test.js") !== -1) {
32 uiLocation = WebInspector.workspace.uiSourceCodeForOriginURL(resource.url).uiLocation(2, 1);
34 InspectorTest.nodeWithId("div", nodeCallback);
36 function nodeCallback(foundNode)
39 InspectorTest.recordNetwork();
40 InspectorTest.evaluateInPage("loadResource('../http/tests/inspector/inspector-test.js')", firstXhrCallback);
43 function firstXhrCallback()
45 requestWithResource = WebInspector.networkLog.requestForURL(resource.url);
46 InspectorTest.evaluateInPage("loadResource('missing.js')", secondXhrCallback);
49 function secondXhrCallback()
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];
62 function revealNode(next)
64 WebInspector.Revealer.reveal(node);
68 function revealUILocation(next)
70 WebInspector.Revealer.reveal(uiLocation);
74 function revealResource(next)
76 WebInspector.Revealer.reveal(resource);
80 function revealRequestWithResource(next)
82 WebInspector.Revealer.reveal(requestWithResource);
86 function revealRequestWithoutResource(next)
88 WebInspector.Revealer.reveal(requestWithoutResource);
93 function installHooks()
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);
105 function nodeRevealed(node)
107 InspectorTest.addResult("Node revealed in the Elements panel");
110 function uiLocationRevealed(uiLocation)
112 InspectorTest.addResult("UILocation " + uiLocation.uiSourceCode.name() + ":" + uiLocation.lineNumber + ":" + uiLocation.columnNumber + " revealed in the Sources panel");
115 function resourceRevealed(resource, lineNumber)
117 InspectorTest.addResult("Resource " + resource.displayName + " revealed in the Resources panel");
120 function requestRevealed(request)
122 InspectorTest.addResult("Request " + new WebInspector.ParsedURL(request.url).lastPathComponent + " revealed in the Network panel");
128 <body onload="runTest()">
129 <p>Tests object revelation in the UI.</p>