OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/file_path.h" | |
jochen (gone - plz use gerrit)
2012/09/13 15:35:48
nit. not required
battre
2012/09/13 16:16:07
Done.
| |
6 #include "base/string16.h" | |
7 #include "base/utf_string_conversions.h" | |
8 #include "chrome/browser/prefs/pref_service.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/browser/ui/browser.h" | |
11 #include "chrome/browser/ui/browser_tabstrip.h" | |
jochen (gone - plz use gerrit)
2012/09/13 15:35:48
not required?
battre
2012/09/13 16:16:07
Needed for chrome::GetActiveTabContents.
| |
12 #include "chrome/common/pref_names.h" | |
13 #include "chrome/test/base/in_process_browser_test.h" | |
14 #include "chrome/test/base/ui_test_utils.h" | |
15 #include "content/public/browser/web_contents.h" | |
jochen (gone - plz use gerrit)
2012/09/13 15:35:48
the next three headers are not required?
battre
2012/09/13 16:16:07
Done.
| |
16 #include "content/public/test/browser_test_utils.h" | |
17 #include "net/test/test_server.h" | |
18 | |
19 typedef InProcessBrowserTest DoNotTrackTest; | |
20 | |
21 // Check that the DNT header is sent when the corresponding preference is set. | |
22 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Simple) { | |
23 ASSERT_TRUE(test_server()->Start()); | |
24 | |
25 PrefService* prefs = browser()->profile()->GetPrefs(); | |
26 prefs->SetBoolean(prefs::kEnableDoNotTrack, true); | |
27 | |
28 GURL url = test_server()->GetURL("echoheader?DNT"); | |
29 ui_test_utils::NavigateToURL(browser(), url); | |
30 | |
31 int matches = ui_test_utils::FindInPage( | |
32 chrome::GetActiveTabContents(browser()), | |
33 string16(ASCIIToUTF16("1")), | |
34 true /* forward */, false /* match case */, NULL /* ordinal */, | |
35 NULL /* selection_rect */); | |
36 | |
37 EXPECT_EQ(1, matches); | |
38 } | |
39 | |
40 // Check that the DNT header is preserved during redirects. | |
41 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Redirect) { | |
42 ASSERT_TRUE(test_server()->Start()); | |
43 | |
44 PrefService* prefs = browser()->profile()->GetPrefs(); | |
45 prefs->SetBoolean(prefs::kEnableDoNotTrack, true); | |
46 | |
47 GURL final_url = test_server()->GetURL("echoheader?DNT"); | |
48 GURL url = test_server()->GetURL( | |
49 std::string("server-redirect?") + final_url.spec()); | |
50 ui_test_utils::NavigateToURL(browser(), url); | |
51 | |
52 int matches = ui_test_utils::FindInPage( | |
53 chrome::GetActiveTabContents(browser()), | |
54 string16(ASCIIToUTF16("1")), | |
55 true /* forward */, false /* match case */, NULL /* ordinal */, | |
56 NULL /* selection_rect */); | |
57 | |
58 EXPECT_EQ(1, matches); | |
59 } | |
OLD | NEW |