summaryrefslogtreecommitdiffstats
path: root/content/child/site_isolation_stats_gatherer_unittest.cc
blob: 23feb4a5bb70296ea4c6edf392ceef852787dcb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/strings/string_piece.h"
#include "content/child/site_isolation_stats_gatherer.h"
#include "testing/gtest/include/gtest/gtest.h"

using base::StringPiece;

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("");

  EXPECT_TRUE(SiteIsolationStatsGatherer::SniffForJS(js_data));
  EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(json_data));

  // Basic bounds check.
  EXPECT_FALSE(SiteIsolationStatsGatherer::SniffForJS(empty_data));
}

}  // namespace content