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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html

Issue 2777183002: Hook up the other Background Fetch Mojo methods with the system (Closed)
Patch Set: Hook up the other Background Fetch Mojo methods with the system Created 3 years, 8 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 <meta charset="utf-8"> 2 <meta charset="utf-8">
3 <title>Background Fetch API: get() tests</title> 3 <title>Background Fetch API: get() tests</title>
4 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testharnessreport.js"></script>
6 <script src="/serviceworker/resources/test-helpers.js"></script> 6 <script src="/serviceworker/resources/test-helpers.js"></script>
7 7
8 <h1>BackgroundFetchManager.get()</h1> 8 <h1>BackgroundFetchManager.get()</h1>
9 <p>This test validates the behaviour of the get() method.</p> 9 <p>This test validates the behaviour of the get() method.</p>
10 10
(...skipping 24 matching lines...) Expand all
35 .then(r => { 35 .then(r => {
36 registration = r; 36 registration = r;
37 return wait_for_state(test, r.installing, 'activated'); 37 return wait_for_state(test, r.installing, 'activated');
38 }) 38 })
39 .then(() => registration.backgroundFetch.get('invalid-fetch-tag')) 39 .then(() => registration.backgroundFetch.get('invalid-fetch-tag'))
40 .then(backgroundFetchRegistration => { 40 .then(backgroundFetchRegistration => {
41 assert_equals(backgroundFetchRegistration, null); 41 assert_equals(backgroundFetchRegistration, null);
42 }); 42 });
43 43
44 }, 'BackgroundFetchManager.get() returns NULL for non-existing fetches.'); 44 }, 'BackgroundFetchManager.get() returns NULL for non-existing fetches.');
45
46 promise_test(function(test) {
47 const tag = 'my-tag';
48 const options = {
49 icons: [
50 {
51 src: 'resources/non-existing-large-icon.png',
52 sizes: '256x256',
53 type: 'image/png'
54 },
55 {
56 src: 'resources/non-existing-small-icon.jpg',
57 sizes: '64x64',
58 type: 'image/jpg'
59 }
60 ],
61 title: 'My Background Fetch',
62 totalDownloadSize: 1024
63 };
64
65 let registration = null;
66
67 return service_worker_unregister_and_register(test, workerUrl, scope)
68 .then(r => {
69 registration = r;
70 return wait_for_state(test, r.installing, 'activated');
71 })
72 .then(() => registration.backgroundFetch.fetch(tag, ['resources/non-existing -file.png'], options))
73 .then(backgroundFetchRegistration => {
74 assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistra tion);
75
76 return registration.backgroundFetch.get(tag)
77 .then(secondBackgroundFetchRegistration => {
78 assert_true(secondBackgroundFetchRegistration instanceof BackgroundFet chRegistration);
79 assert_equals(secondBackgroundFetchRegistration.tag, tag);
80 assert_object_equals(secondBackgroundFetchRegistration.icons, options. icons);
81 assert_equals(secondBackgroundFetchRegistration.totalDownloadSize, opt ions.totalDownloadSize);
82 assert_equals(secondBackgroundFetchRegistration.title, options.title);
83 });
84 });
85 }, 'BackgroundFetchManager.get() can return created fetches.');
86
87 promise_test(function(test) {
88 const tag = 'my-tag';
89
90 let registration = null;
91
92 return service_worker_unregister_and_register(test, workerUrl, scope)
93 .then(r => {
94 registration = r;
95 return wait_for_state(test, r.installing, 'activated');
96 })
97 .then(() => registration.backgroundFetch.fetch(tag, ['resources/non-existing -file.png']))
98 .then(backgroundFetchRegistration => {
99 assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistra tion);
100 return registration.backgroundFetch.get(tag);
101 })
102 .then(secondBackgroundFetchRegistration => {
103 assert_true(secondBackgroundFetchRegistration instanceof BackgroundFetchRe gistration);
104 return secondBackgroundFetchRegistration.abort();
105 })
106 .then(() => registration.backgroundFetch.get(tag))
107 .then(thirdBackgroundFetchRegistration => {
108 assert_equals(thirdBackgroundFetchRegistration, null);
109 });
110
111 }, 'BackgroundFetchManager.get() returned fetches can be aborted.');
45 </script> 112 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698