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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/test-helpers.sub.js

Issue 2695813009: Import wpt@503f5b5f78ec4e87d144f78609f363f0ed0ea8db (Closed)
Patch Set: Skip some tests Created 3 years, 10 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 // Adapter for testharness.js-style tests with Service Workers 1 // Adapter for testharness.js-style tests with Service Workers
2 2
3 function service_worker_unregister_and_register(test, url, scope) { 3 function service_worker_unregister_and_register(test, url, scope) {
4 if (!scope || scope.length == 0) 4 if (!scope || scope.length == 0)
5 return Promise.reject(new Error('tests must define a scope')); 5 return Promise.reject(new Error('tests must define a scope'));
6 6
7 var options = { scope: scope }; 7 var options = { scope: scope };
8 return service_worker_unregister(test, scope) 8 return service_worker_unregister(test, scope)
9 .then(function() { 9 .then(function() {
10 return navigator.serviceWorker.register(url, options); 10 return navigator.serviceWorker.register(url, options);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 assert_unreached(error_prefix + ': ' + reason); 45 assert_unreached(error_prefix + ': ' + reason);
46 }); 46 });
47 } 47 }
48 48
49 // Adds an iframe to the document and returns a promise that resolves to the 49 // Adds an iframe to the document and returns a promise that resolves to the
50 // iframe when it finishes loading. The caller is responsible for removing the 50 // iframe when it finishes loading. The caller is responsible for removing the
51 // iframe later if needed. 51 // iframe later if needed.
52 function with_iframe(url) { 52 function with_iframe(url) {
53 return new Promise(function(resolve) { 53 return new Promise(function(resolve) {
54 var frame = document.createElement('iframe'); 54 var frame = document.createElement('iframe');
55 frame.className = 'test-iframe';
55 frame.src = url; 56 frame.src = url;
56 frame.onload = function() { resolve(frame); }; 57 frame.onload = function() { resolve(frame); };
57 document.body.appendChild(frame); 58 document.body.appendChild(frame);
58 }); 59 });
59 } 60 }
60 61
61 function normalizeURL(url) { 62 function normalizeURL(url) {
62 return new URL(url, self.location).toString().replace(/#.*$/, ''); 63 return new URL(url, self.location).toString().replace(/#.*$/, '');
63 } 64 }
64 65
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 }); 219 });
219 } 220 }
220 221
221 function websocket(test, frame) { 222 function websocket(test, frame) {
222 return test_websocket(test, frame, get_websocket_url()); 223 return test_websocket(test, frame, get_websocket_url());
223 } 224 }
224 225
225 function get_websocket_url() { 226 function get_websocket_url() {
226 return 'wss://{{host}}:{{ports[wss][0]}}/echo'; 227 return 'wss://{{host}}:{{ports[wss][0]}}/echo';
227 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698