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

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

Issue 1976573002: Only use pending navigation params for browser-initiated navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: consistency Created 4 years, 7 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/content/common/content_settings_messages.h " 10 #include "components/content_settings/content/common/content_settings_messages.h "
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 ContentSettingsObserver* observer = 151 ContentSettingsObserver* observer =
152 ContentSettingsObserver::Get(view_->GetMainRenderFrame()); 152 ContentSettingsObserver::Get(view_->GetMainRenderFrame());
153 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 153 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin));
154 154
155 // Temporarily allow the "foo" plugin. 155 // Temporarily allow the "foo" plugin.
156 observer->OnLoadBlockedPlugins(foo_plugin); 156 observer->OnLoadBlockedPlugins(foo_plugin);
157 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 157 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin));
158 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 158 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
159 159
160 // Simulate a navigation within the page. 160 // Simulate a navigation within the page.
161 DidNavigateWithinPage(GetMainFrame(), true); 161 DidNavigateWithinPage(GetMainFrame(), true, true);
162 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 162 EXPECT_TRUE(observer->IsPluginTemporarilyAllowed(foo_plugin));
163 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 163 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
164 164
165 // Navigate to a different page. 165 // Navigate to a different page.
166 LoadHTML("<html>Bar</html>"); 166 LoadHTML("<html>Bar</html>");
167 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin)); 167 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(foo_plugin));
168 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin)); 168 EXPECT_FALSE(observer->IsPluginTemporarilyAllowed(bar_plugin));
169 169
170 // Temporarily allow all plugins. 170 // Temporarily allow all plugins.
171 observer->OnLoadBlockedPlugins(std::string()); 171 observer->OnLoadBlockedPlugins(std::string());
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 script_setting_rules.push_back(ContentSettingPatternSource( 421 script_setting_rules.push_back(ContentSettingPatternSource(
422 ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), 422 ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(),
423 CONTENT_SETTING_BLOCK, std::string(), false)); 423 CONTENT_SETTING_BLOCK, std::string(), false));
424 424
425 ContentSettingsObserver* observer = 425 ContentSettingsObserver* observer =
426 ContentSettingsObserver::Get(view_->GetMainRenderFrame()); 426 ContentSettingsObserver::Get(view_->GetMainRenderFrame());
427 observer->SetContentSettingRules(&content_setting_rules); 427 observer->SetContentSettingRules(&content_setting_rules);
428 428
429 // The page shouldn't see the change to script blocking setting after a 429 // The page shouldn't see the change to script blocking setting after a
430 // same page navigation. 430 // same page navigation.
431 DidNavigateWithinPage(GetMainFrame(), true); 431 DidNavigateWithinPage(GetMainFrame(), true, true);
432 EXPECT_TRUE(observer->allowScript(true)); 432 EXPECT_TRUE(observer->allowScript(true));
433 } 433 }
434 434
435 TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) { 435 TEST_F(ChromeRenderViewTest, ContentSettingsInterstitialPages) {
436 MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame()); 436 MockContentSettingsObserver mock_observer(view_->GetMainRenderFrame());
437 // Block scripts. 437 // Block scripts.
438 RendererContentSettingRules content_setting_rules; 438 RendererContentSettingRules content_setting_rules;
439 ContentSettingsForOneType& script_setting_rules = 439 ContentSettingsForOneType& script_setting_rules =
440 content_setting_rules.script_rules; 440 content_setting_rules.script_rules;
441 script_setting_rules.push_back( 441 script_setting_rules.push_back(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 ContentSettingPatternSource( 516 ContentSettingPatternSource(
517 ContentSettingsPattern::Wildcard(), 517 ContentSettingsPattern::Wildcard(),
518 ContentSettingsPattern::Wildcard(), 518 ContentSettingsPattern::Wildcard(),
519 CONTENT_SETTING_BLOCK, 519 CONTENT_SETTING_BLOCK,
520 std::string(), 520 std::string(),
521 false)); 521 false));
522 522
523 EXPECT_FALSE(observer->allowAutoplay(true)); 523 EXPECT_FALSE(observer->allowAutoplay(true));
524 ::testing::Mock::VerifyAndClearExpectations(&observer); 524 ::testing::Mock::VerifyAndClearExpectations(&observer);
525 } 525 }
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