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

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

Issue 2697453005: Import wpt@758b3b4cfa805067f36121333ba031e583d3a62c (Closed)
Patch Set: Add -expected.txt files. 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
(Empty)
1 <!DOCTYPE html>
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">
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">
6 <script src="/resources/testharness.js"></script>
7 <script src="../resources/testharness-helpers.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script src="../resources/test-helpers.sub.js"></script>
10
11 <!-- This is the entry global -->
12
13 <iframe src="incumbent/incumbent.https.html"></iframe>
14
15 <script>
16 'use strict';
17
18 const loadPromise = new Promise(resolve => {
19 window.addEventListener('load', () => resolve());
20 });
21
22 promise_test(t => {
23 let registration;
24
25 return loadPromise.then(() => {
26 return frames[0].testRegister();
27 }).then(r => {
28 registration = r;
29 const newestWorker = r.installing || r.waiting || r.active;
30 return wait_for_state(t, newestWorker, 'activated');
31 }).then(() => {
32 return fetch('relevant/test.txt');
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
39 return registration.unregister();
40 });
41 }, 'register should use the relevant global of the object it was called on to re solve the script URL');
42
43 promise_test(t => {
44 return loadPromise.then(() => {
45 return frames[0].testRegister({ scope: 'scope' });
46 }).then(registration => {
47 assert_equals(registration.scope, normalizeURL('relevant/scope'), 'the s cope URL should be relevant/scope');
48
49 return registration.unregister();
50 });
51 }, 'register should use the relevant global of the object it was called on to re solve the scope URL');
52
53 promise_test(t => {
54 let registration;
55
56 return loadPromise.then(() => {
57 return navigator.serviceWorker.register(normalizeURL('relevant/test-sw.j s'));
58 }).then(r => {
59 registration = r;
60 return frames[0].testGetRegistration();
61 })
62 .then(gottenRegistration => {
63 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_equals(gottenRegistration.scope, registration.scope,
66 'the retrieved registration\'s scope should be equal to the original \'s scope');
67
68 return registration.unregister();
69 });
70 }, 'getRegistration should use the relevant global of the object it was called o n to resolve the script URL');
71
72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698