blob: eeea749ed8512a18d291195b2f4777a5acedaea3 (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (c) 2008 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/logging.h"
#include "chrome/renderer/user_script_slave.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(UserScriptSlaveTest, EscapeGlob) {
EXPECT_EQ("", UserScript::EscapeGlob(""));
EXPECT_EQ("*", UserScript::EscapeGlob("*"));
EXPECT_EQ("www.google.com", UserScript::EscapeGlob("www.google.com"));
EXPECT_EQ("*google.com*", UserScript::EscapeGlob("*google.com*"));
EXPECT_EQ("foo\\\\bar\\?hot=dog",
UserScript::EscapeGlob("foo\\bar?hot=dog"));
}
TEST(UserScriptSlaveTest, Match1) {
UserScript script("foo", "bar");
script.AddInclude("*mail.google.com*");
script.AddInclude("*mail.yahoo.com*");
script.AddInclude("*mail.msn.com*");
EXPECT_TRUE(script.MatchesUrl(GURL("http://mail.google.com")));
EXPECT_TRUE(script.MatchesUrl(GURL("http://mail.google.com/foo")));
EXPECT_TRUE(script.MatchesUrl(GURL("http://mail.yahoo.com/bar")));
EXPECT_TRUE(script.MatchesUrl(GURL("http://mail.msn.com/baz")));
EXPECT_FALSE(script.MatchesUrl(GURL("http://www.hotmail.com")));
}
TEST(UserScriptSlaveTest, Match2) {
UserScript script("foo", "bar");
script.AddInclude("*");
EXPECT_TRUE(script.MatchesUrl(GURL("http://foo.com/bar")));
EXPECT_TRUE(script.MatchesUrl(GURL("http://hot.com/dog")));
}
TEST(UserScriptSlaveTest, Match3) {
UserScript script("foo", "bar");
script.AddInclude("*foo*");
EXPECT_TRUE(script.MatchesUrl(GURL("http://foo.com/bar")));
EXPECT_FALSE(script.MatchesUrl(GURL("http://baz.org")));
}
|