Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-fail-event-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-fail-event-worker.js b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-fail-event-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..66cb6a4eab5b41fc4fba268b167ed9bf08be395c |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-fail-event-worker.js |
@@ -0,0 +1,34 @@ |
+'use strict'; |
+ |
+importScripts('/resources/testharness.js'); |
+ |
+test(function() { |
+ assert_own_property(self, 'BackgroundFetchFailEvent'); |
+ |
+ // The `tag` and `failedFetches` are required in the BackgroundFetchFailEventInit. |
harkness
2017/03/13 12:43:07
nit: Maybe put that failedFetches needs a particul
Peter Beverloo
2017/03/13 13:23:17
Done.
|
+ assert_throws(null, () => new BackgroundFetchFailEvent('BackgroundFetchFailEvent')); |
+ assert_throws(null, () => new BackgroundFetchFailEvent('BackgroundFetchFailEvent', {})); |
+ assert_throws(null, () => new BackgroundFetchFailEvent('BackgroundFetchFailEvent', { tag: 'foo' })); |
+ assert_throws(null, () => new BackgroundFetchFailEvent('BackgroundFetchFailEvent', { tag: 'foo', failedFetches: 'bar' })); |
+ |
+ const failedFetches = [ |
+ new BackgroundFetchSettledRequest(new Request('non-existing-image.png'), new Response()), |
+ new BackgroundFetchSettledRequest(new Request('non-existing-image-2.png'), new Response()) |
+ ]; |
+ |
+ const event = new BackgroundFetchFailEvent('BackgroundFetchFailEvent', { |
+ tag: 'my-tag', |
+ failedFetches |
+ }); |
+ |
+ assert_equals(event.type, 'BackgroundFetchFailEvent'); |
+ assert_equals(event.cancelable, false); |
+ assert_equals(event.bubbles, false); |
+ assert_equals(event.tag, 'my-tag'); |
+ |
+ assert_true(Array.isArray(event.failedFetches)); |
+ assert_array_equals(event.failedFetches, failedFetches); |
+ |
+ assert_inherits(event, 'waitUntil'); |
+ |
+}, 'Verifies that the BackgroundFetchFailEvent can be constructed.'); |