OLD | NEW |
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 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "content/test/test_render_frame.h" | 52 #include "content/test/test_render_frame.h" |
53 #include "net/base/net_errors.h" | 53 #include "net/base/net_errors.h" |
54 #include "net/cert/cert_status_flags.h" | 54 #include "net/cert/cert_status_flags.h" |
55 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
56 #include "third_party/WebKit/public/platform/WebData.h" | 56 #include "third_party/WebKit/public/platform/WebData.h" |
57 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 57 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
58 #include "third_party/WebKit/public/platform/WebString.h" | 58 #include "third_party/WebKit/public/platform/WebString.h" |
59 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 59 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
60 #include "third_party/WebKit/public/web/WebDataSource.h" | 60 #include "third_party/WebKit/public/web/WebDataSource.h" |
61 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 61 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 62 #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
62 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" | 63 #include "third_party/WebKit/public/web/WebHistoryCommitType.h" |
63 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 64 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
64 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 65 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
65 #include "third_party/WebKit/public/web/WebPerformance.h" | 66 #include "third_party/WebKit/public/web/WebPerformance.h" |
66 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 67 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
67 #include "third_party/WebKit/public/web/WebSettings.h" | 68 #include "third_party/WebKit/public/web/WebSettings.h" |
68 #include "third_party/WebKit/public/web/WebView.h" | 69 #include "third_party/WebKit/public/web/WebView.h" |
69 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 70 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
70 #include "ui/events/event.h" | 71 #include "ui/events/event.h" |
71 #include "ui/events/keycodes/keyboard_codes.h" | 72 #include "ui/events/keycodes/keyboard_codes.h" |
72 #include "ui/gfx/codec/jpeg_codec.h" | 73 #include "ui/gfx/codec/jpeg_codec.h" |
73 #include "ui/gfx/range/range.h" | 74 #include "ui/gfx/range/range.h" |
74 | 75 |
75 #if defined(USE_AURA) && defined(USE_X11) | 76 #if defined(USE_AURA) && defined(USE_X11) |
76 #include <X11/Xlib.h> | 77 #include <X11/Xlib.h> |
77 #include "ui/events/event_constants.h" | 78 #include "ui/events/event_constants.h" |
78 #include "ui/events/keycodes/keyboard_code_conversion.h" | 79 #include "ui/events/keycodes/keyboard_code_conversion.h" |
79 #include "ui/events/test/events_test_utils.h" | 80 #include "ui/events/test/events_test_utils.h" |
80 #include "ui/events/test/events_test_utils_x11.h" | 81 #include "ui/events/test/events_test_utils_x11.h" |
81 #endif | 82 #endif |
82 | 83 |
83 #if defined(USE_OZONE) | 84 #if defined(USE_OZONE) |
84 #include "ui/events/keycodes/keyboard_code_conversion.h" | 85 #include "ui/events/keycodes/keyboard_code_conversion.h" |
85 #endif | 86 #endif |
86 | 87 |
87 #include "url/url_constants.h" | 88 #include "url/url_constants.h" |
88 | 89 |
89 using blink::WebFrame; | 90 using blink::WebFrame; |
| 91 using blink::WebFrameContentDumper; |
90 using blink::WebInputEvent; | 92 using blink::WebInputEvent; |
91 using blink::WebLocalFrame; | 93 using blink::WebLocalFrame; |
92 using blink::WebMouseEvent; | 94 using blink::WebMouseEvent; |
93 using blink::WebRuntimeFeatures; | 95 using blink::WebRuntimeFeatures; |
94 using blink::WebString; | 96 using blink::WebString; |
95 using blink::WebTextDirection; | 97 using blink::WebTextDirection; |
96 using blink::WebURLError; | 98 using blink::WebURLError; |
97 | 99 |
98 namespace content { | 100 namespace content { |
99 | 101 |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 // Update the status of our IME back-end. | 1343 // Update the status of our IME back-end. |
1342 // TODO(hbono): we should verify messages to be sent from the back-end. | 1344 // TODO(hbono): we should verify messages to be sent from the back-end. |
1343 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 1345 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
1344 ProcessPendingMessages(); | 1346 ProcessPendingMessages(); |
1345 render_thread_->sink().ClearMessages(); | 1347 render_thread_->sink().ClearMessages(); |
1346 | 1348 |
1347 if (ime_message->result) { | 1349 if (ime_message->result) { |
1348 // Retrieve the content of this page and compare it with the expected | 1350 // Retrieve the content of this page and compare it with the expected |
1349 // result. | 1351 // result. |
1350 const int kMaxOutputCharacters = 128; | 1352 const int kMaxOutputCharacters = 128; |
1351 base::string16 output = | 1353 base::string16 output = WebFrameContentDumper::dumpFrameTreeAsText( |
1352 GetMainFrame()->contentAsText(kMaxOutputCharacters); | 1354 GetMainFrame(), kMaxOutputCharacters); |
1353 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); | 1355 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); |
1354 } | 1356 } |
1355 } | 1357 } |
1356 } | 1358 } |
1357 | 1359 |
1358 // Test that the RenderView::OnSetTextDirection() function can change the text | 1360 // Test that the RenderView::OnSetTextDirection() function can change the text |
1359 // direction of the selected input element. | 1361 // direction of the selected input element. |
1360 TEST_F(RenderViewImplTest, OnSetTextDirection) { | 1362 TEST_F(RenderViewImplTest, OnSetTextDirection) { |
1361 // Load an HTML page consisting of a <textarea> element and a <div> element. | 1363 // Load an HTML page consisting of a <textarea> element and a <div> element. |
1362 // This test changes the text direction of the <textarea> element, and | 1364 // This test changes the text direction of the <textarea> element, and |
(...skipping 28 matching lines...) Expand all Loading... |
1391 "var result = document.getElementById('result');" | 1393 "var result = document.getElementById('result');" |
1392 "var node = document.getElementById('test');" | 1394 "var node = document.getElementById('test');" |
1393 "var style = getComputedStyle(node, null);" | 1395 "var style = getComputedStyle(node, null);" |
1394 "result.innerText =" | 1396 "result.innerText =" |
1395 " node.getAttribute('dir') + ',' +" | 1397 " node.getAttribute('dir') + ',' +" |
1396 " style.getPropertyValue('direction');"); | 1398 " style.getPropertyValue('direction');"); |
1397 | 1399 |
1398 // Copy the document content to std::wstring and compare with the | 1400 // Copy the document content to std::wstring and compare with the |
1399 // expected result. | 1401 // expected result. |
1400 const int kMaxOutputCharacters = 16; | 1402 const int kMaxOutputCharacters = 16; |
1401 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 1403 base::string16 output = WebFrameContentDumper::dumpFrameTreeAsText( |
| 1404 GetMainFrame(), kMaxOutputCharacters); |
1402 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); | 1405 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); |
1403 } | 1406 } |
1404 } | 1407 } |
1405 | 1408 |
1406 // Test that we can receive correct DOM events when we send input events | 1409 // Test that we can receive correct DOM events when we send input events |
1407 // through the RenderWidget::OnHandleInputEvent() function. | 1410 // through the RenderWidget::OnHandleInputEvent() function. |
1408 TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) { | 1411 TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) { |
1409 #if !defined(OS_MACOSX) | 1412 #if !defined(OS_MACOSX) |
1410 // Load an HTML page consisting of one <input> element and three | 1413 // Load an HTML page consisting of one <input> element and three |
1411 // contentediable <div> elements. | 1414 // contentediable <div> elements. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 "%d,%s", // texts in the third <div> element | 1534 "%d,%s", // texts in the third <div> element |
1532 key_code, kModifierData[j].expected_result, | 1535 key_code, kModifierData[j].expected_result, |
1533 static_cast<int>(char_code[0]), | 1536 static_cast<int>(char_code[0]), |
1534 kModifierData[j].expected_result, | 1537 kModifierData[j].expected_result, |
1535 key_code, kModifierData[j].expected_result); | 1538 key_code, kModifierData[j].expected_result); |
1536 | 1539 |
1537 // Retrieve the text in the test page and compare it with the expected | 1540 // Retrieve the text in the test page and compare it with the expected |
1538 // text created from a virtual-key code, a character code, and the | 1541 // text created from a virtual-key code, a character code, and the |
1539 // modifier-key status. | 1542 // modifier-key status. |
1540 const int kMaxOutputCharacters = 1024; | 1543 const int kMaxOutputCharacters = 1024; |
1541 std::string output = base::UTF16ToUTF8(base::StringPiece16( | 1544 std::string output = base::UTF16ToUTF8( |
1542 GetMainFrame()->contentAsText(kMaxOutputCharacters))); | 1545 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( |
| 1546 GetMainFrame(), kMaxOutputCharacters))); |
1543 EXPECT_EQ(expected_result, output); | 1547 EXPECT_EQ(expected_result, output); |
1544 } | 1548 } |
1545 } | 1549 } |
1546 } | 1550 } |
1547 #else | 1551 #else |
1548 NOTIMPLEMENTED(); | 1552 NOTIMPLEMENTED(); |
1549 #endif | 1553 #endif |
1550 } | 1554 } |
1551 | 1555 |
1552 // Test that our EditorClientImpl class can insert characters when we send | 1556 // Test that our EditorClientImpl class can insert characters when we send |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 base::string16 char_code; | 1767 base::string16 char_code; |
1764 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) | 1768 if (SendKeyEvent(layout, key_code, modifiers, &char_code) < 0) |
1765 continue; | 1769 continue; |
1766 } | 1770 } |
1767 } | 1771 } |
1768 | 1772 |
1769 // Retrieve the text in the test page and compare it with the expected | 1773 // Retrieve the text in the test page and compare it with the expected |
1770 // text created from a virtual-key code, a character code, and the | 1774 // text created from a virtual-key code, a character code, and the |
1771 // modifier-key status. | 1775 // modifier-key status. |
1772 const int kMaxOutputCharacters = 4096; | 1776 const int kMaxOutputCharacters = 4096; |
1773 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 1777 base::string16 output = WebFrameContentDumper::dumpFrameTreeAsText( |
| 1778 GetMainFrame(), kMaxOutputCharacters); |
1774 EXPECT_EQ(base::WideToUTF16(kLayouts[i].expected_result), output); | 1779 EXPECT_EQ(base::WideToUTF16(kLayouts[i].expected_result), output); |
1775 } | 1780 } |
1776 #else | 1781 #else |
1777 NOTIMPLEMENTED(); | 1782 NOTIMPLEMENTED(); |
1778 #endif | 1783 #endif |
1779 } | 1784 } |
1780 | 1785 |
1781 // Crashy, http://crbug.com/53247. | 1786 // Crashy, http://crbug.com/53247. |
1782 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { | 1787 TEST_F(RenderViewImplTest, DISABLED_DidFailProvisionalLoadWithErrorForError) { |
1783 GetMainFrame()->enableViewSourceMode(true); | 1788 GetMainFrame()->enableViewSourceMode(true); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2098 | 2103 |
2099 TestRenderFrame* subframe = | 2104 TestRenderFrame* subframe = |
2100 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( | 2105 static_cast<TestRenderFrame*>(RenderFrameImpl::FromWebFrame( |
2101 view()->webview()->findFrameByName("frame"))); | 2106 view()->webview()->findFrameByName("frame"))); |
2102 subframe->Navigate(common_params, StartNavigationParams(), request_params); | 2107 subframe->Navigate(common_params, StartNavigationParams(), request_params); |
2103 FrameLoadWaiter(subframe).Wait(); | 2108 FrameLoadWaiter(subframe).Wait(); |
2104 | 2109 |
2105 // Copy the document content to std::wstring and compare with the | 2110 // Copy the document content to std::wstring and compare with the |
2106 // expected result. | 2111 // expected result. |
2107 const int kMaxOutputCharacters = 256; | 2112 const int kMaxOutputCharacters = 256; |
2108 std::string output = base::UTF16ToUTF8(base::StringPiece16( | 2113 std::string output = base::UTF16ToUTF8( |
2109 GetMainFrame()->contentAsText(kMaxOutputCharacters))); | 2114 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( |
| 2115 GetMainFrame(), kMaxOutputCharacters))); |
2110 EXPECT_EQ(output, "hello \n\nworld"); | 2116 EXPECT_EQ(output, "hello \n\nworld"); |
2111 } | 2117 } |
2112 | 2118 |
2113 // This test ensures that a RenderFrame object is created for the top level | 2119 // This test ensures that a RenderFrame object is created for the top level |
2114 // frame in the RenderView. | 2120 // frame in the RenderView. |
2115 TEST_F(RenderViewImplTest, BasicRenderFrame) { | 2121 TEST_F(RenderViewImplTest, BasicRenderFrame) { |
2116 EXPECT_TRUE(view()->main_render_frame_); | 2122 EXPECT_TRUE(view()->main_render_frame_); |
2117 } | 2123 } |
2118 | 2124 |
2119 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { | 2125 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 2225 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
2220 common_params.url = GURL("data:text/html,test data"); | 2226 common_params.url = GURL("data:text/html,test data"); |
2221 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); | 2227 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); |
2222 main_frame->Navigate(common_params, StartNavigationParams(), | 2228 main_frame->Navigate(common_params, StartNavigationParams(), |
2223 RequestNavigationParams()); | 2229 RequestNavigationParams()); |
2224 | 2230 |
2225 // An error occurred. | 2231 // An error occurred. |
2226 main_frame->didFailProvisionalLoad(web_frame, error, | 2232 main_frame->didFailProvisionalLoad(web_frame, error, |
2227 blink::WebStandardCommit); | 2233 blink::WebStandardCommit); |
2228 const int kMaxOutputCharacters = 22; | 2234 const int kMaxOutputCharacters = 22; |
2229 EXPECT_EQ("", base::UTF16ToASCII( | 2235 EXPECT_EQ("", base::UTF16ToASCII(base::StringPiece16( |
2230 base::StringPiece16(web_frame->contentAsText(kMaxOutputCharacters)))); | 2236 WebFrameContentDumper::dumpFrameTreeAsText( |
| 2237 web_frame, kMaxOutputCharacters)))); |
2231 } | 2238 } |
2232 | 2239 |
2233 #if defined(OS_ANDROID) | 2240 #if defined(OS_ANDROID) |
2234 // Crashing on Android: http://crbug.com/311341 | 2241 // Crashing on Android: http://crbug.com/311341 |
2235 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress | 2242 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress |
2236 #else | 2243 #else |
2237 #define MAYBE_DoesNotSuppress DoesNotSuppress | 2244 #define MAYBE_DoesNotSuppress DoesNotSuppress |
2238 #endif | 2245 #endif |
2239 | 2246 |
2240 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { | 2247 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) { |
(...skipping 13 matching lines...) Expand all Loading... |
2254 RequestNavigationParams()); | 2261 RequestNavigationParams()); |
2255 | 2262 |
2256 // An error occurred. | 2263 // An error occurred. |
2257 main_frame->didFailProvisionalLoad(web_frame, error, | 2264 main_frame->didFailProvisionalLoad(web_frame, error, |
2258 blink::WebStandardCommit); | 2265 blink::WebStandardCommit); |
2259 | 2266 |
2260 // The error page itself is loaded asynchronously. | 2267 // The error page itself is loaded asynchronously. |
2261 FrameLoadWaiter(main_frame).Wait(); | 2268 FrameLoadWaiter(main_frame).Wait(); |
2262 const int kMaxOutputCharacters = 22; | 2269 const int kMaxOutputCharacters = 22; |
2263 EXPECT_EQ("A suffusion of yellow.", | 2270 EXPECT_EQ("A suffusion of yellow.", |
2264 base::UTF16ToASCII(base::StringPiece16( | 2271 base::UTF16ToASCII( |
2265 web_frame->contentAsText(kMaxOutputCharacters)))); | 2272 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( |
| 2273 web_frame, kMaxOutputCharacters)))); |
2266 } | 2274 } |
2267 | 2275 |
2268 #if defined(OS_ANDROID) | 2276 #if defined(OS_ANDROID) |
2269 // Crashing on Android: http://crbug.com/311341 | 2277 // Crashing on Android: http://crbug.com/311341 |
2270 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \ | 2278 #define MAYBE_HttpStatusCodeErrorWithEmptyBody \ |
2271 DISABLED_HttpStatusCodeErrorWithEmptyBody | 2279 DISABLED_HttpStatusCodeErrorWithEmptyBody |
2272 #else | 2280 #else |
2273 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody | 2281 #define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody |
2274 #endif | 2282 #endif |
2275 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { | 2283 TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) { |
(...skipping 12 matching lines...) Expand all Loading... |
2288 RequestNavigationParams()); | 2296 RequestNavigationParams()); |
2289 | 2297 |
2290 // Emulate a 4xx/5xx main resource response with an empty body. | 2298 // Emulate a 4xx/5xx main resource response with an empty body. |
2291 main_frame->didReceiveResponse(web_frame, 1, response); | 2299 main_frame->didReceiveResponse(web_frame, 1, response); |
2292 main_frame->didFinishDocumentLoad(web_frame, true); | 2300 main_frame->didFinishDocumentLoad(web_frame, true); |
2293 | 2301 |
2294 // The error page itself is loaded asynchronously. | 2302 // The error page itself is loaded asynchronously. |
2295 FrameLoadWaiter(main_frame).Wait(); | 2303 FrameLoadWaiter(main_frame).Wait(); |
2296 const int kMaxOutputCharacters = 22; | 2304 const int kMaxOutputCharacters = 22; |
2297 EXPECT_EQ("A suffusion of yellow.", | 2305 EXPECT_EQ("A suffusion of yellow.", |
2298 base::UTF16ToASCII(base::StringPiece16( | 2306 base::UTF16ToASCII( |
2299 web_frame->contentAsText(kMaxOutputCharacters)))); | 2307 base::StringPiece16(WebFrameContentDumper::dumpFrameTreeAsText( |
| 2308 web_frame, kMaxOutputCharacters)))); |
2300 } | 2309 } |
2301 | 2310 |
2302 // Ensure the render view sends favicon url update events correctly. | 2311 // Ensure the render view sends favicon url update events correctly. |
2303 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { | 2312 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { |
2304 // An event should be sent when a favicon url exists. | 2313 // An event should be sent when a favicon url exists. |
2305 LoadHTML("<html>" | 2314 LoadHTML("<html>" |
2306 "<head>" | 2315 "<head>" |
2307 "<link rel='icon' href='http://www.google.com/favicon.ico'>" | 2316 "<link rel='icon' href='http://www.google.com/favicon.ico'>" |
2308 "</head>" | 2317 "</head>" |
2309 "</html>"); | 2318 "</html>"); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 FROM_HERE, | 2754 FROM_HERE, |
2746 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2755 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2747 ExecuteJavaScriptForTests("debugger;"); | 2756 ExecuteJavaScriptForTests("debugger;"); |
2748 | 2757 |
2749 // CloseWhilePaused should resume execution and continue here. | 2758 // CloseWhilePaused should resume execution and continue here. |
2750 EXPECT_FALSE(IsPaused()); | 2759 EXPECT_FALSE(IsPaused()); |
2751 Detach(); | 2760 Detach(); |
2752 } | 2761 } |
2753 | 2762 |
2754 } // namespace content | 2763 } // namespace content |
OLD | NEW |