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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/misc/resources/resource-timing-sizes-sync-xhr-transfer-size.js

Issue 2163183002: Fix PerformanceResourceTiming transferSize field for sync XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_worker_tests
Patch Set: Rebase Created 4 years, 5 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: 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();

Powered by Google App Engine
This is Rietveld 408576698