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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 251903006: Attempt 2 to enable async data: URL loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better fix for BrowserPlugin tests from lazyboy@ Created 6 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 | Annotate | Revision Log
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "content/child/request_extra_data.h" 12 #include "content/child/request_extra_data.h"
13 #include "content/child/service_worker/service_worker_network_provider.h" 13 #include "content/child/service_worker/service_worker_network_provider.h"
14 #include "content/common/frame_messages.h" 14 #include "content/common/frame_messages.h"
15 #include "content/common/ssl_status_serialization.h" 15 #include "content/common/ssl_status_serialization.h"
16 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
17 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/native_web_keyboard_event.h" 18 #include "content/public/browser/native_web_keyboard_event.h"
19 #include "content/public/browser/web_ui_controller_factory.h" 19 #include "content/public/browser/web_ui_controller_factory.h"
20 #include "content/public/common/bindings_policy.h" 20 #include "content/public/common/bindings_policy.h"
21 #include "content/public/common/page_zoom.h" 21 #include "content/public/common/page_zoom.h"
22 #include "content/public/common/url_constants.h" 22 #include "content/public/common/url_constants.h"
23 #include "content/public/common/url_utils.h" 23 #include "content/public/common/url_utils.h"
24 #include "content/public/renderer/content_renderer_client.h" 24 #include "content/public/renderer/content_renderer_client.h"
25 #include "content/public/renderer/document_state.h" 25 #include "content/public/renderer/document_state.h"
26 #include "content/public/renderer/navigation_state.h" 26 #include "content/public/renderer/navigation_state.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #include "content/public/test/frame_load_waiter.h"
28 #include "content/public/test/render_view_test.h" 29 #include "content/public/test/render_view_test.h"
29 #include "content/public/test/test_utils.h" 30 #include "content/public/test/test_utils.h"
30 #include "content/renderer/accessibility/renderer_accessibility.h" 31 #include "content/renderer/accessibility/renderer_accessibility.h"
31 #include "content/renderer/accessibility/renderer_accessibility_complete.h" 32 #include "content/renderer/accessibility/renderer_accessibility_complete.h"
32 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" 33 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h"
33 #include "content/renderer/history_controller.h" 34 #include "content/renderer/history_controller.h"
34 #include "content/renderer/history_serialization.h" 35 #include "content/renderer/history_serialization.h"
35 #include "content/renderer/render_view_impl.h" 36 #include "content/renderer/render_view_impl.h"
36 #include "content/shell/browser/shell.h" 37 #include "content/shell/browser/shell.h"
37 #include "content/shell/browser/shell_browser_context.h" 38 #include "content/shell/browser/shell_browser_context.h"
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 int was_page_c = -1; 1814 int was_page_c = -1;
1814 base::string16 check_page_c = 1815 base::string16 check_page_c =
1815 base::ASCIIToUTF16( 1816 base::ASCIIToUTF16(
1816 "Number(document.getElementById('pagename').innerHTML == 'Page C')"); 1817 "Number(document.getElementById('pagename').innerHTML == 'Page C')");
1817 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); 1818 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
1818 EXPECT_EQ(1, was_page_b); 1819 EXPECT_EQ(1, was_page_b);
1819 1820
1820 blink::WebHistoryItem forward_item = 1821 blink::WebHistoryItem forward_item =
1821 view()->history_controller()->GetCurrentItemForExport(); 1822 view()->history_controller()->GetCurrentItemForExport();
1822 GoBack(view()->history_controller()->GetPreviousItemForExport()); 1823 GoBack(view()->history_controller()->GetPreviousItemForExport());
1824 FrameLoadWaiter(view()).Wait();
sky 2014/04/30 13:30:59 Why does this code need FrameLoadWaiter? Should Fr
dcheng 2014/04/30 17:56:06 Done. Thanks for noticing this.
1823 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); 1825 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
1824 EXPECT_EQ(1, was_page_b); 1826 EXPECT_EQ(1, was_page_b);
1825 1827
1826 GoForward(forward_item); 1828 GoForward(forward_item);
1829 FrameLoadWaiter(view()).Wait();
1827 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); 1830 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
1828 EXPECT_EQ(1, was_page_c); 1831 EXPECT_EQ(1, was_page_c);
1829 1832
1830 GoBack(view()->history_controller()->GetPreviousItemForExport()); 1833 GoBack(view()->history_controller()->GetPreviousItemForExport());
1834 FrameLoadWaiter(view()).Wait();
1831 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); 1835 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
1832 EXPECT_EQ(1, was_page_b); 1836 EXPECT_EQ(1, was_page_b);
1833 1837
1834 forward_item = view()->history_controller()->GetCurrentItemForExport(); 1838 forward_item = view()->history_controller()->GetCurrentItemForExport();
1835 GoBack(page_a_item); 1839 GoBack(page_a_item);
1840 FrameLoadWaiter(view()).Wait();
1836 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); 1841 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a));
1837 EXPECT_EQ(1, was_page_a); 1842 EXPECT_EQ(1, was_page_a);
1838 1843
1839 GoForward(forward_item); 1844 GoForward(forward_item);
1845 FrameLoadWaiter(view()).Wait();
1840 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); 1846 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
1841 EXPECT_EQ(1, was_page_b); 1847 EXPECT_EQ(1, was_page_b);
1842 } 1848 }
1843 1849
1844 #if defined(OS_MACOSX) || defined(USE_AURA) 1850 #if defined(OS_MACOSX) || defined(USE_AURA)
1845 TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) { 1851 TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
1846 1852
1847 #if defined(OS_WIN) 1853 #if defined(OS_WIN)
1848 // http://crbug.com/304193 1854 // http://crbug.com/304193
1849 if (base::win::GetVersion() < base::win::VERSION_VISTA) 1855 if (base::win::GetVersion() < base::win::VERSION_VISTA)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 FrameMsg_Navigate_Params nav_params; 2010 FrameMsg_Navigate_Params nav_params;
2005 nav_params.url = GURL("data:text/html,world"); 2011 nav_params.url = GURL("data:text/html,world");
2006 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2012 nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2007 nav_params.transition = PAGE_TRANSITION_TYPED; 2013 nav_params.transition = PAGE_TRANSITION_TYPED;
2008 nav_params.current_history_list_length = 1; 2014 nav_params.current_history_list_length = 1;
2009 nav_params.current_history_list_offset = 0; 2015 nav_params.current_history_list_offset = 0;
2010 nav_params.pending_history_list_offset = 1; 2016 nav_params.pending_history_list_offset = 1;
2011 nav_params.page_id = -1; 2017 nav_params.page_id = -1;
2012 nav_params.frame_to_navigate = "frame"; 2018 nav_params.frame_to_navigate = "frame";
2013 frame()->OnNavigate(nav_params); 2019 frame()->OnNavigate(nav_params);
2014 ProcessPendingMessages(); 2020 FrameLoadWaiter(view()).Wait();
2015 2021
2016 // Copy the document content to std::wstring and compare with the 2022 // Copy the document content to std::wstring and compare with the
2017 // expected result. 2023 // expected result.
2018 const int kMaxOutputCharacters = 256; 2024 const int kMaxOutputCharacters = 256;
2019 std::string output = base::UTF16ToUTF8( 2025 std::string output = base::UTF16ToUTF8(
2020 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 2026 GetMainFrame()->contentAsText(kMaxOutputCharacters));
2021 EXPECT_EQ(output, "hello \n\nworld"); 2027 EXPECT_EQ(output, "hello \n\nworld");
2022 } 2028 }
2023 2029
2024 // This test ensures that a RenderFrame object is created for the top level 2030 // This test ensures that a RenderFrame object is created for the top level
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 // Start a load that will reach provisional state synchronously, 2160 // Start a load that will reach provisional state synchronously,
2155 // but won't complete synchronously. 2161 // but won't complete synchronously.
2156 FrameMsg_Navigate_Params params; 2162 FrameMsg_Navigate_Params params;
2157 params.page_id = -1; 2163 params.page_id = -1;
2158 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2164 params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2159 params.url = GURL("data:text/html,test data"); 2165 params.url = GURL("data:text/html,test data");
2160 frame()->OnNavigate(params); 2166 frame()->OnNavigate(params);
2161 2167
2162 // An error occurred. 2168 // An error occurred.
2163 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error); 2169 view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
2164 ProcessPendingMessages(); 2170 // The error page itself is loaded asynchronously.
2171 FrameLoadWaiter(view()).Wait();
2165 const int kMaxOutputCharacters = 22; 2172 const int kMaxOutputCharacters = 22;
2166 EXPECT_EQ("A suffusion of yellow.", 2173 EXPECT_EQ("A suffusion of yellow.",
2167 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2174 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2168 } 2175 }
2169 2176
2170 // Tests if IME API's candidatewindow* events sent from browser are handled 2177 // Tests if IME API's candidatewindow* events sent from browser are handled
2171 // in renderer. 2178 // in renderer.
2172 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { 2179 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) {
2173 // Sends an HTML with an <input> element and scripts to the renderer. 2180 // Sends an HTML with an <input> element and scripts to the renderer.
2174 // The script handles all 3 of candidatewindow* events for an 2181 // The script handles all 3 of candidatewindow* events for an
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 // The load started, we should receive a start notification and a progress 2246 // The load started, we should receive a start notification and a progress
2240 // update with the minimum progress. 2247 // update with the minimum progress.
2241 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching( 2248 const IPC::Message* message = render_thread_->sink().GetFirstMessageMatching(
2242 ViewHostMsg_DidChangeLoadProgress::ID); 2249 ViewHostMsg_DidChangeLoadProgress::ID);
2243 EXPECT_TRUE(message); 2250 EXPECT_TRUE(message);
2244 Tuple1<double> progress_value; 2251 Tuple1<double> progress_value;
2245 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); 2252 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value);
2246 EXPECT_EQ(0.1, progress_value.a); 2253 EXPECT_EQ(0.1, progress_value.a);
2247 render_thread_->sink().ClearMessages(); 2254 render_thread_->sink().ClearMessages();
2248 2255
2249 ProcessPendingMessages(); 2256 FrameLoadWaiter(view()).Wait();
2250 2257
2251 // The data url has loaded, so we should see a progress change to 1.0 (done) 2258 // The data url has loaded, so we should see a progress change to 1.0 (done)
2252 // and a stop notification. 2259 // and a stop notification.
2253 message = render_thread_->sink().GetFirstMessageMatching( 2260 message = render_thread_->sink().GetFirstMessageMatching(
2254 ViewHostMsg_DidChangeLoadProgress::ID); 2261 ViewHostMsg_DidChangeLoadProgress::ID);
2255 EXPECT_TRUE(message); 2262 EXPECT_TRUE(message);
2256 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value); 2263 ViewHostMsg_DidChangeLoadProgress::Read(message, &progress_value);
2257 EXPECT_EQ(1.0, progress_value.a); 2264 EXPECT_EQ(1.0, progress_value.a);
2258 2265
2259 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( 2266 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 view()->renderer_accessibility()->GetType()); 2362 view()->renderer_accessibility()->GetType());
2356 2363
2357 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); 2364 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly);
2358 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); 2365 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode());
2359 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); 2366 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility());
2360 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, 2367 ASSERT_EQ(RendererAccessibilityTypeFocusOnly,
2361 view()->renderer_accessibility()->GetType()); 2368 view()->renderer_accessibility()->GetType());
2362 } 2369 }
2363 2370
2364 } // namespace content 2371 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698