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

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

Issue 2656043002: Use explicit WebString conversions in remaining content files (Closed)
Patch Set: build fix Created 3 years, 11 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
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 #include <stdint.h> 6 #include <stdint.h>
7 #include <tuple> 7 #include <tuple>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // by content-layer, renderer code (still the constructed, partial 181 // by content-layer, renderer code (still the constructed, partial
182 // FrameReplicationState is sufficiently complete to avoid trigerring 182 // FrameReplicationState is sufficiently complete to avoid trigerring
183 // asserts that a default/empty FrameReplicationState would). 183 // asserts that a default/empty FrameReplicationState would).
184 FrameReplicationState ReconstructReplicationStateForTesting( 184 FrameReplicationState ReconstructReplicationStateForTesting(
185 TestRenderFrame* test_render_frame) { 185 TestRenderFrame* test_render_frame) {
186 blink::WebLocalFrame* frame = test_render_frame->GetWebFrame(); 186 blink::WebLocalFrame* frame = test_render_frame->GetWebFrame();
187 187
188 FrameReplicationState result; 188 FrameReplicationState result;
189 // can't recover result.scope - no way to get WebTreeScopeType via public 189 // can't recover result.scope - no way to get WebTreeScopeType via public
190 // blink API... 190 // blink API...
191 result.name = base::UTF16ToUTF8(base::StringPiece16(frame->assignedName())); 191 result.name = frame->assignedName().utf8();
192 result.unique_name = 192 result.unique_name = frame->uniqueName().utf8();
193 base::UTF16ToUTF8(base::StringPiece16(frame->uniqueName()));
194 result.sandbox_flags = frame->effectiveSandboxFlags(); 193 result.sandbox_flags = frame->effectiveSandboxFlags();
195 // result.should_enforce_strict_mixed_content_checking is calculated in the 194 // result.should_enforce_strict_mixed_content_checking is calculated in the
196 // browser... 195 // browser...
197 result.origin = frame->getSecurityOrigin(); 196 result.origin = frame->getSecurityOrigin();
198 197
199 return result; 198 return result;
200 } 199 }
201 200
202 // Returns CommonNavigationParams for a normal navigation to a data: url, with 201 // Returns CommonNavigationParams for a normal navigation to a data: url, with
203 // navigation_start set to Now() plus the given offset. 202 // navigation_start set to Now() plus the given offset.
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 // TODO(hbono): we should verify messages to be sent from the back-end. 1267 // TODO(hbono): we should verify messages to be sent from the back-end.
1269 view()->UpdateTextInputState(); 1268 view()->UpdateTextInputState();
1270 ProcessPendingMessages(); 1269 ProcessPendingMessages();
1271 render_thread_->sink().ClearMessages(); 1270 render_thread_->sink().ClearMessages();
1272 1271
1273 if (ime_message->result) { 1272 if (ime_message->result) {
1274 // Retrieve the content of this page and compare it with the expected 1273 // Retrieve the content of this page and compare it with the expected
1275 // result. 1274 // result.
1276 const int kMaxOutputCharacters = 128; 1275 const int kMaxOutputCharacters = 128;
1277 base::string16 output = WebFrameContentDumper::dumpWebViewAsText( 1276 base::string16 output = WebFrameContentDumper::dumpWebViewAsText(
1278 view()->GetWebView(), kMaxOutputCharacters); 1277 view()->GetWebView(), kMaxOutputCharacters)
1278 .utf16();
1279 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); 1279 EXPECT_EQ(base::WideToUTF16(ime_message->result), output);
1280 } 1280 }
1281 } 1281 }
1282 } 1282 }
1283 1283
1284 // Test that the RenderView::OnSetTextDirection() function can change the text 1284 // Test that the RenderView::OnSetTextDirection() function can change the text
1285 // direction of the selected input element. 1285 // direction of the selected input element.
1286 TEST_F(RenderViewImplTest, OnSetTextDirection) { 1286 TEST_F(RenderViewImplTest, OnSetTextDirection) {
1287 // Load an HTML page consisting of a <textarea> element and a <div> element. 1287 // Load an HTML page consisting of a <textarea> element and a <div> element.
1288 // This test changes the text direction of the <textarea> element, and 1288 // This test changes the text direction of the <textarea> element, and
(...skipping 28 matching lines...) Expand all
1317 "var node = document.getElementById('test');" 1317 "var node = document.getElementById('test');"
1318 "var style = getComputedStyle(node, null);" 1318 "var style = getComputedStyle(node, null);"
1319 "result.innerText =" 1319 "result.innerText ="
1320 " node.getAttribute('dir') + ',' +" 1320 " node.getAttribute('dir') + ',' +"
1321 " style.getPropertyValue('direction');"); 1321 " style.getPropertyValue('direction');");
1322 1322
1323 // Copy the document content to std::wstring and compare with the 1323 // Copy the document content to std::wstring and compare with the
1324 // expected result. 1324 // expected result.
1325 const int kMaxOutputCharacters = 16; 1325 const int kMaxOutputCharacters = 16;
1326 base::string16 output = WebFrameContentDumper::dumpWebViewAsText( 1326 base::string16 output = WebFrameContentDumper::dumpWebViewAsText(
1327 view()->GetWebView(), kMaxOutputCharacters); 1327 view()->GetWebView(), kMaxOutputCharacters)
1328 .utf16();
1328 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); 1329 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output);
1329 } 1330 }
1330 } 1331 }
1331 1332
1332 // Crashy, http://crbug.com/53247. 1333 // Crashy, http://crbug.com/53247.
1333 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { 1334 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) {
1334 GetMainFrame()->enableViewSourceMode(true); 1335 GetMainFrame()->enableViewSourceMode(true);
1335 WebURLError error; 1336 WebURLError error;
1336 error.domain = WebString::fromUTF8(net::kErrorDomain); 1337 error.domain = WebString::fromUTF8(net::kErrorDomain);
1337 error.reason = net::ERR_FILE_NOT_FOUND; 1338 error.reason = net::ERR_FILE_NOT_FOUND;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 1686
1686 TestRenderFrame* subframe = 1687 TestRenderFrame* subframe =
1687 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( 1688 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame(
1688 view()->webview()->findFrameByName("frame"))); 1689 view()->webview()->findFrameByName("frame")));
1689 subframe->Navigate(common_params, StartNavigationParams(), request_params); 1690 subframe->Navigate(common_params, StartNavigationParams(), request_params);
1690 FrameLoadWaiter(subframe).Wait(); 1691 FrameLoadWaiter(subframe).Wait();
1691 1692
1692 // Copy the document content to std::wstring and compare with the 1693 // Copy the document content to std::wstring and compare with the
1693 // expected result. 1694 // expected result.
1694 const int kMaxOutputCharacters = 256; 1695 const int kMaxOutputCharacters = 256;
1695 std::string output = base::UTF16ToUTF8( 1696 std::string output = WebFrameContentDumper::dumpWebViewAsText(
1696 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText( 1697 view()->GetWebView(), kMaxOutputCharacters)
1697 view()->GetWebView(), kMaxOutputCharacters))); 1698 .utf8();
1698 EXPECT_EQ(output, "hello \n\nworld"); 1699 EXPECT_EQ(output, "hello \n\nworld");
1699 } 1700 }
1700 1701
1701 // This test ensures that a RenderFrame object is created for the top level 1702 // This test ensures that a RenderFrame object is created for the top level
1702 // frame in the RenderView. 1703 // frame in the RenderView.
1703 TEST_F(RenderViewImplTest, BasicRenderFrame) { 1704 TEST_F(RenderViewImplTest, BasicRenderFrame) {
1704 EXPECT_TRUE(view()->main_render_frame_); 1705 EXPECT_TRUE(view()->main_render_frame_);
1705 } 1706 }
1706 1707
1707 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { 1708 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 RequestNavigationParams()); 1828 RequestNavigationParams());
1828 1829
1829 // An error occurred. 1830 // An error occurred.
1830 main_frame->didFailProvisionalLoad(web_frame, error, 1831 main_frame->didFailProvisionalLoad(web_frame, error,
1831 blink::WebStandardCommit); 1832 blink::WebStandardCommit);
1832 1833
1833 // The error page itself is loaded asynchronously. 1834 // The error page itself is loaded asynchronously.
1834 FrameLoadWaiter(main_frame).Wait(); 1835 FrameLoadWaiter(main_frame).Wait();
1835 const int kMaxOutputCharacters = 22; 1836 const int kMaxOutputCharacters = 22;
1836 EXPECT_EQ("A suffusion of yellow.", 1837 EXPECT_EQ("A suffusion of yellow.",
1837 base::UTF16ToASCII( 1838 WebFrameContentDumper::dumpWebViewAsText(view()->GetWebView(),
1838 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText( 1839 kMaxOutputCharacters)
1839 view()->GetWebView(), kMaxOutputCharacters)))); 1840 .ascii());
1840 } 1841 }
1841 1842
1842 #if defined(OS_ANDROID) 1843 #if defined(OS_ANDROID)
1843 // Crashing on Android: http://crbug.com/311341 1844 // Crashing on Android: http://crbug.com/311341
1844 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \ 1845 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \
1845 DISABLED_HttpStatusCodeErrorWithEmptyBody 1846 DISABLED_HttpStatusCodeErrorWithEmptyBody
1846 #else 1847 #else
1847 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody 1848 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody
1848 #endif 1849 #endif
1849 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { 1850 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) {
(...skipping 12 matching lines...) Expand all
1862 1863
1863 // Emulate a 4xx/5xx main resource response with an empty body. 1864 // Emulate a 4xx/5xx main resource response with an empty body.
1864 main_frame->didReceiveResponse(response); 1865 main_frame->didReceiveResponse(response);
1865 main_frame->didFinishDocumentLoad(web_frame); 1866 main_frame->didFinishDocumentLoad(web_frame);
1866 main_frame->runScriptsAtDocumentReady(web_frame, true); 1867 main_frame->runScriptsAtDocumentReady(web_frame, true);
1867 1868
1868 // The error page itself is loaded asynchronously. 1869 // The error page itself is loaded asynchronously.
1869 FrameLoadWaiter(main_frame).Wait(); 1870 FrameLoadWaiter(main_frame).Wait();
1870 const int kMaxOutputCharacters = 22; 1871 const int kMaxOutputCharacters = 22;
1871 EXPECT_EQ("A suffusion of yellow.", 1872 EXPECT_EQ("A suffusion of yellow.",
1872 base::UTF16ToASCII( 1873 WebFrameContentDumper::dumpWebViewAsText(view()->GetWebView(),
1873 base::StringPiece16(WebFrameContentDumper::dumpWebViewAsText( 1874 kMaxOutputCharacters)
1874 view()->GetWebView(), kMaxOutputCharacters)))); 1875 .ascii());
1875 } 1876 }
1876 1877
1877 // Ensure the render view sends favicon url update events correctly. 1878 // Ensure the render view sends favicon url update events correctly.
1878 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { 1879 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
1879 // An event should be sent when a favicon url exists. 1880 // An event should be sent when a favicon url exists.
1880 LoadHTML("<html>" 1881 LoadHTML("<html>"
1881 "<head>" 1882 "<head>"
1882 "<link rel='icon' href='http://www.google.com/favicon.ico'>" 1883 "<link rel='icon' href='http://www.google.com/favicon.ico'>"
1883 "</head>" 1884 "</head>"
1884 "</html>"); 1885 "</html>");
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 ExpectPauseAndResume(3); 2556 ExpectPauseAndResume(3);
2556 blink::WebScriptSource source2( 2557 blink::WebScriptSource source2(
2557 WebString::fromUTF8("function func2() { func1(); }; func2();")); 2558 WebString::fromUTF8("function func2() { func1(); }; func2();"));
2558 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); 2559 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1);
2559 2560
2560 EXPECT_FALSE(IsPaused()); 2561 EXPECT_FALSE(IsPaused());
2561 Detach(); 2562 Detach();
2562 } 2563 }
2563 2564
2564 } // namespace content 2565 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698