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

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

Issue 8773035: Content settings: allow scripts on interstitial pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/content_settings.h" 5 #include "chrome/common/content_settings.h"
6 #include "chrome/common/render_messages.h" 6 #include "chrome/common/render_messages.h"
7 #include "chrome/renderer/content_settings_observer.h" 7 #include "chrome/renderer/content_settings_observer.h"
8 #include "chrome/test/base/chrome_render_view_test.h" 8 #include "chrome/test/base/chrome_render_view_test.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 // Verify that the script was not blocked. 316 // Verify that the script was not blocked.
317 bool was_blocked = false; 317 bool was_blocked = false;
318 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 318 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
319 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i); 319 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i);
320 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID) 320 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID)
321 was_blocked = true; 321 was_blocked = true;
322 } 322 }
323 EXPECT_FALSE(was_blocked); 323 EXPECT_FALSE(was_blocked);
324 } 324 }
325
326 TEST_F(ChromeRenderViewTest, ContentSettingsAllowInterstitialScripts) {
327 // Block scripts
328 RendererContentSettingRules content_setting_rules;
329 ContentSettingsForOneType& script_setting_rules =
330 content_setting_rules.script_rules;
331 script_setting_rules.push_back(
332 ContentSettingPatternSource(
333 ContentSettingsPattern::Wildcard(),
334 ContentSettingsPattern::Wildcard(),
335 CONTENT_SETTING_BLOCK, "", false));
336
337 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_);
338 observer->SetContentSettingRules(&content_setting_rules);
339
340 observer->OnSetAsInterstitial();
341
342 // Load a page which contains a script.
343 std::string html = "<html>"
344 "<head>"
345 "<script src='data:foo'></script>"
346 "</head>"
347 "<body>"
348 "</body>"
349 "</html>";
350 LoadHTML(html.c_str());
351
352 // Verify that the script was allowed.
353 bool was_blocked = false;
354 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
355 const IPC::Message* msg = render_thread_->sink().GetMessageAt(i);
356 if (msg->type() == ChromeViewHostMsg_ContentBlocked::ID)
357 was_blocked = true;
358 }
359 EXPECT_FALSE(was_blocked);
360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698