Commit 7a939941 authored by simonjam@chromium.org's avatar simonjam@chromium.org

[Resource Timing] Properly report reused connections

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

Reviewed by Tony Gentilcore.

Source/WebCore:

Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse.html

* page/PerformanceResourceTiming.cpp:
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
* page/PerformanceResourceTiming.h:
(PerformanceResourceTiming):

LayoutTests:

* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse-expected.txt: Added.
* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137772 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cafbb557
2012-12-14 James Simonsen <simonjam@chromium.org>
[Resource Timing] Properly report reused connections
https://bugs.webkit.org/show_bug.cgi?id=104986
Reviewed by Tony Gentilcore.
* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse-expected.txt: Added.
* http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse.html: Added.
2012-12-14 Adam Klein <adamk@chromium.org>
fast/dom/HTMLTemplateElement/inertContents.html is flaky
Description
This test validates that connectStart and connectEnd are the same when a connection is reused.
PASS There should be 2 PerformanceEntries
PASS connectStart and connectEnd should be the same
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Resource Timing connection reuse</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
<script src="/w3c/resources/testharness.js"></script>
<script src="/w3c/resources/testharnessreport.js"></script>
<script src="/w3c/webperf/resources/webperftestharness.js"></script>
<script>
setup({explicit_done: true});
var iframe;
var d;
var body;
function setup_iframe() {
iframe = document.getElementById('frameContext');
d = iframe.contentWindow.document;
body = d.createElement('body');
d.getElementsByTagName('html')[0].appendChild(body);
var image = d.createElement('img');
image.src = '/w3c/webperf/resources/generate_resource.php?type=image&id=1';
image.addEventListener('load', first_image_loaded);
body.appendChild(image);
}
function first_image_loaded() {
var image = d.createElement('img');
image.src = '/w3c/webperf/resources/generate_resource.php?type=image&id=2';
image.addEventListener('load', second_image_loaded);
body.appendChild(image);
}
function second_image_loaded() {
var entries = iframe.contentWindow.performance.webkitGetEntries();
test_equals(entries.length, 2, 'There should be 2 PerformanceEntries');
var entry = entries[0];
test_equals(entry.connectStart, entry.connectEnd, "connectStart and connectEnd should be the same");
done();
}
window.setup_iframe = setup_iframe;
</script>
</head>
<body>
<h1>Description</h1>
<p>This test validates that connectStart and connectEnd are the same when a connection is reused.</p>
<div id="log"></div>
<iframe id="frameContext" src="/w3c/webperf/resources/inject_resource_test.html"></iframe>
</body>
</html>
2012-12-14 James Simonsen <simonjam@chromium.org>
[Resource Timing] Properly report reused connections
https://bugs.webkit.org/show_bug.cgi?id=104986
Reviewed by Tony Gentilcore.
Test: http/tests/w3c/webperf/submission/resource-timing/html/test_resource_connection_reuse.html
* page/PerformanceResourceTiming.cpp:
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
* page/PerformanceResourceTiming.h:
(PerformanceResourceTiming):
2012-12-14 Roger Fong <roger_fong@apple.com>
Enable video caption controls on Windows.
......@@ -81,6 +81,7 @@ PerformanceResourceTiming::PerformanceResourceTiming(const AtomicString& initiat
, m_initiatorType(initiatorType)
, m_timing(response.resourceLoadTiming())
, m_finishTime(finishTime)
, m_didReuseConnection(response.connectionReused())
, m_shouldReportDetails(passesTimingAllowCheck(response, requestingDocument))
, m_requestingDocument(requestingDocument)
{
......@@ -95,8 +96,6 @@ AtomicString PerformanceResourceTiming::initiatorType() const
return m_initiatorType;
}
// FIXME: Need to enforce same-origin policy on these.
double PerformanceResourceTiming::redirectStart() const
{
// FIXME: Need to track and report redirects for resources.
......@@ -145,7 +144,8 @@ double PerformanceResourceTiming::connectStart() const
if (!m_shouldReportDetails)
return 0.0;
if (!m_timing || m_timing->connectStart < 0) // Connection was reused.
// connectStart will be -1 when a network request is not made.
if (!m_timing || m_timing->connectStart < 0 || m_didReuseConnection)
return domainLookupEnd();
// connectStart includes any DNS time, so we may need to trim that off.
......@@ -161,7 +161,8 @@ double PerformanceResourceTiming::connectEnd() const
if (!m_shouldReportDetails)
return 0.0;
if (!m_timing || m_timing->connectEnd < 0) // Connection was reused.
// connectStart will be -1 when a network request is not made.
if (!m_timing || m_timing->connectEnd < 0 || m_didReuseConnection)
return connectStart();
return resourceTimeToDocumentMilliseconds(m_timing->connectEnd);
......
......@@ -79,6 +79,7 @@ private:
AtomicString m_initiatorType;
RefPtr<ResourceLoadTiming> m_timing;
double m_finishTime;
bool m_didReuseConnection;
bool m_shouldReportDetails;
RefPtr<Document> m_requestingDocument;
};
......
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