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

Unified Diff: content/child/site_isolation_stats_gatherer_unittest.cc

Issue 1174323002: [Patch 5 of 6] Split out the site_isolation_policy files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename_policy_to_sniffer3
Patch Set: Pull Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/child/site_isolation_stats_gatherer_unittest.cc
diff --git a/net/test/channel_id_test_util.cc b/content/child/site_isolation_stats_gatherer_unittest.cc
similarity index 26%
copy from net/test/channel_id_test_util.cc
copy to content/child/site_isolation_stats_gatherer_unittest.cc
index 77007f2a879dee13009f7ba9b15911d1f5788494..23feb4a5bb70296ea4c6edf392ceef852787dcb4 100644
--- a/net/test/channel_id_test_util.cc
+++ b/content/child/site_isolation_stats_gatherer_unittest.cc
@@ -2,24 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/test/channel_id_test_util.h"
+#include "base/strings/string_piece.h"
+#include "content/child/site_isolation_stats_gatherer.h"
+#include "testing/gtest/include/gtest/gtest.h"
-#include <string>
+using base::StringPiece;
-#include "crypto/ec_private_key.h"
-#include "testing/gtest/include/gtest/gtest.h"
+namespace content {
+
+TEST(SiteIsolationStatsGathererTest, SniffForJS) {
+ StringPiece basic_js_data("var a = 4");
+ StringPiece js_data("\t\t\r\n var a = 4");
+ StringPiece json_data("\t\t\r\n { \"name\" : \"chrome\", ");
+ StringPiece empty_data("");
-namespace net {
+ EXPECT_TRUE(SiteIsolationStatsGatherer::SniffForJS(js_data));
+ EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(json_data));
-::testing::AssertionResult KeysEqual(crypto::ECPrivateKey* key1,
- crypto::ECPrivateKey* key2) {
- std::string public_key1, public_key2;
- EXPECT_TRUE(key1 && key1->ExportRawPublicKey(&public_key1));
- EXPECT_TRUE(key2 && key2->ExportRawPublicKey(&public_key2));
- if (public_key1 == public_key2)
- return ::testing::AssertionSuccess();
- else
- return ::testing::AssertionFailure();
+ // Basic bounds check.
+ EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(empty_data));
}
-} // namespace net
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698