- Revision
- 201415
- Author
- [email protected]
- Date
- 2016-05-25 22:34:27 -0700 (Wed, 25 May 2016)
Log Message
Fix ResourceTiming multiple entries per resource and test initiator
https://bugs.webkit.org/show_bug.cgi?id=158094
Reviewed by Alex Christensen.
Make sure that CachedResource that was needed by two different elements only adds one entry, with the right (first) initiatorType.
Source/WebCore:
Tests: http/tests/performance/performance-resource-timing-initiator-css.html
http/tests/performance/performance-resource-timing-initiator-no-override.html
* loader/ResourceTimingInformation.cpp:
(WebCore::ResourceTimingInformation::addResourceTiming): Don't remove CachedResource when entry is added, but
mark it as added. Only add new entries for non-added resources.
(WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Initialize initiator info as NotYetAdded.
* loader/ResourceTimingInformation.h:
LayoutTests:
* http/tests/performance/performance-resource-timing-initiator-css.html: Added. Makes sure css has the right initiator type.
* http/tests/performance/performance-resource-timing-initiator-css-expected.txt: Added.
* http/tests/performance/performance-resource-timing-initiator-no-override.html: Added. Makes sure that only one entry is added and
that its initiator info doesn't get overriden.
* http/tests/performance/performance-resource-timing-initiator-no-override-expected.txt: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201414 => 201415)
--- trunk/LayoutTests/ChangeLog 2016-05-26 05:33:58 UTC (rev 201414)
+++ trunk/LayoutTests/ChangeLog 2016-05-26 05:34:27 UTC (rev 201415)
@@ -1,5 +1,20 @@
2016-05-25 Yoav Weiss <[email protected]>
+ Fix ResourceTiming multiple entries per resource and test initiator
+ https://bugs.webkit.org/show_bug.cgi?id=158094
+
+ Reviewed by Alex Christensen.
+
+ Make sure that CachedResource that was needed by two different elements only adds one entry, with the right (first) initiatorType.
+
+ * http/tests/performance/performance-resource-timing-initiator-css.html: Added. Makes sure css has the right initiator type.
+ * http/tests/performance/performance-resource-timing-initiator-css-expected.txt: Added.
+ * http/tests/performance/performance-resource-timing-initiator-no-override.html: Added. Makes sure that only one entry is added and
+ that its initiator info doesn't get overriden.
+ * http/tests/performance/performance-resource-timing-initiator-no-override-expected.txt: Added.
+
+2016-05-25 Yoav Weiss <[email protected]>
+
Fix ResourceTiming XHR flakiness
https://bugs.webkit.org/show_bug.cgi?id=158019
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css-expected.txt (0 => 201415)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css-expected.txt 2016-05-26 05:34:27 UTC (rev 201415)
@@ -0,0 +1,2 @@
+PASS initiator is "css"
+
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css.html (0 => 201415)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css.html (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-css.html 2016-05-26 05:34:27 UTC (rev 201415)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<script>
+ if (window.internals)
+ internals.setResourceTimingSupport(true);
+ if (window.testRunner) {
+ testRunner.dumpAsText()
+ testRunner.waitUntilDone();
+ }
+</script>
+<script src=""
+<body>
+<style>
+ body { background: url("../../resources/square100.png"); }
+</style>
+<script>
+ var initiator;
+ var runTest = function() {
+ var resources = performance.getEntriesByType('resource');
+ for (var i = 0; i < resources.length; ++i) {
+ if (resources[i].name.indexOf("square") != -1) {
+ initiator = resources[i].initiatorType;
+ shouldBeEqualToString("initiator", "css");
+ }
+ };
+ if (window.internals)
+ window.internals.setResourceTimingSupport(false);
+ if (window.testRunner)
+ testRunner.notifyDone();
+ };
+ window.addEventListener("load", function() {
+ runTest();
+ });
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override-expected.txt (0 => 201415)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override-expected.txt 2016-05-26 05:34:27 UTC (rev 201415)
@@ -0,0 +1,3 @@
+PASS initiator is "img"
+PASS foundResources is 1
+
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override.html (0 => 201415)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override.html (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-initiator-no-override.html 2016-05-26 05:34:27 UTC (rev 201415)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<script>
+ if (window.internals)
+ internals.setResourceTimingSupport(true);
+ if (window.testRunner) {
+ testRunner.dumpAsText()
+ testRunner.waitUntilDone();
+ }
+</script>
+<script src=""
+<body>
+<img src=""
+<style>
+ body { background: url("../../resources/square100.png"); }
+</style>
+<script>
+ var initiator;
+ var foundResources = 0;
+ var runTest = function() {
+ var resources = performance.getEntriesByType('resource');
+ for (var i = 0; i < resources.length; ++i) {
+ if (resources[i].name.indexOf("square") != -1) {
+ ++foundResources;
+ initiator = resources[i].initiatorType;
+ shouldBeEqualToString("initiator", "img");
+ }
+ };
+ shouldBe("foundResources", "1");
+ if (window.internals)
+ window.internals.setResourceTimingSupport(false);
+ if (window.testRunner)
+ testRunner.notifyDone();
+ };
+ window.addEventListener("load", function() {
+ runTest();
+ });
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (201414 => 201415)
--- trunk/Source/WebCore/ChangeLog 2016-05-26 05:33:58 UTC (rev 201414)
+++ trunk/Source/WebCore/ChangeLog 2016-05-26 05:34:27 UTC (rev 201415)
@@ -1,5 +1,23 @@
2016-05-25 Yoav Weiss <[email protected]>
+ Fix ResourceTiming multiple entries per resource and test initiator
+ https://bugs.webkit.org/show_bug.cgi?id=158094
+
+ Reviewed by Alex Christensen.
+
+ Make sure that CachedResource that was needed by two different elements only adds one entry, with the right (first) initiatorType.
+
+ Tests: http/tests/performance/performance-resource-timing-initiator-css.html
+ http/tests/performance/performance-resource-timing-initiator-no-override.html
+
+ * loader/ResourceTimingInformation.cpp:
+ (WebCore::ResourceTimingInformation::addResourceTiming): Don't remove CachedResource when entry is added, but
+ mark it as added. Only add new entries for non-added resources.
+ (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Initialize initiator info as NotYetAdded.
+ * loader/ResourceTimingInformation.h:
+
+2016-05-25 Yoav Weiss <[email protected]>
+
Fix ResourceTiming XHR flakiness
https://bugs.webkit.org/show_bug.cgi?id=158019
Modified: trunk/Source/WebCore/loader/ResourceTimingInformation.cpp (201414 => 201415)
--- trunk/Source/WebCore/loader/ResourceTimingInformation.cpp 2016-05-26 05:33:58 UTC (rev 201414)
+++ trunk/Source/WebCore/loader/ResourceTimingInformation.cpp 2016-05-26 05:34:27 UTC (rev 201415)
@@ -44,7 +44,7 @@
if (resource && resource->response().isHTTP()
&& ((!resource->errorOccurred() && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource);
- if (initiatorIt != m_initiatorMap.end()) {
+ if (initiatorIt != m_initiatorMap.end() && initiatorIt->value.added == NotYetAdded) {
ASSERT(document);
Document* initiatorDocument = document;
if (resource->type() == CachedResource::MainResource)
@@ -54,7 +54,7 @@
ASSERT(initiatorDocument->domWindow()->performance());
const InitiatorInfo& info = initiatorIt->value;
initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, initiatorDocument, resource->resourceRequest(), resource->response(), info.startTime, resource->loadFinishTime());
- m_initiatorMap.remove(initiatorIt);
+ initiatorIt->value.added = Added;
}
}
}
@@ -67,11 +67,11 @@
// <iframe>s should report the initial navigation requested by the parent document, but not subsequent navigations.
ASSERT(frame);
if (frame->ownerElement()) {
- InitiatorInfo info = { frame->ownerElement()->localName(), monotonicallyIncreasingTime() };
+ InitiatorInfo info = { frame->ownerElement()->localName(), monotonicallyIncreasingTime(), NotYetAdded };
m_initiatorMap.add(resource.get(), info);
}
} else {
- InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
+ InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime(), NotYetAdded };
m_initiatorMap.add(resource.get(), info);
}
}
Modified: trunk/Source/WebCore/loader/ResourceTimingInformation.h (201414 => 201415)
--- trunk/Source/WebCore/loader/ResourceTimingInformation.h 2016-05-26 05:33:58 UTC (rev 201414)
+++ trunk/Source/WebCore/loader/ResourceTimingInformation.h 2016-05-26 05:34:27 UTC (rev 201415)
@@ -45,9 +45,11 @@
void storeResourceTimingInitiatorInformation(const CachedResourceHandle<CachedResource>&, const CachedResourceRequest&, Frame*);
private:
+ enum AlreadyAdded { NotYetAdded, Added };
struct InitiatorInfo {
AtomicString name;
double startTime;
+ AlreadyAdded added;
};
HashMap<CachedResource*, InitiatorInfo> m_initiatorMap;
};