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..efd25fba0f8774eb9052c1ae64ff23c7428b79e4 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js |
@@ -0,0 +1,34 @@ |
+// This test code is shared between |
+// resource-timing-sizes-sync-xhr-transfer-size.html and |
+// resource-timing-sizes-sync-xhr-transfer-size-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(); |