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

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

Issue 2745573002: Implement the events for Background Fetch (Closed)
Patch Set: Implement the events for Background Fetch 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-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.');

Powered by Google App Engine
This is Rietveld 408576698