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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetched-event-worker.js

Issue 2744873002: Implement the Request/Response bits of Background Fetch (Closed)
Patch Set: comments 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/resources/background-fetched-event-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetched-event-worker.js b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetched-event-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..5eed0c6e19662307017dc1a3c0fdd91b759506ee
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetched-event-worker.js
@@ -0,0 +1,36 @@
+'use strict';
+
+importScripts('/resources/testharness.js');
+
+test(function() {
+ assert_own_property(self, 'BackgroundFetchedEvent');
+
+ // The `tag` and `completedFetches` are required options in the
+ // BackgroundFetchedEventInit. The latter must be a sequence of
+ // BackgroundFetchSettledRequest instances.
+ assert_throws(null, () => new BackgroundFetchedEvent('BackgroundFetchedEvent'));
+ assert_throws(null, () => new BackgroundFetchedEvent('BackgroundFetchedEvent', {}));
+ assert_throws(null, () => new BackgroundFetchedEvent('BackgroundFetchedEvent', { tag: 'foo' }));
+ assert_throws(null, () => new BackgroundFetchedEvent('BackgroundFetchedEvent', { tag: 'foo', completedFetches: 'bar' }));
+
+ const completedFetches = [
+ new BackgroundFetchSettledRequest(new Request('non-existing-image.png'), new Response()),
+ new BackgroundFetchSettledRequest(new Request('non-existing-image-2.png'), new Response())
+ ];
+
+ const event = new BackgroundFetchedEvent('BackgroundFetchedEvent', {
+ tag: 'my-tag',
+ completedFetches
+ });
+
+ assert_equals(event.type, 'BackgroundFetchedEvent');
+ assert_equals(event.cancelable, false);
+ assert_equals(event.bubbles, false);
+ assert_equals(event.tag, 'my-tag');
+
+ assert_true(Array.isArray(event.completedFetches));
+ assert_array_equals(event.completedFetches, completedFetches);
+
+ assert_inherits(event, 'waitUntil');
+
+}, 'Verifies that the BackgroundFetchedEvent can be constructed.');

Powered by Google App Engine
This is Rietveld 408576698