Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / notifications / notification_permission_context_unittest.cc
blobfedbb305d68c39527e03458f6749eeb029808f0e
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.
5 #include "chrome/browser/notifications/notification_permission_context.h"
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"
17 // Web Notification permission requests will completely ignore the embedder
18 // origin. See https://crbug.com/416894.
19 TEST(NotificationPermissionContextTest, IgnoresEmbedderOrigin) {
20 content::TestBrowserThreadBundle thread_bundle;
21 TestingProfile profile;
23 GURL requesting_origin("https://example.com");
24 GURL embedding_origin("https://chrome.com");
25 GURL different_origin("https://foobar.com");
27 NotificationPermissionContext context(&profile);
28 context.UpdateContentSetting(requesting_origin,
29 embedding_origin,
30 CONTENT_SETTING_ALLOW);
32 EXPECT_EQ(CONTENT_SETTING_ALLOW,
33 context.GetPermissionStatus(requesting_origin, embedding_origin));
35 EXPECT_EQ(CONTENT_SETTING_ALLOW,
36 context.GetPermissionStatus(requesting_origin, different_origin));
38 context.ResetPermission(requesting_origin, embedding_origin);
40 EXPECT_EQ(CONTENT_SETTING_ASK,
41 context.GetPermissionStatus(requesting_origin, embedding_origin));
43 EXPECT_EQ(CONTENT_SETTING_ASK,
44 context.GetPermissionStatus(requesting_origin, different_origin));
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;
53 GURL origin("http://example.com");
55 NotificationPermissionContext context(&profile);
56 EXPECT_EQ(CONTENT_SETTING_ASK,
57 context.GetPermissionStatus(origin, origin));
59 context.UpdateContentSetting(origin, origin, CONTENT_SETTING_ALLOW);
61 EXPECT_EQ(CONTENT_SETTING_ALLOW,
62 context.GetPermissionStatus(origin, origin));