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

Side by Side Diff: chrome/renderer/app_categorizer_unittest.cc

Issue 1974413003: Whitelist hangouts.google.com further to allow video effects plugin access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use static methods instead of namespace Created 4 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
« no previous file with comments | « chrome/renderer/app_categorizer.cc ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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/renderer/app_categorizer.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h"
9
10 namespace {
11
12 const char* kChatAppURLs[] = {
13 "https://hangouts.google.com/hangouts/foo",
14 "https://hAnGoUtS.gOoGlE.com/HaNgOuTs/foo",
15 "https://meet.google.com/hangouts/foo",
16 "https://talkgadget.google.com/hangouts/foo",
17 "https://staging.talkgadget.google.com/hangouts/foo",
18 "https://plus.google.com/hangouts/foo",
19 "https://plus.sandbox.google.com/hangouts/foo"
20 };
21
22 const char* kChatManifestFSs[] = {
23 "filesystem:https://hangouts.google.com/foo",
24 "filesystem:https://hAnGoUtS.gOoGlE.com/foo",
25 "filesystem:https://meet.google.com/foo",
26 "filesystem:https://talkgadget.google.com/foo",
27 "filesystem:https://staging.talkgadget.google.com/foo",
28 "filesystem:https://plus.google.com/foo",
29 "filesystem:https://plus.sandbox.google.com/foo"
30 };
31
32 const char* kBadChatAppURLs[] = {
33 "http://talkgadget.google.com/hangouts/foo", // not https
34 "https://talkgadget.evil.com/hangouts/foo" // domain not whitelisted
35 };
36
37 const char* kPhotosAppURLs[] = {
38 "https://foo.plus.google.com",
39 "https://foo.plus.sandbox.google.com"
40 };
41
42 const char* kPhotosManifestURLs[] = {
43 "https://ssl.gstatic.com/photos/nacl/foo",
44 "https://ssl.gstatic.com/s2/oz/nacl/foo"
45 };
46
47 const char* kBadPhotosAppURLs[] = {
48 "https://plus.google.com/foo",
49 "https://plus.google.com/foo",
50 "https://plus.google.com/foo",
51 "http://plus.google.com/foo", // http scheme
52 "https://plus.evil.com/foo", // domain not whitelisted
53 };
54
55 const char* kBadPhotosManifestURLs[] = {
56 "http://ssl.gstatic.com/photos/nacl/foo", // http scheme
57 "https://lss.gstatic.com/photos/nacl/foo", // bad hostname
58 "https://ssl.gstatic.com/wrong/photos/nacl/foo", // bad path
59 "https://ssl.gstatic.com/photos/nacl/foo",
60 "https://ssl.gstatic.com/photos/nacl/foo",
61 };
62
63 } // namespace
64
65 TEST(AppCategorizerTest, IsHangoutsUrl) {
66 for (size_t i = 0; i < arraysize(kChatAppURLs); ++i) {
67 EXPECT_TRUE(AppCategorizer::IsHangoutsUrl(GURL(kChatAppURLs[i])));
68 }
69
70 for (size_t i = 0; i < arraysize(kBadChatAppURLs); ++i) {
71 EXPECT_FALSE(AppCategorizer::IsHangoutsUrl(GURL(kBadChatAppURLs[i])));
72 }
73 }
74
75 TEST(AppCategorizerTest, IsWhitelistedApp) {
76 // Hangouts app
77 {
78 EXPECT_EQ(arraysize(kChatAppURLs), arraysize(kChatManifestFSs));
79 for (size_t i = 0; i < arraysize(kChatAppURLs); ++i) {
80 EXPECT_TRUE(AppCategorizer::IsWhitelistedApp(
81 GURL(kChatManifestFSs[i]), GURL(kChatAppURLs[i])));
82 }
83 for (size_t i = 0; i < arraysize(kBadChatAppURLs); ++i) {
84 EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
85 GURL("filesystem:https://irrelevant.com/"),
86 GURL(kBadChatAppURLs[i])));
87 }
88
89 // Manifest URL not filesystem
90 EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
91 GURL("https://hangouts.google.com/foo"),
92 GURL("https://hangouts.google.com/hangouts/foo")));
93
94 // Manifest URL not https
95 EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
96 GURL("filesystem:http://hangouts.google.com/foo"),
97 GURL("https://hangouts.google.com/hangouts/foo")));
98
99 // Manifest URL hostname does not match that of the app URL
100 EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
101 GURL("filesystem:https://meet.google.com/foo"),
102 GURL("https://hangouts.google.com/hangouts/foo")));
103 }
104
105 // Photos app
106 {
107 EXPECT_EQ(arraysize(kPhotosAppURLs), arraysize(kPhotosManifestURLs));
108 for (size_t i = 0; i < arraysize(kPhotosAppURLs); ++i) {
109 EXPECT_TRUE(AppCategorizer::IsWhitelistedApp(
110 GURL(kPhotosManifestURLs[i]), GURL(kPhotosAppURLs[i])));
111 }
112 // The app/manifest two sides do not have any coorelation for the Photos app
113 for (size_t i = 0; i < arraysize(kPhotosAppURLs); ++i) {
114 EXPECT_TRUE(AppCategorizer::IsWhitelistedApp(
115 GURL(kPhotosManifestURLs[(i + 1) % arraysize(kPhotosAppURLs)]),
116 GURL(kPhotosAppURLs[i])));
117 }
118
119 EXPECT_EQ(arraysize(kBadPhotosAppURLs), arraysize(kBadPhotosManifestURLs));
120 for (size_t i = 0; i < arraysize(kBadPhotosAppURLs); ++i) {
121 EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
122 GURL(kBadPhotosManifestURLs[i]), GURL(kBadPhotosAppURLs[i])));
123 }
124 }
125 }
OLDNEW
« no previous file with comments | « chrome/renderer/app_categorizer.cc ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698