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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 1158923002: Remove support for the "gcm_user_visible_only" manifest key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a message Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/barrier_closure.h" 8 #include "base/barrier_closure.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 private: 188 private:
189 scoped_ptr<net::SpawnedTestServer> https_server_; 189 scoped_ptr<net::SpawnedTestServer> https_server_;
190 gcm::FakeGCMProfileService* gcm_service_; 190 gcm::FakeGCMProfileService* gcm_service_;
191 PushMessagingServiceImpl* push_service_; 191 PushMessagingServiceImpl* push_service_;
192 scoped_ptr<StubNotificationUIManager> notification_manager_; 192 scoped_ptr<StubNotificationUIManager> notification_manager_;
193 193
194 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); 194 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest);
195 }; 195 };
196 196
197 class PushMessagingBadManifestBrowserTest : public PushMessagingBrowserTest {
198 std::string GetTestURL() override {
199 return "files/push_messaging/test_bad_manifest.html";
200 }
201 };
202
203 class PushMessagingManifestUserVisibleOnlyTrueTest
204 : public PushMessagingBrowserTest {
205 std::string GetTestURL() override {
206 return "files/push_messaging/test_user_visible_only_manifest.html";
207 }
208 };
209
210 class PushMessagingBrowserTestEmptySubscriptionOptions 197 class PushMessagingBrowserTestEmptySubscriptionOptions
211 : public PushMessagingBrowserTest { 198 : public PushMessagingBrowserTest {
212 std::string GetTestURL() override { 199 std::string GetTestURL() override {
213 return "files/push_messaging/test_no_subscription_options.html"; 200 return "files/push_messaging/test_no_subscription_options.html";
214 } 201 }
215 }; 202 };
216 203
217 IN_PROC_BROWSER_TEST_F(PushMessagingBadManifestBrowserTest,
218 SubscribeFailsNotVisibleMessages) {
219 std::string script_result;
220
221 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
222 ASSERT_EQ("ok - service worker registered", script_result);
223 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
224 EXPECT_EQ("AbortError - Registration failed - permission denied",
225 script_result);
226 }
227
228 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( 204 void PushMessagingBrowserTest::TryToSubscribeSuccessfully(
229 const std::string& expected_push_subscription_id) { 205 const std::string& expected_push_subscription_id) {
230 std::string script_result; 206 std::string script_result;
231 207
232 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); 208 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result));
233 EXPECT_EQ("ok - service worker registered", script_result); 209 EXPECT_EQ("ok - service worker registered", script_result);
234 210
235 InfoBarResponder accepting_responder(GetInfoBarService(), true); 211 InfoBarResponder accepting_responder(GetInfoBarService(), true);
236 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result)); 212 EXPECT_TRUE(RunScript("requestNotificationPermission()", &script_result));
237 EXPECT_EQ("permission status - granted", script_result); 213 EXPECT_EQ("permission status - granted", script_result);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 310
335 InfoBarResponder accepting_responder(GetInfoBarService(), true); 311 InfoBarResponder accepting_responder(GetInfoBarService(), true);
336 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); 312 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
337 ASSERT_EQ("permission status - granted", script_result); 313 ASSERT_EQ("permission status - granted", script_result);
338 314
339 ASSERT_TRUE(RunScript("subscribePush()", &script_result)); 315 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
340 EXPECT_EQ("AbortError - Registration failed - permission denied", 316 EXPECT_EQ("AbortError - Registration failed - permission denied",
341 script_result); 317 script_result);
342 } 318 }
343 319
344 IN_PROC_BROWSER_TEST_F(PushMessagingBadManifestBrowserTest,
345 RegisterFailsNotVisibleMessages) {
346 std::string script_result;
347
348 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
349 ASSERT_EQ("ok - service worker registered", script_result);
350 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
351 EXPECT_EQ("AbortError - Registration failed - permission denied",
352 script_result);
353 }
354
355 IN_PROC_BROWSER_TEST_F(PushMessagingManifestUserVisibleOnlyTrueTest,
356 ManifestKeyConsidered) {
357 // Chrome 42 introduced the "gcm_user_visible_only" manifest key, but Chrome
358 // 43 supersedes this by the standardized PushSubscriptionOptions.userVisible
359 // option. We maintain support for the manifest key without specifying the
360 // subscription option, so verify that it is still being considered.
361 std::string script_result;
362
363 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
364 ASSERT_EQ("ok - service worker registered", script_result);
365
366 InfoBarResponder accepting_responder(GetInfoBarService(), true);
367 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
368 EXPECT_EQ("permission status - granted", script_result);
369
370 ASSERT_TRUE(RunScript("subscribePush()", &script_result));
371 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result);
372
373 // permissionState has been introduced later so it does not
374 // respect the manifest key.
375 ASSERT_TRUE(RunScript("permissionState()", &script_result));
376 EXPECT_EQ(
377 "NotSupportedError - Push subscriptions that don't enable"
378 " userVisibleOnly are not supported.",
379 script_result);
380 }
381
382 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) { 320 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribePersisted) {
383 std::string script_result; 321 std::string script_result;
384 322
385 // First, test that Service Worker registration IDs are assigned in order of 323 // First, test that Service Worker registration IDs are assigned in order of
386 // registering the Service Workers, and the (fake) push subscription ids are 324 // registering the Service Workers, and the (fake) push subscription ids are
387 // assigned in order of push subscription (even when these orders are 325 // assigned in order of push subscription (even when these orders are
388 // different). 326 // different).
389 327
390 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 328 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
391 PushMessagingAppIdentifier sw0_identifier = 329 PushMessagingAppIdentifier sw0_identifier =
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 std::string script_result; 1035 std::string script_result;
1098 1036
1099 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 1037 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
1100 ASSERT_EQ("ok - service worker registered", script_result); 1038 ASSERT_EQ("ok - service worker registered", script_result);
1101 1039
1102 // In Incognito mode the promise returned by getSubscription should not hang, 1040 // In Incognito mode the promise returned by getSubscription should not hang,
1103 // it should just fulfill with null. 1041 // it should just fulfill with null.
1104 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 1042 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
1105 ASSERT_EQ("false - not subscribed", script_result); 1043 ASSERT_EQ("false - not subscribed", script_result);
1106 } 1044 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698