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

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: Rebasing to HEAD 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_origin_("https://example.com"),
17 requesting_sub_domain_origin_("https://subdomain.example.com") {
18 command_line_ = scoped_command_line_.GetProcessCommandLine();
19 }
20
21 bool IsOriginWhitelisted(const GURL& origin) {
22 return ProtectedMediaIdentifierPermissionContext::IsOriginWhitelisted(
23 origin);
24 }
25
26 GURL requesting_origin_;
27 GURL requesting_sub_domain_origin_;
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(IsOriginWhitelisted(requesting_origin_));
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::kUnsafelyAllowProtectedMediaIdentifierForDomain, "example.com");
43
44 // The request should no longer need to ask for permission
45 ASSERT_TRUE(IsOriginWhitelisted(requesting_origin_));
46 }
47
48 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
49 BypassWithFlagWithDomainList) {
50 // The request should need to ask for permission
51 ASSERT_FALSE(IsOriginWhitelisted(requesting_origin_));
52
53 // Add the switch value that the
54 // ProtectedMediaIdentifierPermissionContext::reads from
55 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
56 command_line_->AppendSwitchASCII(
57 switches::kUnsafelyAllowProtectedMediaIdentifierForDomain,
58 "example.ca,example.com,example.edu");
59
60 // The request should no longer need to ask for permission
61 ASSERT_TRUE(IsOriginWhitelisted(requesting_origin_));
62 }
63
64 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
65 BypassWithFlagAndSubdomain) {
66 // The request should need to ask for permission
67 ASSERT_FALSE(IsOriginWhitelisted(requesting_sub_domain_origin_));
68
69 // Add the switch value that the
70 // ProtectedMediaIdentifierPermissionContext::reads from
71 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
72 command_line_->AppendSwitchASCII(
73 switches::kUnsafelyAllowProtectedMediaIdentifierForDomain, "example.com");
74
75 // The request should no longer need to ask for permission
76 ASSERT_TRUE(IsOriginWhitelisted(requesting_sub_domain_origin_));
77 }
78
79 TEST_F(ProtectedMediaIdentifierPermissionContextTest,
80 BypassRequiresUserDataDir) {
81 // The request should need to ask for permission
82 ASSERT_FALSE(IsOriginWhitelisted(requesting_origin_));
83
84 // Add the switch value that the
85 // ProtectedMediaIdentifierPermissionContext::reads from
86 command_line_->AppendSwitchASCII(
87 switches::kUnsafelyAllowProtectedMediaIdentifierForDomain, "example.com");
88
89 // The request should still need to ask for permission
90 ASSERT_FALSE(IsOriginWhitelisted(requesting_origin_));
91
92 // Set the user data dir switch but do not give it a value, this should still
93 // require the request to ask for permission.
94 command_line_->AppendSwitch(switches::kUserDataDir);
95
96 // The request should still need to ask for permission
97 ASSERT_FALSE(IsOriginWhitelisted(requesting_origin_));
98
99 // Set the user data dir so the request should no longer need to ask for
100 // permission
101 command_line_->AppendSwitchASCII(switches::kUserDataDir, "/dir/for/testing");
102
103 // The request should no longer need to ask for permission
104 ASSERT_TRUE(IsOriginWhitelisted(requesting_origin_));
105 }
OLDNEW
« no previous file with comments | « chrome/browser/media/protected_media_identifier_permission_context.cc ('k') | chrome/browser/ui/startup/bad_flags_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698