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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html

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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>register()/getRegistration() URL parsing, with multiple globals in play</ title> 2 <title>register()/getRegistration() URL parsing, with multiple globals in play</ title>
3 <link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/i ndex.html#service-worker-container-register-method"> 3 <link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/i ndex.html#service-worker-container-register-method">
4 <link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/i ndex.html#service-worker-container-getregistration-method"> 4 <link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/i ndex.html#service-worker-container-getregistration-method">
5 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> 5 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
6 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharness.js"></script>
7 <script src="../resources/testharness-helpers.js"></script> 7 <script src="../resources/testharness-helpers.js"></script>
8 <script src="/resources/testharnessreport.js"></script> 8 <script src="/resources/testharnessreport.js"></script>
9 <script src="../resources/test-helpers.sub.js"></script> 9 <script src="../resources/test-helpers.sub.js"></script>
10 10
11 <!-- This is the entry global --> 11 <!-- This is the entry global -->
12 12
13 <iframe src="incumbent/incumbent.https.html"></iframe> 13 <iframe src="incumbent/incumbent.https.html"></iframe>
14 14
15 <script> 15 <script>
16 'use strict'; 16 'use strict';
17 17
18 const loadPromise = new Promise(resolve => { 18 const loadPromise = new Promise(resolve => {
19 window.addEventListener('load', () => resolve()); 19 window.addEventListener('load', () => resolve());
20 }); 20 });
21 21
22 promise_test(t => { 22 promise_test(t => {
23 let registration; 23 let registration;
24 24
25 return loadPromise.then(() => { 25 return loadPromise.then(() => {
26 return frames[0].testRegister(); 26 return frames[0].testRegister();
27 }).then(r => { 27 }).then(r => {
28 registration = r; 28 registration = r;
29 const newestWorker = r.installing || r.waiting || r.active; 29 return wait_for_state(t, registration.installing, 'activated');
30 return wait_for_state(t, newestWorker, 'activated'); 30 }).then(_ => {
31 }).then(() => { 31 assert_equals(registration.active.scriptURL, normalizeURL('relevant/test -sw.js'), 'the script URL should be parsed against the relevant global');
32 return fetch('relevant/test.txt'); 32 assert_equals(registration.scope, normalizeURL('relevant/'), 'the defaul t scope URL should be parsed against the parsed script URL');
33 })
34 .then(response => response.text())
35 .then(text => {
36 assert_equals(text, 'relevant',
37 'the service worker found at relevant/test-sw.js must have been the one to intercept the fetch');
38 33
39 return registration.unregister(); 34 return registration.unregister();
40 }); 35 });
41 }, 'register should use the relevant global of the object it was called on to re solve the script URL'); 36 }, 'register should use the relevant global of the object it was called on to re solve the script URL and the default scope URL');
42 37
43 promise_test(t => { 38 promise_test(t => {
39 let registration;
40
44 return loadPromise.then(() => { 41 return loadPromise.then(() => {
45 return frames[0].testRegister({ scope: 'scope' }); 42 return frames[0].testRegister({ scope: 'scope' });
46 }).then(registration => { 43 }).then(r => {
47 assert_equals(registration.scope, normalizeURL('relevant/scope'), 'the s cope URL should be relevant/scope'); 44 registration = r;
45 return wait_for_state(t, registration.installing, 'activated');
46 }).then(_ => {
47 assert_equals(registration.active.scriptURL, normalizeURL('relevant/test -sw.js'), 'the script URL should be parsed against the relevant global');
48 assert_equals(registration.scope, normalizeURL('relevant/scope'), 'the g iven scope URL should be parsed against the relevant global');
48 49
49 return registration.unregister(); 50 return registration.unregister();
50 }); 51 });
51 }, 'register should use the relevant global of the object it was called on to re solve the scope URL'); 52 }, 'register should use the relevant global of the object it was called on to re solve the script URL and the given scope URL');
52 53
53 promise_test(t => { 54 promise_test(t => {
54 let registration; 55 let registration;
55 56
56 return loadPromise.then(() => { 57 return loadPromise.then(() => {
57 return navigator.serviceWorker.register(normalizeURL('relevant/test-sw.j s')); 58 return navigator.serviceWorker.register(normalizeURL('relevant/test-sw.j s'));
58 }).then(r => { 59 }).then(r => {
59 registration = r; 60 registration = r;
60 return frames[0].testGetRegistration(); 61 return frames[0].testGetRegistration();
61 }) 62 })
62 .then(gottenRegistration => { 63 .then(gottenRegistration => {
63 assert_not_equals(registration, null, 'the registration should not be nu ll'); 64 assert_not_equals(registration, null, 'the registration should not be nu ll');
64 assert_not_equals(gottenRegistration, null, 'the registration from the o ther frame should not be null'); 65 assert_not_equals(gottenRegistration, null, 'the registration from the o ther frame should not be null');
65 assert_equals(gottenRegistration.scope, registration.scope, 66 assert_equals(gottenRegistration.scope, registration.scope,
66 'the retrieved registration\'s scope should be equal to the original \'s scope'); 67 'the retrieved registration\'s scope should be equal to the original \'s scope');
67 68
68 return registration.unregister(); 69 return registration.unregister();
69 }); 70 });
70 }, 'getRegistration should use the relevant global of the object it was called o n to resolve the script URL'); 71 }, 'getRegistration should use the relevant global of the object it was called o n to resolve the script URL');
71 72
72 </script> 73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698