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

Unified Diff: chrome/browser/do_not_track_browsertest.cc

Issue 10960042: Add navigator.doNotTrack property (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/renderer_preferences_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index f1b391d4391b75eb371b074a6ba7d3261c7ff515..acaafc71e960170dad87d41de1f466bc7079c815 100644
--- a/chrome/browser/do_not_track_browsertest.cc
+++ b/chrome/browser/do_not_track_browsertest.cc
@@ -11,6 +11,8 @@
#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"
+#include "content/public/test/browser_test_utils.h"
typedef InProcessBrowserTest DoNotTrackTest;
@@ -53,3 +55,32 @@ IN_PROC_BROWSER_TEST_F(DoNotTrackTest, Redirect) {
EXPECT_EQ(1, matches);
}
+
+// Check that the DOM property is set when the corresponding preference is set.
+IN_PROC_BROWSER_TEST_F(DoNotTrackTest, DOMProperty) {
+ PrefService* prefs = browser()->profile()->GetPrefs();
+ prefs->SetBoolean(prefs::kEnableDoNotTrack, true);
+
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
+ chrome::GetActiveWebContents(browser())));
+
+ std::string do_not_track;
+ EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString(
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
+ std::wstring(),
+ L"window.domAutomationController.send(navigator.doNotTrack)",
+ &do_not_track));
+ EXPECT_EQ("1", do_not_track);
+
+ // Reset flag and check that the changed value is propagated to the existing
+ // renderer.
+ prefs->SetBoolean(prefs::kEnableDoNotTrack, false);
+
+ EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString(
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
+ std::wstring(),
+ L"window.domAutomationController.send("
+ L"navigator.doNotTrack === null ? '0' : '1')",
+ &do_not_track));
+ EXPECT_EQ("0", do_not_track);
+}
« no previous file with comments | « no previous file | chrome/browser/renderer_preferences_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698