Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-click-event-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-click-event-worker.js b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-click-event-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1103782aa55626d9024170b49a95e1a1fbf1ab45 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/resources/background-fetch-click-event-worker.js |
@@ -0,0 +1,31 @@ |
+'use strict'; |
+ |
+importScripts('/resources/testharness.js'); |
+ |
+test(function() { |
+ assert_own_property(self, 'BackgroundFetchClickEvent'); |
+ |
+ // The `tag` and `state` are required in the BackgroundFetchClickEventInit. |
+ assert_throws(null, () => new BackgroundFetchClickEvent('BackgroundFetchClickEvent')); |
+ assert_throws(null, () => new BackgroundFetchClickEvent('BackgroundFetchClickEvent', {})); |
+ assert_throws(null, () => new BackgroundFetchClickEvent('BackgroundFetchClickEvent', { tag: 'foo' })); |
+ assert_throws(null, () => new BackgroundFetchClickEvent('BackgroundFetchClickEvent', { tag: 'foo', state: 'foo' })); |
+ |
+ // The `state` must be one of { pending, succeeded, failed }. This should not throw. |
+ for (let state of ['pending', 'succeeded', 'failed']) |
+ new BackgroundFetchClickEvent('BackgroundFetchClickEvent', { tag: 'foo', state }); |
harkness
2017/03/09 19:41:15
Are there tag formats that we won't allow?
Peter Beverloo
2017/03/10 00:42:50
No, it follows the semantics of a DOMString.
|
+ |
+ const event = new BackgroundFetchClickEvent('BackgroundFetchClickEvent', { |
+ tag: 'my-tag', |
+ state: 'succeeded' |
+ }); |
+ |
+ assert_equals(event.type, 'BackgroundFetchClickEvent'); |
harkness
2017/03/09 19:41:15
Why not check these in the for loop above for each
Peter Beverloo
2017/03/10 00:42:50
Logically line 15/16 are testing that the allowed
|
+ assert_equals(event.cancelable, false); |
+ assert_equals(event.bubbles, false); |
+ assert_equals(event.tag, 'my-tag'); |
+ assert_equals(event.state, 'succeeded'); |
+ |
+ assert_inherits(event, 'waitUntil'); |
+ |
+}, 'Verifies that the BackgroundFetchClickEvent can be constructed.'); |