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

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 GURL requesting_domain_;
22 GURL requesting_sub_domain_;
23
24 base::test::ScopedCommandLine scoped_command_line_;
25 base::CommandLine* command_line_;
26 };
27
28 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
29 BypassWithFlagWithSingleDomain) {
30 // The request should need to ask for permission
31 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
32 requesting_domain_));
33
34 // Add the switch value that the
35 // ProtectedMediaIdentifierPermissionContext::reads from
36 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
37 command_line_->AppendSwitchASCII(
38 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
39 "example.com");
40
41 // The request should no longer need to ask for permission
42 ASSERT_TRUE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
43 requesting_domain_));
44 }
45
46 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
47 BypassWithFlagWithDomainList) {
48 // The request should need to ask for permission
49 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
50 requesting_domain_));
51
52 // Add the switch value that the
53 // ProtectedMediaIdentifierPermissionContext::reads from
54 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
55 command_line_->AppendSwitchASCII(
56 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
57 "example.ca,example.com,example.edu");
58
59 // The request should no longer need to ask for permission
60 ASSERT_TRUE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
61 requesting_domain_));
62 }
63
64 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
65 BypassWithFlagAndSubdomain) {
66 // The request should need to ask for permission
67 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
68 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(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
79 requesting_sub_domain_));
80 }
81
82 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
83 BypassRequiresUserDataDir) {
84 // The request should need to ask for permission
85 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
86 requesting_domain_));
87
88 // Add the switch value that the
89 // ProtectedMediaIdentifierPermissionContext::reads from
90 command_line_->AppendSwitchASCII(
91 switches::kDisableInfobarForProtectedMediaIdentifierForDomain,
92 "example.com");
93
94 // The request should still need to ask for permission
95 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
96 requesting_domain_));
97
98 // Set the user data dir switch but do not give it a value, this should still
99 // require the request to ask for permission.
100 command_line_->AppendSwitch(switches::kUserDataDir);
101
102 // The request should still need to ask for permission
103 ASSERT_FALSE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
104 requesting_domain_));
105
106 // Set the user data dir so the request should no longer need to ask for
107 // permission
108 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
109
110 // The request should no longer need to ask for permission
111 ASSERT_TRUE(ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
112 requesting_domain_));
113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698