Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Navigate a Window</title> | 2 <title>Service Worker: Navigate a Window</title> |
| 3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script src="/common/get-host-info.sub.js"></script> | 5 <script src="/common/get-host-info.sub.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> | 6 <script src="resources/test-helpers.sub.js"></script> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 var host_info = get_host_info(); | 9 var host_info = get_host_info(); |
| 10 var BASE_URL = host_info['HTTPS_ORIGIN'] + base_path(); | 10 var BASE_URL = host_info['HTTPS_ORIGIN'] + base_path(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 { url: url, frameType: 'auxiliary' } | 74 { url: url, frameType: 'auxiliary' } |
| 75 ]; | 75 ]; |
| 76 // If we are including uncontrolled windows, then we might see the | 76 // If we are including uncontrolled windows, then we might see the |
| 77 // test window itself and the test harness. | 77 // test window itself and the test harness. |
| 78 if (opts.includeUncontrolled) { | 78 if (opts.includeUncontrolled) { |
| 79 expected.push({ url: BASE_URL + 'navigate-window.https.html', | 79 expected.push({ url: BASE_URL + 'navigate-window.https.html', |
| 80 frameType: 'auxiliary' }); | 80 frameType: 'auxiliary' }); |
| 81 expected.push({ url: host_info['HTTPS_ORIGIN'] + '/testharness_runner. html', | 81 expected.push({ url: host_info['HTTPS_ORIGIN'] + '/testharness_runner. html', |
| 82 frameType: 'top-level' }); | 82 frameType: 'top-level' }); |
| 83 } | 83 } |
| 84 | |
| 84 assert_equals(resultList.length, expected.length, | 85 assert_equals(resultList.length, expected.length, |
| 85 'expected number of clients'); | 86 'expected number of clients'); |
| 86 for (var i = 0; i < resultList.length; ++i) { | 87 |
| 87 assert_equals(resultList[i].url, expected[i].url, | 88 // Check if the URLs and the frame type in the result list match with th ose in |
|
jsbell
2017/03/02 20:19:49
Would it be easier to just to sort the lists by ur
jsbell
2017/03/02 20:19:49
nit: wrap to 80 columns?
(since this file is _mos
ananta
2017/03/02 23:21:10
Thanks. Done. I added a compare_urls comparator fu
ananta
2017/03/02 23:21:10
Removed this comment
| |
| 88 'client should have expected url'); | 89 // the expected list. |
| 89 assert_equals(resultList[i].frameType, expected[i].frameType, | 90 for (var i = 0; i < expected.length; ++i) { |
| 90 ' client should have expected frame type'); | 91 var foundMatch = false; |
| 92 var matchingFrameType; | |
| 93 for (var j = 0; j < resultList.length; ++j) { | |
| 94 if (expected[i].url == resultList[j].url) { | |
|
jsbell
2017/03/02 20:19:49
nit: this file seems to prefer === to ==
ananta
2017/03/02 23:21:10
Not needed after sorting.
| |
| 95 foundMatch = true; | |
| 96 matchingFrameType = resultList[j].frameType; | |
| 97 break; | |
| 98 } | |
| 99 } | |
| 100 assert_equals(foundMatch, true, | |
| 101 'client should have expected url ' + expected[i].url); | |
| 102 assert_equals(expected[i].frameType, matchingFrameType, | |
| 103 'client should have expected frame type'); | |
| 91 } | 104 } |
| 92 return win; | 105 return win; |
| 93 }) | 106 }) |
| 94 } | 107 } |
| 95 | 108 |
| 96 promise_test(function(t) { | 109 promise_test(function(t) { |
| 97 var worker = BASE_URL + 'resources/navigate-window-worker.js'; | 110 var worker = BASE_URL + 'resources/navigate-window-worker.js'; |
| 98 var scope = BASE_URL + 'resources/loaded.html?navigate-window-controlled'; | 111 var scope = BASE_URL + 'resources/loaded.html?navigate-window-controlled'; |
| 99 var url1 = scope + '&q=1'; | 112 var url1 = scope + '&q=1'; |
| 100 var url2 = scope + '&q=2'; | 113 var url2 = scope + '&q=2'; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 .then(win => go_forward(win)) | 145 .then(win => go_forward(win)) |
| 133 .then(win => validate_window(win, url2, { includeUncontrolled: true })) | 146 .then(win => validate_window(win, url2, { includeUncontrolled: true })) |
| 134 .then(win => reload_window(win)) | 147 .then(win => reload_window(win)) |
| 135 .then(win => validate_window(win, url2, { includeUncontrolled: true })) | 148 .then(win => validate_window(win, url2, { includeUncontrolled: true })) |
| 136 .then(win => win.close()) | 149 .then(win => win.close()) |
| 137 .catch(unreached_rejection(t)) | 150 .catch(unreached_rejection(t)) |
| 138 .then(___ => service_worker_unregister(t, scope)) | 151 .then(___ => service_worker_unregister(t, scope)) |
| 139 }, 'Clients.matchAll() should not show an old window after it navigates.'); | 152 }, 'Clients.matchAll() should not show an old window after it navigates.'); |
| 140 </script> | 153 </script> |
| 141 </body> | 154 </body> |
| OLD | NEW |