Commit e49aedca authored by yurys@chromium.org's avatar yurys@chromium.org

Do not use raw protocol types in inspector/timeline/timeline-network-resource.html

In preparation to switching to tracing backend the test is changed to use higher level abstractions.

BUG=398785
R=pfeldman@chromium.org

Review URL: https://codereview.chromium.org/480013002

git-svn-id: svn://svn.chromium.org/blink/trunk@180451 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9c614e9c
...@@ -169,7 +169,7 @@ InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt ...@@ -169,7 +169,7 @@ InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt
} }
if (detailsCallback) if (detailsCallback)
suffix += " " + detailsCallback(record); suffix += " " + detailsCallback(record);
InspectorTest.addResult(prefix + InspectorTest._timelineAgentTypeToString(record.type()) + suffix); InspectorTest.addResult(prefix + record.type() + suffix);
var children = record.children(); var children = record.children();
var numChildren = children.length; var numChildren = children.length;
...@@ -216,7 +216,7 @@ InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallb ...@@ -216,7 +216,7 @@ InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallb
} }
if (detailsCallback) if (detailsCallback)
suffix += " " + detailsCallback(presentationRecord); suffix += " " + detailsCallback(presentationRecord);
var typeString = record ? InspectorTest._timelineAgentTypeToString(record.type()) : "Root"; var typeString = record ? record.type() : "Root";
InspectorTest.addResult(prefix + typeString + suffix); InspectorTest.addResult(prefix + typeString + suffix);
var numChildren = presentationRecord.presentationChildren() ? presentationRecord.presentationChildren().length : 0; var numChildren = presentationRecord.presentationChildren() ? presentationRecord.presentationChildren().length : 0;
...@@ -235,23 +235,13 @@ InspectorTest.dumpTimelineRecords = function(timelineRecords) ...@@ -235,23 +235,13 @@ InspectorTest.dumpTimelineRecords = function(timelineRecords)
InspectorTest.printTimelineRecordProperties = function(record) InspectorTest.printTimelineRecordProperties = function(record)
{ {
var recordType = (typeof record.type === "string") ? record.type : record.type(); InspectorTest.addResult(record.type() + " Properties:");
InspectorTest.addResult(InspectorTest._timelineAgentTypeToString(recordType) + " Properties:");
// Use this recursive routine to print the properties // Use this recursive routine to print the properties
if (record instanceof WebInspector.TimelineModel.RecordImpl) if (record instanceof WebInspector.TimelineModel.RecordImpl)
record = record._record; record = record._record;
InspectorTest.addObject(record, InspectorTest.timelinePropertyFormatters); InspectorTest.addObject(record, InspectorTest.timelinePropertyFormatters);
}; };
InspectorTest._timelineAgentTypeToString = function(numericType)
{
for (var prop in WebInspector.TimelineModel.RecordType) {
if (WebInspector.TimelineModel.RecordType[prop] === numericType)
return prop;
}
return undefined;
};
InspectorTest.findFirstTimelineRecord = function(type) InspectorTest.findFirstTimelineRecord = function(type)
{ {
var result; var result;
......
...@@ -30,16 +30,20 @@ function test() ...@@ -30,16 +30,20 @@ function test()
function format(record) function format(record)
{ {
if (record.type() === WebInspector.TimelineModel.RecordType.ResourceSendRequest) if (record.type() === WebInspector.TimelineModel.RecordType.ResourceSendRequest)
printSend(record._record); printSend(record);
else if (record.type() === WebInspector.TimelineModel.RecordType.ResourceReceiveResponse) else if (record.type() === WebInspector.TimelineModel.RecordType.ResourceReceiveResponse)
printReceive(record._record); printReceive(record);
else if (record.type() === WebInspector.TimelineModel.RecordType.ResourceFinish) else if (record.type() === WebInspector.TimelineModel.RecordType.ResourceFinish)
printFinish(record._record); printFinish(record);
if (record.parent && record.parent.type() === WebInspector.TimelineModel.RecordType.Root) { var presentationRecord = presentationModel.toPresentationRecord(record);
if (lastRecordStartTime) if (presentationRecord && record.thread() === WebInspector.TimelineModel.MainThreadName) {
InspectorTest.assertGreaterOrEqual(record.startTime(), lastRecordStartTime, "Top level records order violation"); var parentIsRoot = presentationRecord.presentationParent() && !presentationRecord.presentationParent().presentationParent();
lastRecordStartTime = record.startTime(); if (parentIsRoot) {
if (lastRecordStartTime)
InspectorTest.assertGreaterOrEqual(record.startTime(), lastRecordStartTime, "Top level records order violation");
lastRecordStartTime = record.startTime();
}
} }
} }
model.forAllRecords(format); model.forAllRecords(format);
...@@ -55,28 +59,28 @@ function test() ...@@ -55,28 +59,28 @@ function test()
function printSend(record) function printSend(record)
{ {
printRecord(record); printRecord(record);
requestId = record.data.requestId; requestId = record.data().requestId;
if (record.data.url === undefined) if (record.data().url === undefined)
InspectorTest.addResult("* No 'url' property in record"); InspectorTest.addResult("* No 'url' property in record");
else if (record.data.url.indexOf(scriptUrl) === -1) else if (record.data().url.indexOf(scriptUrl) === -1)
InspectorTest.addResult("* Didn't find URL: " + scriptUrl); InspectorTest.addResult("* Didn't find URL: " + scriptUrl);
} }
function printReceive(record) function printReceive(record)
{ {
printRecord(record); printRecord(record);
if (requestId !== record.data.requestId) if (requestId !== record.data().requestId)
InspectorTest.addResult("Didn't find matching requestId: " + requestId); InspectorTest.addResult("Didn't find matching requestId: " + requestId);
if (record.data.statusCode !== 0) if (record.data().statusCode !== 0)
InspectorTest.addResult("Response received status: " + record.data.statusCode); InspectorTest.addResult("Response received status: " + record.data().statusCode);
} }
function printFinish(record) function printFinish(record)
{ {
printRecord(record); printRecord(record);
if (requestId !== record.data.requestId) if (requestId !== record.data().requestId)
InspectorTest.addResult("Didn't find matching requestId: " + requestId); InspectorTest.addResult("Didn't find matching requestId: " + requestId);
if (record.data.didFail) if (record.data().didFail)
InspectorTest.addResult("Request failed."); InspectorTest.addResult("Request failed.");
} }
} }
......
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