OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/strings/string_piece.h" | 5 #include "base/strings/string_piece.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "content/common/cross_site_document_classifier.h" |
7 #include "content/child/site_isolation_policy.h" | |
8 #include "content/public/common/context_menu_params.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/WebKit/public/platform/WebURLResponse.h" | |
11 #include "ui/gfx/range/range.h" | |
12 | 8 |
13 using base::StringPiece; | 9 using base::StringPiece; |
14 | 10 |
15 namespace content { | 11 namespace content { |
16 | 12 |
17 TEST(CrossSiteDocumentClassifierTest, IsBlockableScheme) { | 13 TEST(CrossSiteDocumentClassifierTest, IsBlockableScheme) { |
18 GURL data_url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA=="); | 14 GURL data_url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA=="); |
19 GURL ftp_url("ftp://google.com"); | 15 GURL ftp_url("ftp://google.com"); |
20 GURL mailto_url("mailto:google@google.com"); | 16 GURL mailto_url("mailto:google@google.com"); |
21 GURL about_url("about:chrome"); | 17 GURL about_url("about:chrome"); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 StringPiece empty_data(""); | 109 StringPiece empty_data(""); |
114 | 110 |
115 EXPECT_TRUE(CrossSiteDocumentClassifier::SniffForJSON(json_data)); | 111 EXPECT_TRUE(CrossSiteDocumentClassifier::SniffForJSON(json_data)); |
116 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(non_json_data0)); | 112 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(non_json_data0)); |
117 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(non_json_data1)); | 113 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(non_json_data1)); |
118 | 114 |
119 // Basic bounds check. | 115 // Basic bounds check. |
120 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(empty_data)); | 116 EXPECT_FALSE(CrossSiteDocumentClassifier::SniffForJSON(empty_data)); |
121 } | 117 } |
122 | 118 |
123 TEST(SiteIsolationStatsGathererTest, SniffForJS) { | |
124 StringPiece basic_js_data("var a = 4"); | |
125 StringPiece js_data("\t\t\r\n var a = 4"); | |
126 StringPiece json_data("\t\t\r\n { \"name\" : \"chrome\", "); | |
127 StringPiece empty_data(""); | |
128 | |
129 EXPECT_TRUE(SiteIsolationStatsGatherer::SniffForJS(js_data)); | |
130 EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(json_data)); | |
131 | |
132 // Basic bounds check. | |
133 EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(empty_data)); | |
134 } | |
135 | |
136 } // namespace content | 119 } // namespace content |
OLD | NEW |