OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/string16.h" | 5 #include "base/string16.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Check that the DOM property is set when the corresponding preference is set. | 59 // Check that the DOM property is set when the corresponding preference is set. |
60 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, DOMProperty) { | 60 IN_PROC_BROWSER_TEST_F(DoNotTrackTest, DOMProperty) { |
61 PrefService* prefs = browser()->profile()->GetPrefs(); | 61 PrefService* prefs = browser()->profile()->GetPrefs(); |
62 prefs->SetBoolean(prefs::kEnableDoNotTrack, true); | 62 prefs->SetBoolean(prefs::kEnableDoNotTrack, true); |
63 | 63 |
64 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( | 64 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( |
65 chrome::GetActiveWebContents(browser()))); | 65 chrome::GetActiveWebContents(browser()))); |
66 | 66 |
67 std::string do_not_track; | 67 std::string do_not_track; |
68 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( | 68 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
69 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 69 chrome::GetActiveWebContents(browser()), |
70 "", | |
71 "window.domAutomationController.send(navigator.doNotTrack)", | 70 "window.domAutomationController.send(navigator.doNotTrack)", |
72 &do_not_track)); | 71 &do_not_track)); |
73 EXPECT_EQ("1", do_not_track); | 72 EXPECT_EQ("1", do_not_track); |
74 | 73 |
75 // Reset flag and check that the changed value is propagated to the existing | 74 // Reset flag and check that the changed value is propagated to the existing |
76 // renderer. | 75 // renderer. |
77 prefs->SetBoolean(prefs::kEnableDoNotTrack, false); | 76 prefs->SetBoolean(prefs::kEnableDoNotTrack, false); |
78 | 77 |
79 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( | 78 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
80 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 79 chrome::GetActiveWebContents(browser()), |
81 "", | |
82 "window.domAutomationController.send(" | 80 "window.domAutomationController.send(" |
83 " navigator.doNotTrack === null ? '0' : '1')", | 81 " navigator.doNotTrack === null ? '0' : '1')", |
84 &do_not_track)); | 82 &do_not_track)); |
85 EXPECT_EQ("0", do_not_track); | 83 EXPECT_EQ("0", do_not_track); |
86 } | 84 } |
OLD | NEW |