Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: LayoutTests/http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_memory_cached.html

Issue 42363004: [Resource Timing] Memory cached resources should be reported on first use. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix unsigned Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_memory_cached.html
diff --git a/LayoutTests/http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_memory_cached.html b/LayoutTests/http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_memory_cached.html
new file mode 100644
index 0000000000000000000000000000000000000000..fe2c7d9100a24c309f75c205bc53e689c9a8a684
--- /dev/null
+++ b/LayoutTests/http/tests/w3c/webperf/submission/Google/resource-timing/html/test_resource_memory_cached.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>Resource Timing memory cached resources</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 src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
+<script>
+setup({explicit_done: true});
+var d;
+var iframe;
+var iframeBody;
+var count = 0;
+function onload_prep() {
+ iframe = document.getElementById('frameContext');
+ d = iframe.contentWindow.document;
+ iframeBody = d.body;
+
+ var image = d.createElement('img');
+ image.addEventListener("load", function() { setTimeout(onload_test, 0); }, false);
+ image.src = '/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached';
+ iframeBody.appendChild(image);
+
+ var image2 = d.createElement('img');
+ image2.addEventListener("load", function() { setTimeout(onload_test, 0); }, false);
+ image2.src = '/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached';
+ iframeBody.appendChild(image2);
+}
+function onload_test() {
+ ++count;
+ if (count < 2)
+ return;
+
+ var context = new PerformanceContext(iframe.contentWindow.performance);
+ var entries = context.getEntriesByType('resource');
+ test_equals(entries.length, 1, "There should be only one entry");
+ var expected_entries = {
+ '/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached': 'img',
+ }
+ test_resource_entries(entries, expected_entries);
+ test_greater_than(entries[0].requestStart, 0, 'requestStart should non-zero on the same-origin request');
+
+ context.clearResourceTimings();
+ start_crossorigin_test();
+}
+function start_crossorigin_test() {
+ var image3 = d.createElement('img');
+ image3.addEventListener("load", function() { setTimeout(finish_crossorigin_test, 0); }, false);
+ image3.src = 'http://localhost:8000/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached';
+ iframeBody.appendChild(image3);
+}
+function finish_crossorigin_test() {
+ var context = new PerformanceContext(iframe.contentWindow.performance);
+ var entries = context.getEntriesByType('resource');
+ test_equals(entries.length, 1, "There should be only one entry");
+ test_equals(entries[0].name, 'http://localhost:8000/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached', 'http://localhost:8000/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached should be present');
+ test_equals(entries[0].requestStart, 0, 'requestStart should be 0 on the cross-origin request');
+ done();
+}
+window.setup_iframe = function() {}
+window.addEventListener('load', onload_prep, false);
+</script>
+</head>
+<body>
+<h1>Description</h1>
+<p>This test validates that a memory cached resource appears in the buffer once.</p>
+<div id="log"></div>
+<iframe id="frameContext" src="/w3c/webperf/resources/inject_resource_test.html"></iframe>
+<img src="/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached"></img>
+<img src="http://localhost:8000/w3c/webperf/resources/generate_resource.php?type=image&cacheable=1&id=cached"></img>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698