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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js

Issue 2511283002: Revert of scheduler: Re-enable timer throttling for hidden frames (Closed)
Patch Set: Created 4 years, 1 month 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 // Adds an iframe to the document and returns a promise that resolves to the 46 // Adds an iframe to the document and returns a promise that resolves to the
47 // iframe when it finishes loading. When |options.auto_remove| is set to 47 // iframe when it finishes loading. When |options.auto_remove| is set to
48 // |false|, the caller is responsible for removing the iframe 48 // |false|, the caller is responsible for removing the iframe
49 // later. Otherwise, the frame will be removed after all tests are finished. 49 // later. Otherwise, the frame will be removed after all tests are finished.
50 function with_iframe(url, options) { 50 function with_iframe(url, options) {
51 return new Promise(function(resolve) { 51 return new Promise(function(resolve) {
52 var frame = document.createElement('iframe'); 52 var frame = document.createElement('iframe');
53 frame.src = url; 53 frame.src = url;
54 // Make sure the iframe stays in the viewport even if the test creates
55 // many of them. Otherwise some iframes may end up being throttled.
56 frame.style.position = 'absolute';
57 frame.onload = function() { resolve(frame); }; 54 frame.onload = function() { resolve(frame); };
58 document.body.appendChild(frame); 55 document.body.appendChild(frame);
59 if (typeof options === 'undefined') 56 if (typeof options === 'undefined')
60 options = {}; 57 options = {};
61 if (typeof options.auto_remove === 'undefined') 58 if (typeof options.auto_remove === 'undefined')
62 options.auto_remove = true; 59 options.auto_remove = true;
63 if (options.auto_remove) 60 if (options.auto_remove)
64 add_completion_callback(function() { frame.remove(); }); 61 add_completion_callback(function() { frame.remove(); });
65 }); 62 });
66 } 63 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 199
203 function login(test, local, remote) { 200 function login(test, local, remote) {
204 var suffix = (local.indexOf("https") != -1) ? "s": ""; 201 var suffix = (local.indexOf("https") != -1) ? "s": "";
205 return test_login(test, local, 'username1' + suffix, 'password1' + suffix, 202 return test_login(test, local, 'username1' + suffix, 'password1' + suffix,
206 'cookie1') 203 'cookie1')
207 .then(function() { 204 .then(function() {
208 return test_login(test, remote, 'username2' + suffix, 205 return test_login(test, remote, 'username2' + suffix,
209 'password2' + suffix, 'cookie2'); 206 'password2' + suffix, 'cookie2');
210 }); 207 });
211 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698