Index: third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-content-encoding.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-content-encoding.html b/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-content-encoding.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..89164695bc52827c29aef4928e9e3aae6c974265 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/resource-timing-sizes-content-encoding.html |
@@ -0,0 +1,36 @@ |
+<!DOCTYPE html> |
+<script src="/resources/testharness.js"></script> |
+<script src="/resources/testharnessreport.js"></script> |
+<script src="/resources/get-host-info.js?pipe=sub"></script> |
Kunihiko Sakamoto
2016/07/07 09:56:51
Is this necessary?
Adam Rice
2016/07/07 11:21:12
Removed, thanks.
|
+<script src="/misc/resources/run-async-tasks-promise.js"></script> |
+<script> |
+const url = '/misc/resources/gzip-content-encoding.php'; |
+const uncompressedSize = 1250; |
+ |
+var seenCount = 0; |
+ |
+function checkResourceSizes() { |
+ var entries = performance.getEntriesByType('resource'); |
+ var absoluteUrl = new URL(url, location.href).href; |
+ for (var entry of entries) { |
+ if (entry.name === absoluteUrl) { |
Kunihiko Sakamoto
2016/07/07 09:56:50
You can use performance.getEntriesByName(absoluteU
Adam Rice
2016/07/07 11:21:12
That's better, thank you.
|
+ assert_between_exclusive(entry.encodedBodySize, 0, uncompressedSize, |
+ 'encodedBodySize'); |
+ assert_equals(entry.decodedBodySize, uncompressedSize); |
+ ++seenCount; |
+ } |
+ } |
+ assert_equals(seenCount, 2, 'seenCount'); |
+} |
+ |
+promise_test(() => { |
+ // Fetch twice to ensure at least one fetch comes from the cache. |
+ var eatBody = response => response.arrayBuffer(); |
+ return fetch(url) |
+ .then(eatBody) |
+ .then(() => fetch(url)) |
+ .then(eatBody) |
+ .then(runAsyncTasks) |
+ .then(checkResourceSizes); |
+}, 'PerformanceResourceTiming sizes compressed content test'); |
+</script> |