OLD | NEW |
1 <!DOCTYPE html> | 1 // This test code is shared between resource-timing-sizes-xhr-fetch.html |
2 <script src="/resources/testharness.js"></script> | 2 // and resource-timing-sizes-xhr-fetch-worker.html |
3 <script src="/resources/testharnessreport.js"></script> | 3 |
4 <script> | 4 if (typeof document === 'undefined') { |
| 5 importScripts('/resources/testharness.js'); |
| 6 } |
| 7 |
5 const XHR_SYNC_URL = '/resources/dummy.xml?t=syncxhr'; | 8 const XHR_SYNC_URL = '/resources/dummy.xml?t=syncxhr'; |
6 const XHR_ASYNC_URL = '/resources/dummy.xml?t=asyncxhr'; | 9 const XHR_ASYNC_URL = '/resources/dummy.xml?t=asyncxhr'; |
7 const FETCH_URL = '/resources/dummy.xml?t=fetch'; | 10 const FETCH_URL = '/resources/dummy.xml?t=fetch'; |
8 var sizes = {}; | 11 var sizes = {}; |
9 sizes[XHR_SYNC_URL] = sizes[XHR_ASYNC_URL] = sizes[FETCH_URL] = 60; | 12 sizes[XHR_SYNC_URL] = sizes[XHR_ASYNC_URL] = sizes[FETCH_URL] = 60; |
10 | 13 |
11 const totalAsyncResources = 2; | 14 const totalAsyncResources = 2; |
12 var seenAsyncResources = 0; | 15 var seenAsyncResources = 0; |
13 var seenResources = 0; | 16 var seenResources = 0; |
14 var t = async_test('PerformanceResourceTiming sizes XHR and Fetch test'); | 17 var t = async_test('PerformanceResourceTiming sizes XHR and Fetch test'); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 async.open('GET', XHR_ASYNC_URL); | 57 async.open('GET', XHR_ASYNC_URL); |
55 async.onload = t.step_func(asyncResourceLoaded); | 58 async.onload = t.step_func(asyncResourceLoaded); |
56 async.onerror = t.step_func(() => assert_unreached('Async XHR error')); | 59 async.onerror = t.step_func(() => assert_unreached('Async XHR error')); |
57 async.send(); | 60 async.send(); |
58 fetch(FETCH_URL) | 61 fetch(FETCH_URL) |
59 .then(response => response.text()) | 62 .then(response => response.text()) |
60 .then(t.step_func(asyncResourceLoaded)) | 63 .then(t.step_func(asyncResourceLoaded)) |
61 .catch(t.step_func(() => assert_unreached('Fetch error'))); | 64 .catch(t.step_func(() => assert_unreached('Fetch error'))); |
62 } | 65 } |
63 | 66 |
64 window.onload = t.step_func(runTest); | 67 runTest(); |
65 </script> | 68 |
| 69 done(); |
OLD | NEW |