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

Side by Side Diff: chrome/renderer/content_settings_observer_browsertest.cc

Issue 2799093002: s/DidNavigateWithinPage/OnSameDocumentNavigation. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/content_settings_observer.h" 8 #include "chrome/renderer/content_settings_observer.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 9 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "components/content_settings/core/common/content_settings.h" 10 #include "components/content_settings/core/common/content_settings.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 ContentSettingsObserver* observer = 150 ContentSettingsObserver* observer =
151 ContentSettingsObserver::Get(view_->GetMainRenderFrame()); 151 ContentSettingsObserver::Get(view_->GetMainRenderFrame());
152 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 152 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin));
153 153
154 // Temporarily allow the "foo" plugin. 154 // Temporarily allow the "foo" plugin.
155 observer->OnLoadBlockedPlugins(foo_plugin); 155 observer->OnLoadBlockedPlugins(foo_plugin);
156 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 156 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin));
157 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 157 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
158 158
159 // Simulate a navigation within the page. 159 // Simulate same document navigation.
160 DidNavigateWithinPage(GetMainFrame(), true, true); 160 OnSameDocumentNavigation(GetMainFrame(), true, true);
161 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 161 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin));
162 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 162 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
163 163
164 // Navigate to a different page. 164 // Navigate to a different page.
165 LoadHTML("<html>Bar</html>"); 165 LoadHTML("<html>Bar</html>");
166 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 166 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin));
167 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 167 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
168 168
169 // Temporarily allow all plugins. 169 // Temporarily allow all plugins.
170 observer->OnLoadBlockedPlugins(std::string()); 170 observer->OnLoadBlockedPlugins(std::string());
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 content_setting_rules.script_rules; 419 content_setting_rules.script_rules;
420 script_setting_rules.push_back(ContentSettingPatternSource( 420 script_setting_rules.push_back(ContentSettingPatternSource(
421 ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), 421 ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(),
422 CONTENT_SETTING_BLOCK, std::string(), false)); 422 CONTENT_SETTING_BLOCK, std::string(), false));
423 423
424 ContentSettingsObserver* observer = 424 ContentSettingsObserver* observer =
425 ContentSettingsObserver::Get(view_->GetMainRenderFrame()); 425 ContentSettingsObserver::Get(view_->GetMainRenderFrame());
426 observer->SetContentSettingRules(&content_setting_rules); 426 observer->SetContentSettingRules(&content_setting_rules);
427 427
428 // The page shouldn't see the change to script blocking setting after a 428 // The page shouldn't see the change to script blocking setting after a
429 // same page navigation. 429 // same document navigation.
430 DidNavigateWithinPage(GetMainFrame(), true, true); 430 OnSameDocumentNavigation(GetMainFrame(), true, true);
431 EXPECT_TRUE(observer->allowScript(true)); 431 EXPECT_TRUE(observer->allowScript(true));
432 } 432 }
433 433
434 TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) { 434 TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) {
435 MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); 435 MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame());
436 // Block scripts. 436 // Block scripts.
437 RendererContentSettingRules content_setting_rules; 437 RendererContentSettingRules content_setting_rules;
438 ContentSettingsForOneType& script_setting_rules = 438 ContentSettingsForOneType& script_setting_rules =
439 content_setting_rules.script_rules; 439 content_setting_rules.script_rules;
440 script_setting_rules.push_back( 440 script_setting_rules.push_back(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 ContentSettingPatternSource( 515 ContentSettingPatternSource(
516 ContentSettingsPattern::Wildcard(), 516 ContentSettingsPattern::Wildcard(),
517 ContentSettingsPattern::Wildcard(), 517 ContentSettingsPattern::Wildcard(),
518 CONTENT_SETTING_BLOCK, 518 CONTENT_SETTING_BLOCK,
519 std::string(), 519 std::string(),
520 false)); 520 false));
521 521
522 EXPECT_FALSE(observer->allowAutoplay(true)); 522 EXPECT_FALSE(observer->allowAutoplay(true));
523 ::testing::Mock::VerifyAndClearExpectations(&observer); 523 ::testing::Mock::VerifyAndClearExpectations(&observer);
524 } 524 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698