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

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

Powered by Google App Engine
This is Rietveld 408576698