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

Side by Side Diff: chrome/browser/do_not_track_browsertest.cc

Issue 10911283: Implement 'Do Not Track' header (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(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/string16.h"
6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_tabstrip.h"
11 #include "chrome/common/pref_names.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h"
14
15 typedef InProcessBrowserTest DoNotTrackTest;
16
17 // Check that the DNT header is sent when the corresponding preference is set.
18 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Simple) {
19 ASSERT_TRUE(test_server()->Start());
20
21 PrefService* prefs = browser()->profile()->GetPrefs();
22 prefs->SetBoolean(prefs::kEnableDoNotTrack, true);
23
24 GURL url = test_server()->GetURL("echoheader?DNT");
25 ui_test_utils::NavigateToURL(browser(), url);
26
27 int matches = ui_test_utils::FindInPage(
28 chrome::GetActiveTabContents(browser()),
29 string16(ASCIIToUTF16("1")),
30 true /* forward */, false /* match case */, NULL /* ordinal */,
31 NULL /* selection_rect */);
32
33 EXPECT_EQ(1, matches);
34 }
35
36 // Check that the DNT header is preserved during redirects.
37 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Redirect) {
38 ASSERT_TRUE(test_server()->Start());
39
40 PrefService* prefs = browser()->profile()->GetPrefs();
41 prefs->SetBoolean(prefs::kEnableDoNotTrack, true);
42
43 GURL final_url = test_server()->GetURL("echoheader?DNT");
44 GURL url = test_server()->GetURL(
45 std::string("server-redirect?") + final_url.spec());
46 ui_test_utils::NavigateToURL(browser(), url);
47
48 int matches = ui_test_utils::FindInPage(
49 chrome::GetActiveTabContents(browser()),
50 string16(ASCIIToUTF16("1")),
51 true /* forward */, false /* match case */, NULL /* ordinal */,
52 NULL /* selection_rect */);
53
54 EXPECT_EQ(1, matches);
55 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/api/web_request/web_request_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698