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.'); |