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

Side by Side 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: Re-upload. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 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 "net/test/channel_id_test_util.h" 5 #include "base/strings/string_piece.h"
6 6 #include "content/child/site_isolation_stats_gatherer.h"
7 #include <string>
8
9 #include "crypto/ec_private_key.h"
10 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
11 8
12 namespace net { 9 using base::StringPiece;
13 10
14 ::testing::AssertionResult KeysEqual(crypto::ECPrivateKey* key1, 11 namespace content {
15 crypto::ECPrivateKey* key2) { 12
16 std::string public_key1, public_key2; 13 TEST(SiteIsolationStatsGathererTest, SniffForJS) {
17 EXPECT_TRUE(key1 && key1->ExportRawPublicKey(&public_key1)); 14 StringPiece basic_js_data("var a = 4");
18 EXPECT_TRUE(key2 && key2->ExportRawPublicKey(&public_key2)); 15 StringPiece js_data("\t\t\r\n var a = 4");
19 if (public_key1 == public_key2) 16 StringPiece json_data("\t\t\r\n { \"name\" : \"chrome\", ");
20 return ::testing::AssertionSuccess(); 17 StringPiece empty_data("");
21 else 18
22 return ::testing::AssertionFailure(); 19 EXPECT_TRUE(SiteIsolationStatsGatherer::SniffForJS(js_data));
20 EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(json_data));
21
22 // Basic bounds check.
23 EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(empty_data));
23 } 24 }
24 25
25 } // namespace net 26 } // namespace content
OLDNEW
« no previous file with comments | « content/child/site_isolation_stats_gatherer_browsertest.cc ('k') | content/common/cross_site_document_classifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698