OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/notifications/notification_permission_context.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/gtest_prod_util.h" | |
9 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/test/base/testing_profile.h" | |
12 #include "components/content_settings/core/browser/host_content_settings_map.h" | |
13 #include "content/public/test/test_browser_thread_bundle.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 #include "url/gurl.h" | |
16 | |
17 // Web Notification permission requests will completely ignore the embedder | |
18 // origin. See https://crbug.com/416894. | |
19 TEST(NotificationPermissionContextTest, IgnoresEmbedderOrigin) { | |
mlamouri (slow - plz ping)
2015/06/30 14:27:11
I think having a test class would be better becaus
Peter Beverloo
2015/06/30 14:35:23
Acknowledged. I prefer the current form, so I'll l
| |
20 content::TestBrowserThreadBundle thread_bundle; | |
21 TestingProfile profile; | |
22 | |
23 GURL requesting_origin("https://example.com"); | |
24 GURL embedding_origin("https://chrome.com"); | |
25 GURL different_origin("https://foobar.com"); | |
26 | |
27 NotificationPermissionContext context(&profile); | |
28 context.UpdateContentSetting(requesting_origin, | |
29 embedding_origin, | |
30 CONTENT_SETTING_ALLOW); | |
31 | |
32 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
33 context.GetPermissionStatus(requesting_origin, embedding_origin)); | |
34 | |
35 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
36 context.GetPermissionStatus(requesting_origin, different_origin)); | |
37 | |
38 context.ResetPermission(requesting_origin, embedding_origin); | |
39 | |
40 EXPECT_EQ(CONTENT_SETTING_ASK, | |
41 context.GetPermissionStatus(requesting_origin, embedding_origin)); | |
42 | |
43 EXPECT_EQ(CONTENT_SETTING_ASK, | |
44 context.GetPermissionStatus(requesting_origin, different_origin)); | |
45 } | |
46 | |
47 // Web Notifications do not require a secure origin when requesting permission. | |
48 // See https://crbug.com/404095. | |
49 TEST(NotificationPermissionContextTest, NoSecureOriginRequirement) { | |
50 content::TestBrowserThreadBundle thread_bundle; | |
51 TestingProfile profile; | |
52 | |
53 GURL origin("http://example.com"); | |
54 | |
55 NotificationPermissionContext context(&profile); | |
56 EXPECT_EQ(CONTENT_SETTING_ASK, | |
57 context.GetPermissionStatus(origin, origin)); | |
58 | |
59 context.UpdateContentSetting(origin, origin, CONTENT_SETTING_ALLOW); | |
60 | |
61 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
62 context.GetPermissionStatus(origin, origin)); | |
63 } | |
OLD | NEW |