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