Chromium Code Reviews| Index: chrome/browser/do_not_track_browsertest.cc |
| diff --git a/chrome/browser/do_not_track_browsertest.cc b/chrome/browser/do_not_track_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9909bc44aacab2eb013dbea32f1c9d8244e1b74f |
| --- /dev/null |
| +++ b/chrome/browser/do_not_track_browsertest.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2012 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/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.
|
| +#include "base/string16.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#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.
|
| +#include "chrome/common/pref_names.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| +#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.
|
| +#include "content/public/test/browser_test_utils.h" |
| +#include "net/test/test_server.h" |
| + |
| +typedef InProcessBrowserTest DoNotTrackTest; |
| + |
| +// Check that the DNT header is sent when the corresponding preference is set. |
| +IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Simple) { |
| + ASSERT_TRUE(test_server()->Start()); |
| + |
| + PrefService* prefs = browser()->profile()->GetPrefs(); |
| + prefs->SetBoolean(prefs::kEnableDoNotTrack, true); |
| + |
| + GURL url = test_server()->GetURL("echoheader?DNT"); |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + int matches = ui_test_utils::FindInPage( |
| + chrome::GetActiveTabContents(browser()), |
| + string16(ASCIIToUTF16("1")), |
| + true /* forward */, false /* match case */, NULL /* ordinal */, |
| + NULL /* selection_rect */); |
| + |
| + EXPECT_EQ(1, matches); |
| +} |
| + |
| +// Check that the DNT header is preserved during redirects. |
| +IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Redirect) { |
| + ASSERT_TRUE(test_server()->Start()); |
| + |
| + PrefService* prefs = browser()->profile()->GetPrefs(); |
| + prefs->SetBoolean(prefs::kEnableDoNotTrack, true); |
| + |
| + GURL final_url = test_server()->GetURL("echoheader?DNT"); |
| + GURL url = test_server()->GetURL( |
| + std::string("server-redirect?") + final_url.spec()); |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + int matches = ui_test_utils::FindInPage( |
| + chrome::GetActiveTabContents(browser()), |
| + string16(ASCIIToUTF16("1")), |
| + true /* forward */, false /* match case */, NULL /* ordinal */, |
| + NULL /* selection_rect */); |
| + |
| + EXPECT_EQ(1, matches); |
| +} |