| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 | 6 |
| 7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 error.domain.fromUTF8("test_domain"); | 764 error.domain.fromUTF8("test_domain"); |
| 765 error.reason = net::ERR_ABORTED; | 765 error.reason = net::ERR_ABORTED; |
| 766 error.unreachableURL = GURL("http://foo"); | 766 error.unreachableURL = GURL("http://foo"); |
| 767 WebFrame* web_frame = GetMainFrame(); | 767 WebFrame* web_frame = GetMainFrame(); |
| 768 // A cancellation occurred. | 768 // A cancellation occurred. |
| 769 view_->didFailProvisionalLoad(web_frame, error); | 769 view_->didFailProvisionalLoad(web_frame, error); |
| 770 // Frame should stay in view-source mode. | 770 // Frame should stay in view-source mode. |
| 771 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 771 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
| 772 } | 772 } |
| 773 | 773 |
| 774 // Regression test for http://crbug.com/35011 | |
| 775 TEST_F(RenderViewTest, JSBlockSentAfterPageLoad) { | |
| 776 // 1. Load page with JS. | |
| 777 std::string html = "<html>" | |
| 778 "<head>" | |
| 779 "<script>document.createElement('div');</script>" | |
| 780 "</head>" | |
| 781 "<body>" | |
| 782 "</body>" | |
| 783 "</html>"; | |
| 784 render_thread_.sink().ClearMessages(); | |
| 785 LoadHTML(html.c_str()); | |
| 786 | |
| 787 // 2. Block JavaScript. | |
| 788 ContentSettings settings; | |
| 789 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) | |
| 790 settings.settings[i] = CONTENT_SETTING_ALLOW; | |
| 791 settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] = CONTENT_SETTING_BLOCK; | |
| 792 view_->SetContentSettings(settings); | |
| 793 | |
| 794 // Make sure no pending messages are in the queue. | |
| 795 ProcessPendingMessages(); | |
| 796 render_thread_.sink().ClearMessages(); | |
| 797 | |
| 798 // 3. Reload page. | |
| 799 ViewMsg_Navigate_Params params; | |
| 800 std::string url_str = "data:text/html;charset=utf-8,"; | |
| 801 url_str.append(html); | |
| 802 GURL url(url_str); | |
| 803 params.url = url; | |
| 804 params.navigation_type = ViewMsg_Navigate_Type::RELOAD; | |
| 805 view_->OnNavigate(params); | |
| 806 ProcessPendingMessages(); | |
| 807 | |
| 808 // 4. Verify that the notification that javascript was blocked is sent after | |
| 809 // the navigation notifiction is sent. | |
| 810 int navigation_index = -1; | |
| 811 int block_index = -1; | |
| 812 for (size_t i = 0; i < render_thread_.sink().message_count(); ++i) { | |
| 813 const IPC::Message* msg = render_thread_.sink().GetMessageAt(i); | |
| 814 if (msg->type() == ViewHostMsg_FrameNavigate::ID) | |
| 815 navigation_index = i; | |
| 816 if (msg->type() == ViewHostMsg_ContentBlocked::ID) | |
| 817 block_index = i; | |
| 818 } | |
| 819 EXPECT_NE(-1, navigation_index); | |
| 820 EXPECT_NE(-1, block_index); | |
| 821 EXPECT_LT(navigation_index, block_index); | |
| 822 } | |
| 823 | |
| 824 // Regression test for http://crbug.com/41562 | 774 // Regression test for http://crbug.com/41562 |
| 825 TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) { | 775 TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) { |
| 826 const GURL invalid_gurl("http://"); | 776 const GURL invalid_gurl("http://"); |
| 827 view_->setMouseOverURL(WebKit::WebURL(invalid_gurl)); | 777 view_->setMouseOverURL(WebKit::WebURL(invalid_gurl)); |
| 828 EXPECT_EQ(invalid_gurl, view_->target_url_); | 778 EXPECT_EQ(invalid_gurl, view_->target_url_); |
| 829 } | 779 } |
| OLD | NEW |