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>
8 var initialize_TestCustom = function() {
10 InspectorTest
.preloadPanel("elements");
11 InspectorTest
.preloadPanel("sources");
12 InspectorTest
.preloadPanel("resources");
13 InspectorTest
.preloadPanel("network");
17 function loadResource(url
)
19 var xhr
= new XMLHttpRequest();
20 xhr
.open("GET", url
, false);
28 var requestWithResource
;
29 var requestWithoutResource
;
31 InspectorTest
.runTestSuite([
36 InspectorTest
.resourceTreeModel
.forAllResources(function(r
) {
37 if (r
.url
.indexOf("inspector-test.js") !== -1) {
42 uiLocation
= WebInspector
.workspace
.uiSourceCodeForOriginURL(resource
.url
).uiLocation(2, 1);
44 InspectorTest
.nodeWithId("div", nodeCallback
);
46 function nodeCallback(foundNode
)
49 InspectorTest
.recordNetwork();
50 InspectorTest
.evaluateInPage("loadResource('../http/tests/inspector/inspector-test.js')", firstXhrCallback
);
53 function firstXhrCallback()
55 requestWithResource
= InspectorTest
.networkLog
.requestForURL(resource
.url
);
56 InspectorTest
.evaluateInPage("loadResource('missing.js')", secondXhrCallback
);
59 function secondXhrCallback()
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
];
72 function revealNode(next
)
74 WebInspector
.Revealer
.revealPromise(node
).then(next
);
77 function revealUILocation(next
)
79 WebInspector
.Revealer
.revealPromise(uiLocation
).then(next
);
82 function revealResource(next
)
84 WebInspector
.Revealer
.revealPromise(resource
).then(next
);
87 function revealRequestWithResource(next
)
89 WebInspector
.Revealer
.revealPromise(requestWithResource
).then(next
);
92 function revealRequestWithoutResource(next
)
94 WebInspector
.Revealer
.revealPromise(requestWithoutResource
).then(next
);
98 function installHooks()
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);
106 function nodeRevealed(node
)
108 InspectorTest
.addResult("Node revealed in the Elements panel");
111 function uiLocationRevealed(uiLocation
)
113 InspectorTest
.addResult("UILocation " + uiLocation
.uiSourceCode
.name() + ":" + uiLocation
.lineNumber
+ ":" + uiLocation
.columnNumber
+ " revealed in the Sources panel");
116 function resourceRevealed(resource
, lineNumber
)
118 InspectorTest
.addResult("Resource " + resource
.displayName
+ " revealed in the Resources panel");
121 function requestRevealed(request
)
123 InspectorTest
.addResult("Request " + new WebInspector
.ParsedURL(request
.url
).lastPathComponent
+ " revealed in the Network panel");
129 <body onload=
"runTest()">
130 <p>Tests object revelation in the UI.
</p>