Allow overlapping sync and async startup requests
[chromium-blink-merge.git] / webkit / common / user_agent / user_agent_unittest.cc
blobbed7652dc699143d4eed069cc5fddb89310ada74
1 // Copyright (c) 2012 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.
5 #include "webkit/common/user_agent/user_agent.h"
7 #include <string>
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h"
12 namespace {
14 typedef testing::Test WebkitGlueUserAgentTest;
16 bool IsSpoofedUserAgent(const std::string& user_agent) {
17 return user_agent.find("TestContentClient") == std::string::npos;
20 TEST_F(WebkitGlueUserAgentTest, UserAgentSpoofingHack) {
21 enum Platform {
22 NONE = 0,
23 MACOSX = 1,
24 WIN = 2,
25 OTHER = 4,
28 struct Expected {
29 const char* url;
30 int os_mask;
33 Expected expected[] = {
34 { "http://wwww.google.com", NONE },
35 { "http://www.microsoft.com/getsilverlight", MACOSX },
36 { "http://downloads.yahoo.co.jp/docs/silverlight/", MACOSX },
37 { "http://gyao.yahoo.co.jp/", MACOSX },
38 { "http://promotion.shopping.yahoo.co.jp/", WIN },
40 #if defined(OS_MACOSX)
41 int os_bit = MACOSX;
42 #elif defined(OS_WIN)
43 int os_bit = WIN;
44 #else
45 int os_bit = OTHER;
46 #endif
48 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
49 EXPECT_EQ((expected[i].os_mask & os_bit) != 0,
50 IsSpoofedUserAgent(
51 webkit_glue::GetUserAgent(GURL(expected[i].url))));
55 } // namespace