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

Side by Side Diff: chrome/browser/media/protected_media_identifier_permission_context_unittest.cc

Issue 2816773002: Added switch for bypassing protected media identifier permission (Closed)
Patch Set: Added switch for bypassing permissions Created 3 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2017 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/media/protected_media_identifier_permission_context.h"
6
7 #include "base/test/scoped_command_line.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "media/base/media_switches.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h"
12
13 class ProtectedMediaIdentifierPermissionContextTest : public testing::Test {
14 public:
15 ProtectedMediaIdentifierPermissionContextTest()
16 : requesting_domain_("https://example.com"),
17 requesting_sub_domain_("https://subdomain.example.com") {
18 command_line_ = scoped_command_line_.GetProcessCommandLine();
19 }
20
21 bool IsDomainWhitelisted(const GURL& domain) {
22 return ProtectedMediaIdentifierPermissionContext::IsDomainWhitelisted(
23 domain);
24 }
25
26 GURL requesting_domain_;
27 GURL requesting_sub_domain_;
28
29 base::test::ScopedCommandLine scoped_command_line_;
30 base::CommandLine* command_line_;
31 };
32
33 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
34 BypassWithFlagWithSingleDomain) {
35 // The request should need to ask for permission
36 ASSERT_FALSE(IsDomainWhitelisted(requesting_domain_));
37
38 // Add the switch value that the
39 // ProtectedMediaIdentifierPermissionContext::reads from
40 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
41 command_line_->AppendSwitchASCII(
42 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
43 "example.com");
44
45 // The request should no longer need to ask for permission
46 ASSERT_TRUE(IsDomainWhitelisted(requesting_domain_));
47 }
48
49 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
50 BypassWithFlagWithDomainList) {
51 // The request should need to ask for permission
52 ASSERT_FALSE(IsDomainWhitelisted(requesting_domain_));
53
54 // Add the switch value that the
55 // ProtectedMediaIdentifierPermissionContext::reads from
56 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
57 command_line_->AppendSwitchASCII(
58 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
59 "example.ca,example.com,example.edu");
60
61 // The request should no longer need to ask for permission
62 ASSERT_TRUE(IsDomainWhitelisted(requesting_domain_));
63 }
64
65 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
66 BypassWithFlagAndSubdomain) {
67 // The request should need to ask for permission
68 ASSERT_FALSE(IsDomainWhitelisted(requesting_sub_domain_));
69
70 // Add the switch value that the
71 // ProtectedMediaIdentifierPermissionContext::reads from
72 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
73 command_line_->AppendSwitchASCII(
74 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
75 "example.com");
76
77 // The request should no longer need to ask for permission
78 ASSERT_TRUE(IsDomainWhitelisted(requesting_sub_domain_));
79 }
80
81 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
82 BypassRequiresUserDataDir) {
83 // The request should need to ask for permission
84 ASSERT_FALSE(IsDomainWhitelisted(requesting_domain_));
85
86 // Add the switch value that the
87 // ProtectedMediaIdentifierPermissionContext::reads from
88 command_line_->AppendSwitchASCII(
89 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
90 "example.com");
91
92 // The request should still need to ask for permission
93 ASSERT_FALSE(IsDomainWhitelisted(requesting_domain_));
94
95 // Set the user data dir switch but do not give it a value, this should still
96 // require the request to ask for permission.
97 command_line_->AppendSwitch(switches::kUserDataDir);
98
99 // The request should still need to ask for permission
100 ASSERT_FALSE(IsDomainWhitelisted(requesting_domain_));
101
102 // Set the user data dir so the request should no longer need to ask for
103 // permission
104 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
105
106 // The request should no longer need to ask for permission
107 ASSERT_TRUE(IsDomainWhitelisted(requesting_domain_));
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698