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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html
index f547bcd1c62f8d9e2b2d64bcb075dd6bac4961ba..fcdd961b13a11d7e499a051ed7bb2dbd7d4b44b2 100644
--- a/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-manager-get.https.html
@@ -42,4 +42,71 @@ promise_test(function(test) {
});
}, 'BackgroundFetchManager.get() returns NULL for non-existing fetches.');
+
+promise_test(function(test) {
+ const tag = 'my-tag';
+ const options = {
+ icons: [
+ {
+ src: 'resources/non-existing-large-icon.png',
+ sizes: '256x256',
+ type: 'image/png'
+ },
+ {
+ src: 'resources/non-existing-small-icon.jpg',
+ sizes: '64x64',
+ type: 'image/jpg'
+ }
+ ],
+ title: 'My Background Fetch',
+ totalDownloadSize: 1024
+ };
+
+ let registration = null;
+
+ return service_worker_unregister_and_register(test, workerUrl, scope)
+ .then(r => {
+ registration = r;
+ return wait_for_state(test, r.installing, 'activated');
+ })
+ .then(() => registration.backgroundFetch.fetch(tag, ['resources/non-existing-file.png'], options))
+ .then(backgroundFetchRegistration => {
+ assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistration);
+
+ return registration.backgroundFetch.get(tag)
+ .then(secondBackgroundFetchRegistration => {
+ assert_true(secondBackgroundFetchRegistration instanceof BackgroundFetchRegistration);
+ assert_equals(secondBackgroundFetchRegistration.tag, tag);
+ assert_object_equals(secondBackgroundFetchRegistration.icons, options.icons);
+ assert_equals(secondBackgroundFetchRegistration.totalDownloadSize, options.totalDownloadSize);
+ assert_equals(secondBackgroundFetchRegistration.title, options.title);
+ });
+ });
+}, 'BackgroundFetchManager.get() can return created fetches.');
+
+promise_test(function(test) {
+ const tag = 'my-tag';
+
+ let registration = null;
+
+ return service_worker_unregister_and_register(test, workerUrl, scope)
+ .then(r => {
+ registration = r;
+ return wait_for_state(test, r.installing, 'activated');
+ })
+ .then(() => registration.backgroundFetch.fetch(tag, ['resources/non-existing-file.png']))
+ .then(backgroundFetchRegistration => {
+ assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistration);
+ return registration.backgroundFetch.get(tag);
+ })
+ .then(secondBackgroundFetchRegistration => {
+ assert_true(secondBackgroundFetchRegistration instanceof BackgroundFetchRegistration);
+ return secondBackgroundFetchRegistration.abort();
+ })
+ .then(() => registration.backgroundFetch.get(tag))
+ .then(thirdBackgroundFetchRegistration => {
+ assert_equals(thirdBackgroundFetchRegistration, null);
+ });
+
+}, 'BackgroundFetchManager.get() returned fetches can be aborted.');
</script>

Powered by Google App Engine
This is Rietveld 408576698