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

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

Issue 1208693003: Add LayoutTest for ServiceWorker's sandbox iframe handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use in Created 5 years, 6 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/sandboxed-iframe-navigator-serviceworker.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // iframe later if needed. 48 // iframe later if needed.
49 function with_iframe(url) { 49 function with_iframe(url) {
50 return new Promise(function(resolve) { 50 return new Promise(function(resolve) {
51 var frame = document.createElement('iframe'); 51 var frame = document.createElement('iframe');
52 frame.src = url; 52 frame.src = url;
53 frame.onload = function() { resolve(frame); }; 53 frame.onload = function() { resolve(frame); };
54 document.body.appendChild(frame); 54 document.body.appendChild(frame);
55 }); 55 });
56 } 56 }
57 57
58 function with_sandboxed_iframe(url, sandbox) {
59 return new Promise(function(resolve) {
60 var frame = document.createElement('iframe');
61 frame.sandbox = sandbox;
62 frame.src = url;
63 frame.onload = function() { resolve(frame); };
64 document.body.appendChild(frame);
65 });
66 }
67
58 function normalizeURL(url) { 68 function normalizeURL(url) {
59 return new URL(url, self.location).toString().replace(/#.*$/, ''); 69 return new URL(url, self.location).toString().replace(/#.*$/, '');
60 } 70 }
61 71
62 function wait_for_update(test, registration) { 72 function wait_for_update(test, registration) {
63 if (!registration || registration.unregister == undefined) { 73 if (!registration || registration.unregister == undefined) {
64 return Promise.reject(new Error( 74 return Promise.reject(new Error(
65 'wait_for_update must be passed a ServiceWorkerRegistration')); 75 'wait_for_update must be passed a ServiceWorkerRegistration'));
66 } 76 }
67 77
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 198 }
189 199
190 function login_https(test) { 200 function login_https(test) {
191 return test_login(test, 'https://127.0.0.1:8443', 201 return test_login(test, 'https://127.0.0.1:8443',
192 'username1s', 'password1s', 'cookie1') 202 'username1s', 'password1s', 'cookie1')
193 .then(function() { 203 .then(function() {
194 return test_login(test, 'https://localhost:8443', 204 return test_login(test, 'https://localhost:8443',
195 'username2s', 'password2s', 'cookie2'); 205 'username2s', 'password2s', 'cookie2');
196 }); 206 });
197 } 207 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/sandboxed-iframe-navigator-serviceworker.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698