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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-iframe.html

Issue 2872363002: Upstream service worker navigation tests to WPT (Closed)
Patch Set: Created 3 years, 7 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 <script src="../../resources/get-host-info.js?pipe=sub"></script> 2 <script src="/common/get-host-info.sub.js"></script>
3 <script src="test-helpers.js"></script> 3 <script src="test-helpers.sub.js"></script>
4 <script> 4 <script>
5 var SCOPE = './navigation-redirect-to-http.php'; 5 var SCOPE = './redirect.py?Redirect=' + encodeURI('http://example.com');
6 var SCRIPT = 'navigation-redirect-to-http-worker.js'; 6 var SCRIPT = 'navigation-redirect-to-http-worker.js';
7 var host_info = get_host_info(); 7 var host_info = get_host_info();
8 8
9 navigator.serviceWorker.getRegistration(SCOPE) 9 navigator.serviceWorker.getRegistration(SCOPE)
10 .then(function(registration) { 10 .then(function(registration) {
11 if (registration) 11 if (registration)
12 return registration.unregister(); 12 return registration.unregister();
13 }) 13 })
14 .then(function() { 14 .then(function() {
15 return navigator.serviceWorker.register(SCRIPT, {scope: SCOPE}); 15 return navigator.serviceWorker.register(SCRIPT, {scope: SCOPE});
16 }) 16 })
17 .then(function(registration) { 17 .then(function(registration) {
18 return new Promise(function(resolve) { 18 return new Promise(function(resolve) {
19 registration.addEventListener('updatefound', function() { 19 registration.addEventListener('updatefound', function() {
20 resolve(registration.installing); 20 resolve(registration.installing);
21 }); 21 });
22 }); 22 });
23 }) 23 })
24 .then(function(worker) { 24 .then(function(worker) {
25 worker.addEventListener('statechange', on_state_change); 25 worker.addEventListener('statechange', on_state_change);
26 }) 26 })
27 .catch(function(reason) { 27 .catch(function(reason) {
28 window.parent.postMessage({results: 'FAILURE: ' + reason.message}, 28 window.parent.postMessage({results: 'FAILURE: ' + reason.message},
29 host_info['HTTP_ORIGIN']); 29 host_info['HTTPS_ORIGIN']);
30 }); 30 });
31 31
32 function on_state_change(event) { 32 function on_state_change(event) {
33 if (event.target.state != 'activated') 33 if (event.target.state != 'activated')
34 return; 34 return;
35 with_iframe(SCOPE, {auto_remove: false}) 35 with_iframe(SCOPE, {auto_remove: false})
36 .then(function(frame) { 36 .then(function(frame) {
37 window.parent.postMessage( 37 window.parent.postMessage(
38 {results: frame.contentDocument.body.textContent}, 38 {results: frame.contentDocument.body.textContent},
39 host_info['HTTP_ORIGIN']); 39 host_info['HTTPS_ORIGIN']);
40 }); 40 });
41 } 41 }
42
43 </script> 42 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698