Index: third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js b/third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c28421f1b101ed5610c579392041d4e5f7fade0d |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js |
@@ -0,0 +1,33 @@ |
+// This test code is shared between resource-timing-sizes-redirect.html and |
Kunihiko Sakamoto
2016/07/21 04:05:43
Please update this comment.
Adam Rice
2016/07/21 04:13:51
Sorry. Done.
|
+// resource-timing-sizes-redirect-worker.html |
+ |
+if (typeof document === 'undefined') { |
+ importScripts('/resources/testharness.js'); |
+} |
+ |
+const minSize = 100; |
+const url = new URL(cacheBust('/resources/dummy.xml'), location.href).href; |
+var t = async_test('PerformanceResourceTiming sync XHR transferSize test'); |
+ |
+function cacheBust(url) { |
+ return url + '?bust=' + Math.random().toString().substring(2); |
+} |
+ |
+function check() { |
+ var entries = performance.getEntriesByName(url); |
+ assert_equals(entries.length, 1, 'entries.length'); |
+ var entry = entries[0]; |
+ assert_greater_than(entry.transferSize, minSize, 'transferSize'); |
+ t.done(); |
+} |
+ |
+function run() { |
+ var xhr = new XMLHttpRequest(); |
+ xhr.open('GET', url, false); |
+ xhr.send(); |
+ setTimeout(t.step_func(check), 0); |
+} |
+ |
+run(); |
+ |
+done(); |