OLD | NEW |
(Empty) | |
| 1 // This test code is shared between |
| 2 // resource-timing-sizes-sync-xhr-transfer-size.html and |
| 3 // resource-timing-sizes-sync-xhr-transfer-size-worker.html |
| 4 |
| 5 if (typeof document === 'undefined') { |
| 6 importScripts('/resources/testharness.js'); |
| 7 } |
| 8 |
| 9 const minSize = 100; |
| 10 const url = new URL(cacheBust('/resources/dummy.xml'), location.href).href; |
| 11 var t = async_test('PerformanceResourceTiming sync XHR transferSize test'); |
| 12 |
| 13 function cacheBust(url) { |
| 14 return url + '?bust=' + Math.random().toString().substring(2); |
| 15 } |
| 16 |
| 17 function check() { |
| 18 var entries = performance.getEntriesByName(url); |
| 19 assert_equals(entries.length, 1, 'entries.length'); |
| 20 var entry = entries[0]; |
| 21 assert_greater_than(entry.transferSize, minSize, 'transferSize'); |
| 22 t.done(); |
| 23 } |
| 24 |
| 25 function run() { |
| 26 var xhr = new XMLHttpRequest(); |
| 27 xhr.open('GET', url, false); |
| 28 xhr.send(); |
| 29 setTimeout(t.step_func(check), 0); |
| 30 } |
| 31 |
| 32 run(); |
| 33 |
| 34 done(); |
OLD | NEW |