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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigate-window.https.html

Issue 2726793002: PlzNavigate: Rewrite the url and frame type validation part of the external/wpt/service-workers/se… (Closed)
Patch Set: Address review comments Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (evt.data.type === 'success') { 51 if (evt.data.type === 'success') {
52 resolve(evt.data.detail); 52 resolve(evt.data.detail);
53 } else { 53 } else {
54 reject(evt.data.detail); 54 reject(evt.data.detail);
55 } 55 }
56 }); 56 });
57 sw.postMessage({ type: 'GET_CLIENTS', opts: (opts || {}) }); 57 sw.postMessage({ type: 'GET_CLIENTS', opts: (opts || {}) });
58 }); 58 });
59 } 59 }
60 60
61 function compare_urls(a, b) {
62 return a.url < b.url ? -1 : b.url < a.url ? 1 : 0;
63 }
64
61 function validate_window(win, url, opts) { 65 function validate_window(win, url, opts) {
62 return win.navigator.serviceWorker.getRegistration(url) 66 return win.navigator.serviceWorker.getRegistration(url)
63 .then(reg => { 67 .then(reg => {
64 // In order to compare service worker instances we need to 68 // In order to compare service worker instances we need to
65 // make sure the DOM object is owned by the same global; the 69 // make sure the DOM object is owned by the same global; the
66 // opened window in this case. 70 // opened window in this case.
67 assert_equals(win.navigator.serviceWorker.controller, reg.active, 71 assert_equals(win.navigator.serviceWorker.controller, reg.active,
68 'window should be controlled by service worker'); 72 'window should be controlled by service worker');
69 return get_clients(win, reg.active, opts); 73 return get_clients(win, reg.active, opts);
70 }) 74 })
71 .then(resultList => { 75 .then(resultList => {
72 // We should always see our controlled window. 76 // We should always see our controlled window.
73 var expected = [ 77 var expected = [
74 { url: url, frameType: 'auxiliary' } 78 { url: url, frameType: 'auxiliary' }
75 ]; 79 ];
76 // If we are including uncontrolled windows, then we might see the 80 // If we are including uncontrolled windows, then we might see the
77 // test window itself and the test harness. 81 // test window itself and the test harness.
78 if (opts.includeUncontrolled) { 82 if (opts.includeUncontrolled) {
79 expected.push({ url: BASE_URL + 'navigate-window.https.html', 83 expected.push({ url: BASE_URL + 'navigate-window.https.html',
80 frameType: 'auxiliary' }); 84 frameType: 'auxiliary' });
81 expected.push({ url: host_info['HTTPS_ORIGIN'] + '/testharness_runner. html', 85 expected.push({
82 frameType: 'top-level' }); 86 url: host_info['HTTPS_ORIGIN'] + '/testharness_runner.html',
87 frameType: 'top-level' });
83 } 88 }
89
84 assert_equals(resultList.length, expected.length, 90 assert_equals(resultList.length, expected.length,
85 'expected number of clients'); 91 'expected number of clients');
92
93 expected.sort(compare_urls);
94 resultList.sort(compare_urls);
95
86 for (var i = 0; i < resultList.length; ++i) { 96 for (var i = 0; i < resultList.length; ++i) {
87 assert_equals(resultList[i].url, expected[i].url, 97 assert_equals(expected[i].url, resultList[i].url,
88 'client should have expected url'); 98 'client should have expected url');
89 assert_equals(resultList[i].frameType, expected[i].frameType, 99 assert_equals(expected[i].frameType, resultList[i].frameType,
90 ' client should have expected frame type'); 100 'client should have expected frame type');
91 } 101 }
92 return win; 102 return win;
93 }) 103 })
94 } 104 }
95 105
96 promise_test(function(t) { 106 promise_test(function(t) {
97 var worker = BASE_URL + 'resources/navigate-window-worker.js'; 107 var worker = BASE_URL + 'resources/navigate-window-worker.js';
98 var scope = BASE_URL + 'resources/loaded.html?navigate-window-controlled'; 108 var scope = BASE_URL + 'resources/loaded.html?navigate-window-controlled';
99 var url1 = scope + '&q=1'; 109 var url1 = scope + '&q=1';
100 var url2 = scope + '&q=2'; 110 var url2 = scope + '&q=2';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 .then(win => go_forward(win)) 142 .then(win => go_forward(win))
133 .then(win => validate_window(win, url2, { includeUncontrolled: true })) 143 .then(win => validate_window(win, url2, { includeUncontrolled: true }))
134 .then(win => reload_window(win)) 144 .then(win => reload_window(win))
135 .then(win => validate_window(win, url2, { includeUncontrolled: true })) 145 .then(win => validate_window(win, url2, { includeUncontrolled: true }))
136 .then(win => win.close()) 146 .then(win => win.close())
137 .catch(unreached_rejection(t)) 147 .catch(unreached_rejection(t))
138 .then(___ => service_worker_unregister(t, scope)) 148 .then(___ => service_worker_unregister(t, scope))
139 }, 'Clients.matchAll() should not show an old window after it navigates.'); 149 }, 'Clients.matchAll() should not show an old window after it navigates.');
140 </script> 150 </script>
141 </body> 151 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698