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

Unified Diff: content/browser/background_sync/background_sync_manager_unittest.cc

Issue 1316743002: Reland of [Background Sync] Allow sync manager access from uncontrolled clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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: content/browser/background_sync/background_sync_manager_unittest.cc
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc
index e80881c12ee41f3cca8082c5e93781397412db4b..b6b73fd40748abd9d60f44281c04676f1c286375 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -374,7 +374,20 @@ class BackgroundSyncManagerTest : public testing::Test {
const BackgroundSyncRegistrationOptions& options) {
bool was_called = false;
background_sync_manager_->Register(
- sw_registration_id, options,
+ sw_registration_id, options, true /* requested_from_service_worker */,
+ base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
+ base::Unretained(this), &was_called));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(was_called);
+ return callback_status_ == BACKGROUND_SYNC_STATUS_OK;
+ }
+
+ bool RegisterFromDocumentWithServiceWorkerId(
+ int64 sw_registration_id,
+ const BackgroundSyncRegistrationOptions& options) {
+ bool was_called = false;
+ background_sync_manager_->Register(
+ sw_registration_id, options, false /* requested_from_service_worker */,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &was_called));
base::RunLoop().RunUntilIdle();
@@ -782,6 +795,7 @@ TEST_F(BackgroundSyncManagerTest, SequentialOperations) {
bool get_registration_called = false;
test_background_sync_manager_->Register(
sw_registration_id_1_, sync_options_1_,
+ true /* requested_from_service_worker */,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &register_called));
test_background_sync_manager_->Unregister(
@@ -839,6 +853,7 @@ TEST_F(BackgroundSyncManagerTest,
bool callback_called = false;
test_background_sync_manager_->Register(
sw_registration_id_1_, sync_options_2_,
+ true /* requested_from_service_worker */,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &callback_called));
@@ -1269,6 +1284,12 @@ TEST_F(BackgroundSyncManagerTest, RegisterExistingFailsWithoutWindow) {
EXPECT_FALSE(Register(sync_options_1_));
}
+TEST_F(BackgroundSyncManagerTest, RegisterSucceedsFromUncontrolledWindow) {
+ RemoveWindowClients();
+ EXPECT_TRUE(RegisterFromDocumentWithServiceWorkerId(sw_registration_id_1_,
+ sync_options_1_));
+}
+
TEST_F(BackgroundSyncManagerTest, UnregisterSucceedsWithoutWindow) {
EXPECT_TRUE(Register(sync_options_1_));
RemoveWindowClients();

Powered by Google App Engine
This is Rietveld 408576698