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

Unified Diff: content/browser/background_fetch/background_fetch_service_unittest.cc

Issue 2781393002: Test aborting an inactive Background Fetch registration (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/background_fetch/background_fetch_service_unittest.cc
diff --git a/content/browser/background_fetch/background_fetch_service_unittest.cc b/content/browser/background_fetch/background_fetch_service_unittest.cc
index 29fbf9d02661b157b3eecee1d7bc23a9d863611a..769870c523c96430b5d33edc958212b4aadc8624 100644
--- a/content/browser/background_fetch/background_fetch_service_unittest.cc
+++ b/content/browser/background_fetch/background_fetch_service_unittest.cc
@@ -347,18 +347,28 @@ TEST_F(BackgroundFetchServiceTest, AbortInvalidArguments) {
// This test verifies that the Abort() function will kill the renderer and
// return INVALID_ARGUMENT when invalid data is send over the Mojo channel.
- BackgroundFetchOptions options;
+ BackgroundFetchRegistrationId registration_id(
+ 42 /* service_worker_registration_id */, origin(), "" /* tag */);
- // The `tag` must be a non-empty string.
- {
- BackgroundFetchRegistrationId registration_id(
- 42 /* service_worker_registration_id */, origin(), "" /* tag */);
+ blink::mojom::BackgroundFetchError error;
- blink::mojom::BackgroundFetchError error;
+ ASSERT_NO_FATAL_FAILURE(Abort(registration_id, &error));
+ ASSERT_EQ(error, blink::mojom::BackgroundFetchError::INVALID_ARGUMENT);
+}
- ASSERT_NO_FATAL_FAILURE(Abort(registration_id, &error));
- ASSERT_EQ(error, blink::mojom::BackgroundFetchError::INVALID_ARGUMENT);
- }
+TEST_F(BackgroundFetchServiceTest, AbortInvalidTag) {
+ // This test verifies that aborting a Background Fetch registration with a
+ // tag that does not correspond to an active fetch kindly tells us so.
+
+ BackgroundFetchRegistrationId registration_id;
+ ASSERT_TRUE(CreateRegistrationId(kExampleTag, &registration_id));
+
+ // Deliberate do *not* create a fetch for the |registration_id|.
+
+ blink::mojom::BackgroundFetchError error;
+
+ ASSERT_NO_FATAL_FAILURE(Abort(registration_id, &error));
+ ASSERT_EQ(error, blink::mojom::BackgroundFetchError::INVALID_TAG);
}
TEST_F(BackgroundFetchServiceTest, GetTags) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698