Commit 0f5ad84b authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2009-12-01 Eric Z. Ayers <zundel@google.com>

        Reviewed by Pavel Feldman.

        Adds test for Timeline network resource records.

        https://bugs.webkit.org/show_bug.cgi?id=31378

        * inspector/timeline-network-resource-expected.txt: Added.
        * inspector/timeline-network-resource.html: Added.
        * inspector/timeline-network-resource.js: Added.
        * inspector/timeline-test.js:
        (printTimelineRecords):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2d423529
2009-12-01 Eric Z. Ayers <zundel@google.com>
Reviewed by Pavel Feldman.
Adds test for Timeline network resource records.
https://bugs.webkit.org/show_bug.cgi?id=31378
* inspector/timeline-network-resource-expected.txt: Added.
* inspector/timeline-network-resource.html: Added.
* inspector/timeline-network-resource.js: Added.
* inspector/timeline-test.js:
(printTimelineRecords):
2009-12-01 Chris Marrin <cmarrin@apple.com>
 
Reviewed by Adam Roben.
Tests the Timeline API instrumentation of a network resource load
ResourceSendRequest Properties:
+ startTime : * DEFINED *
+ data : {
+- identifier : * DEFINED *
+- url : * DEFINED *
+- requestMethod : GET
+- isMainResource : false
+ }
+ type : 12
ResourceReceiveResponse Properties:
+ startTime : * DEFINED *
+ data : {
+- identifier : * DEFINED *
+- statusCode : 0
+- mimeType : application/x-javascript
+- expectedContentLength : 210
+ }
+ type : 13
ResourceFinish Properties:
+ startTime : * DEFINED *
+ data : {
+- identifier : * DEFINED *
+- didFail : false
+ }
+ type : 14
Script resource loaded
<html>
<head>
<script src="inspector-test.js"></script>
<script src="timeline-test.js"></script>
<script>
var scriptUrl = "timeline-network-resource.js";
function runAfterScriptIsEvaluated(continuation)
{
function step()
{
if (!window.scriptEvaluated)
setTimeout(step, 100);
else
continuation();
}
setTimeout(step, 100);
}
function printRecord(record)
{
output("");
printTimelineRecordProperties(record);
}
function printSend(record)
{
printRecord(record);
window.resourceId = record.data.identifier;
if (record.data.url === undefined)
output("* No 'url' property in record");
else if (record.data.url.indexOf(scriptUrl) === -1)
output("* Didn't find URL: " + scriptUrl);
}
function printReceive(record)
{
printRecord(record);
if (window.resourceId !== record.data.identifier)
output("Didn't find matching resourceId: " + window.resourceId);
if (record.data.statusCode !== 0)
output("Response received status: " + record.data.statusCode);
}
function printFinish(record)
{
printRecord(record);
if (window.resourceId !== record.data.identifier)
output("Didn't find matching resourceId: " + window.resourceId);
if (record.data.didFail)
output("Request failed.");
}
function doit()
{
if (window.layoutTestController)
layoutTestController.setTimelineProfilingEnabled(true);
var script = document.createElement("script");
script.src = scriptUrl;
document.body.appendChild(script);
runAfterScriptIsEvaluated(function() {
printTimelineRecords(null, null, function(record) {
if (record.type === timelineAgentRecordType["ResourceSendRequest"])
printSend(record);
else if (record.type === timelineAgentRecordType["ResourceReceiveResponse"])
printReceive(record);
else if (record.type === timelineAgentRecordType["ResourceFinish"])
printFinish(record);
});
});
}
</script>
</head>
<body onload="onload()">
<p>
Tests the Timeline API instrumentation of a network resource load
</p>
</body>
</html>
// Sample script resource to find in timeline data
var element = document.createElement("div");
element.innerHTML = "Script resource loaded";
document.body.appendChild(element);
window.scriptEvaluated = true;
......@@ -5,6 +5,7 @@ var timelineNonDeterministicProps = {
children : 1,
endTime : 1,
height : 1,
identifier : 1,
startTime : 1,
width : 1,
url : 1
......@@ -27,10 +28,11 @@ function printTimelineRecords(performActions, typeName, formatter)
output("Error fetching Timeline results: " + timelineRecords);
else {
for (var i = 0; i < timelineRecords.length; ++i) {
if (typeName && timelineRecords[i].type === timelineAgentRecordType[typeName])
printTimelineRecordProperties(timelineRecords[i]);
var record = timelineRecords[i];
if (typeName && record.type === timelineAgentRecordType[typeName])
printTimelineRecordProperties(record);
if (formatter)
formatter(timelineRecords[i]);
formatter(record);
}
}
if (window.layoutTestController)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment