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

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

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android Created 5 years, 5 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 "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/location.h" 8 #include "base/location.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); 421 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>");
422 422
423 // We should NOT have gotten a form state change notification yet. 423 // We should NOT have gotten a form state change notification yet.
424 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 424 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
425 ViewHostMsg_UpdateState::ID)); 425 ViewHostMsg_UpdateState::ID));
426 render_thread_->sink().ClearMessages(); 426 render_thread_->sink().ClearMessages();
427 427
428 // Change the value of the input. We should have gotten an update state 428 // Change the value of the input. We should have gotten an update state
429 // notification. We need to spin the message loop to catch this update. 429 // notification. We need to spin the message loop to catch this update.
430 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); 430 ExecuteJavaScriptForTests(
431 "document.getElementById('elt_text').value = 'foo';");
431 ProcessPendingMessages(); 432 ProcessPendingMessages();
432 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( 433 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
433 ViewHostMsg_UpdateState::ID)); 434 ViewHostMsg_UpdateState::ID));
434 } 435 }
435 436
436 TEST_F(RenderViewImplTest, OnNavigationHttpPost) { 437 TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
437 // An http url will trigger a resource load so cannot be used here. 438 // An http url will trigger a resource load so cannot be used here.
438 CommonNavigationParams common_params; 439 CommonNavigationParams common_params;
439 StartNavigationParams start_params; 440 StartNavigationParams start_params;
440 RequestNavigationParams request_params; 441 RequestNavigationParams request_params;
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 {"test12", ui::TEXT_INPUT_MODE_EMAIL}, 960 {"test12", ui::TEXT_INPUT_MODE_EMAIL},
960 {"test13", ui::TEXT_INPUT_MODE_URL}, 961 {"test13", ui::TEXT_INPUT_MODE_URL},
961 {"test14", ui::TEXT_INPUT_MODE_DEFAULT}, 962 {"test14", ui::TEXT_INPUT_MODE_DEFAULT},
962 {"test15", ui::TEXT_INPUT_MODE_VERBATIM}, 963 {"test15", ui::TEXT_INPUT_MODE_VERBATIM},
963 }; 964 };
964 965
965 const int kRepeatCount = 10; 966 const int kRepeatCount = 10;
966 for (int i = 0; i < kRepeatCount; i++) { 967 for (int i = 0; i < kRepeatCount; i++) {
967 // Move the input focus to the first <input> element, where we should 968 // Move the input focus to the first <input> element, where we should
968 // activate IMEs. 969 // activate IMEs.
969 ExecuteJavaScript("document.getElementById('test1').focus();"); 970 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
970 ProcessPendingMessages(); 971 ProcessPendingMessages();
971 render_thread_->sink().ClearMessages(); 972 render_thread_->sink().ClearMessages();
972 973
973 // Update the IME status and verify if our IME backend sends an IPC message 974 // Update the IME status and verify if our IME backend sends an IPC message
974 // to activate IMEs. 975 // to activate IMEs.
975 view()->UpdateTextInputType(); 976 view()->UpdateTextInputType();
976 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); 977 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
977 EXPECT_TRUE(msg != NULL); 978 EXPECT_TRUE(msg != NULL);
978 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); 979 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type());
979 ViewHostMsg_TextInputTypeChanged::Param params; 980 ViewHostMsg_TextInputTypeChanged::Param params;
980 ViewHostMsg_TextInputTypeChanged::Read(msg, &params); 981 ViewHostMsg_TextInputTypeChanged::Read(msg, &params);
981 ui::TextInputType type = base::get<0>(params); 982 ui::TextInputType type = base::get<0>(params);
982 ui::TextInputMode input_mode = base::get<1>(params); 983 ui::TextInputMode input_mode = base::get<1>(params);
983 bool can_compose_inline = base::get<2>(params); 984 bool can_compose_inline = base::get<2>(params);
984 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); 985 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type);
985 EXPECT_EQ(true, can_compose_inline); 986 EXPECT_EQ(true, can_compose_inline);
986 987
987 // Move the input focus to the second <input> element, where we should 988 // Move the input focus to the second <input> element, where we should
988 // de-activate IMEs. 989 // de-activate IMEs.
989 ExecuteJavaScript("document.getElementById('test2').focus();"); 990 ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
990 ProcessPendingMessages(); 991 ProcessPendingMessages();
991 render_thread_->sink().ClearMessages(); 992 render_thread_->sink().ClearMessages();
992 993
993 // Update the IME status and verify if our IME backend sends an IPC message 994 // Update the IME status and verify if our IME backend sends an IPC message
994 // to de-activate IMEs. 995 // to de-activate IMEs.
995 view()->UpdateTextInputType(); 996 view()->UpdateTextInputType();
996 msg = render_thread_->sink().GetMessageAt(0); 997 msg = render_thread_->sink().GetMessageAt(0);
997 EXPECT_TRUE(msg != NULL); 998 EXPECT_TRUE(msg != NULL);
998 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); 999 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type());
999 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); 1000 ViewHostMsg_TextInputTypeChanged::Read(msg, & params);
(...skipping 29 matching lines...) Expand all
1029 // Test that our IME backend can compose CJK words. 1030 // Test that our IME backend can compose CJK words.
1030 // Our IME front-end sends many platform-independent messages to the IME backend 1031 // Our IME front-end sends many platform-independent messages to the IME backend
1031 // while it composes CJK words. This test sends the minimal messages captured 1032 // while it composes CJK words. This test sends the minimal messages captured
1032 // on my local environment directly to the IME backend to verify if the backend 1033 // on my local environment directly to the IME backend to verify if the backend
1033 // can compose CJK words without any problems. 1034 // can compose CJK words without any problems.
1034 // This test uses an array of command sets because an IME composotion does not 1035 // This test uses an array of command sets because an IME composotion does not
1035 // only depends on IME events, but also depends on window events, e.g. moving 1036 // only depends on IME events, but also depends on window events, e.g. moving
1036 // the window focus while composing a CJK text. To handle such complicated 1037 // the window focus while composing a CJK text. To handle such complicated
1037 // cases, this test should not only call IME-related functions in the 1038 // cases, this test should not only call IME-related functions in the
1038 // RenderWidget class, but also call some RenderWidget members, e.g. 1039 // RenderWidget class, but also call some RenderWidget members, e.g.
1039 // ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc. 1040 // ExecuteJavaScriptForTests(), RenderWidget::OnSetFocus(), etc.
1040 TEST_F(RenderViewImplTest, ImeComposition) { 1041 TEST_F(RenderViewImplTest, ImeComposition) {
1041 enum ImeCommand { 1042 enum ImeCommand {
1042 IME_INITIALIZE, 1043 IME_INITIALIZE,
1043 IME_SETINPUTMODE, 1044 IME_SETINPUTMODE,
1044 IME_SETFOCUS, 1045 IME_SETFOCUS,
1045 IME_SETCOMPOSITION, 1046 IME_SETCOMPOSITION,
1046 IME_CONFIRMCOMPOSITION, 1047 IME_CONFIRMCOMPOSITION,
1047 IME_CANCELCOMPOSITION 1048 IME_CANCELCOMPOSITION
1048 }; 1049 };
1049 struct ImeMessage { 1050 struct ImeMessage {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 // IMEs. 1106 // IMEs.
1106 view()->OnSetInputMethodActive(ime_message->enable); 1107 view()->OnSetInputMethodActive(ime_message->enable);
1107 view()->set_send_content_state_immediately(true); 1108 view()->set_send_content_state_immediately(true);
1108 LoadHTML("<html>" 1109 LoadHTML("<html>"
1109 "<head>" 1110 "<head>"
1110 "</head>" 1111 "</head>"
1111 "<body>" 1112 "<body>"
1112 "<div id=\"test1\" contenteditable=\"true\"></div>" 1113 "<div id=\"test1\" contenteditable=\"true\"></div>"
1113 "</body>" 1114 "</body>"
1114 "</html>"); 1115 "</html>");
1115 ExecuteJavaScript("document.getElementById('test1').focus();"); 1116 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1116 break; 1117 break;
1117 1118
1118 case IME_SETINPUTMODE: 1119 case IME_SETINPUTMODE:
1119 // Activate (or deactivate) our IME back-end. 1120 // Activate (or deactivate) our IME back-end.
1120 view()->OnSetInputMethodActive(ime_message->enable); 1121 view()->OnSetInputMethodActive(ime_message->enable);
1121 break; 1122 break;
1122 1123
1123 case IME_SETFOCUS: 1124 case IME_SETFOCUS:
1124 // Update the window focus. 1125 // Update the window focus.
1125 view()->OnSetFocus(ime_message->enable); 1126 view()->OnSetFocus(ime_message->enable);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 1186
1186 static const struct { 1187 static const struct {
1187 WebTextDirection direction; 1188 WebTextDirection direction;
1188 const wchar_t* expected_result; 1189 const wchar_t* expected_result;
1189 } kTextDirection[] = { 1190 } kTextDirection[] = {
1190 { blink::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, 1191 { blink::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" },
1191 { blink::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, 1192 { blink::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" },
1192 }; 1193 };
1193 for (size_t i = 0; i < arraysize(kTextDirection); ++i) { 1194 for (size_t i = 0; i < arraysize(kTextDirection); ++i) {
1194 // Set the text direction of the <textarea> element. 1195 // Set the text direction of the <textarea> element.
1195 ExecuteJavaScript("document.getElementById('test').focus();"); 1196 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1196 view()->OnSetTextDirection(kTextDirection[i].direction); 1197 view()->OnSetTextDirection(kTextDirection[i].direction);
1197 1198
1198 // Write the values of its DOM 'dir' attribute and its CSS 'direction' 1199 // Write the values of its DOM 'dir' attribute and its CSS 'direction'
1199 // property to the <div> element. 1200 // property to the <div> element.
1200 ExecuteJavaScript("var result = document.getElementById('result');" 1201 ExecuteJavaScriptForTests(
1201 "var node = document.getElementById('test');" 1202 "var result = document.getElementById('result');"
1202 "var style = getComputedStyle(node, null);" 1203 "var node = document.getElementById('test');"
1203 "result.innerText =" 1204 "var style = getComputedStyle(node, null);"
1204 " node.getAttribute('dir') + ',' +" 1205 "result.innerText ="
1205 " style.getPropertyValue('direction');"); 1206 " node.getAttribute('dir') + ',' +"
1207 " style.getPropertyValue('direction');");
1206 1208
1207 // Copy the document content to std::wstring and compare with the 1209 // Copy the document content to std::wstring and compare with the
1208 // expected result. 1210 // expected result.
1209 const int kMaxOutputCharacters = 16; 1211 const int kMaxOutputCharacters = 16;
1210 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); 1212 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
1211 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); 1213 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output);
1212 } 1214 }
1213 } 1215 }
1214 1216
1215 // Test that we can receive correct DOM events when we send input events 1217 // Test that we can receive correct DOM events when we send input events
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 " onkeyup='return OnKeyEvent(event);'>" 1249 " onkeyup='return OnKeyEvent(event);'>"
1248 "</input>" 1250 "</input>"
1249 "<div id='keydown' contenteditable='true'>" 1251 "<div id='keydown' contenteditable='true'>"
1250 "</div>" 1252 "</div>"
1251 "<div id='keypress' contenteditable='true'>" 1253 "<div id='keypress' contenteditable='true'>"
1252 "</div>" 1254 "</div>"
1253 "<div id='keyup' contenteditable='true'>" 1255 "<div id='keyup' contenteditable='true'>"
1254 "</div>" 1256 "</div>"
1255 "</body>" 1257 "</body>"
1256 "</html>"); 1258 "</html>");
1257 ExecuteJavaScript("document.getElementById('test').focus();"); 1259 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1258 render_thread_->sink().ClearMessages(); 1260 render_thread_->sink().ClearMessages();
1259 1261
1260 static const MockKeyboard::Layout kLayouts[] = { 1262 static const MockKeyboard::Layout kLayouts[] = {
1261 #if defined(OS_WIN) 1263 #if defined(OS_WIN)
1262 // Since we ignore the mock keyboard layout on Linux and instead just use 1264 // Since we ignore the mock keyboard layout on Linux and instead just use
1263 // the screen's keyboard layout, these trivially pass. They are commented 1265 // the screen's keyboard layout, these trivially pass. They are commented
1264 // out to avoid the illusion that they work. 1266 // out to avoid the illusion that they work.
1265 MockKeyboard::LAYOUT_ARABIC, 1267 MockKeyboard::LAYOUT_ARABIC,
1266 MockKeyboard::LAYOUT_CANADIAN_FRENCH, 1268 MockKeyboard::LAYOUT_CANADIAN_FRENCH,
1267 MockKeyboard::LAYOUT_FRENCH, 1269 MockKeyboard::LAYOUT_FRENCH,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 view()->set_send_content_state_immediately(true); 1516 view()->set_send_content_state_immediately(true);
1515 LoadHTML("<html>" 1517 LoadHTML("<html>"
1516 "<head>" 1518 "<head>"
1517 "<title></title>" 1519 "<title></title>"
1518 "</head>" 1520 "</head>"
1519 "<body>" 1521 "<body>"
1520 "<div id='test' contenteditable='true'>" 1522 "<div id='test' contenteditable='true'>"
1521 "</div>" 1523 "</div>"
1522 "</body>" 1524 "</body>"
1523 "</html>"); 1525 "</html>");
1524 ExecuteJavaScript("document.getElementById('test').focus();"); 1526 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1525 render_thread_->sink().ClearMessages(); 1527 render_thread_->sink().ClearMessages();
1526 1528
1527 // For each key code, we send three keyboard events. 1529 // For each key code, we send three keyboard events.
1528 // * Pressing only the key; 1530 // * Pressing only the key;
1529 // * Pressing the key and a left-shift key, and; 1531 // * Pressing the key and a left-shift key, and;
1530 // * Pressing the key and a right-alt (AltGr) key. 1532 // * Pressing the key and a right-alt (AltGr) key.
1531 static const MockKeyboard::Modifiers kModifiers[] = { 1533 static const MockKeyboard::Modifiers kModifiers[] = {
1532 MockKeyboard::NONE, 1534 MockKeyboard::NONE,
1533 MockKeyboard::LEFT_SHIFT, 1535 MockKeyboard::LEFT_SHIFT,
1534 #if defined(OS_WIN) 1536 #if defined(OS_WIN)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 #if defined(OS_MACOSX) || defined(USE_AURA) 1739 #if defined(OS_MACOSX) || defined(USE_AURA)
1738 TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) { 1740 TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
1739 1741
1740 #if defined(OS_WIN) 1742 #if defined(OS_WIN)
1741 // http://crbug.com/304193 1743 // http://crbug.com/304193
1742 if (base::win::GetVersion() < base::win::VERSION_VISTA) 1744 if (base::win::GetVersion() < base::win::VERSION_VISTA)
1743 return; 1745 return;
1744 #endif 1746 #endif
1745 1747
1746 LoadHTML("<textarea id=\"test\"></textarea>"); 1748 LoadHTML("<textarea id=\"test\"></textarea>");
1747 ExecuteJavaScript("document.getElementById('test').focus();"); 1749 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1748 1750
1749 const base::string16 empty_string; 1751 const base::string16 empty_string;
1750 const std::vector<blink::WebCompositionUnderline> empty_underline; 1752 const std::vector<blink::WebCompositionUnderline> empty_underline;
1751 std::vector<gfx::Rect> bounds; 1753 std::vector<gfx::Rect> bounds;
1752 view()->OnSetFocus(true); 1754 view()->OnSetFocus(true);
1753 view()->OnSetInputMethodActive(true); 1755 view()->OnSetInputMethodActive(true);
1754 1756
1755 // ASCII composition 1757 // ASCII composition
1756 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); 1758 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo");
1757 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); 1759 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1842
1841 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { 1843 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) {
1842 // Load an HTML page consisting of an input field. 1844 // Load an HTML page consisting of an input field.
1843 LoadHTML("<html>" 1845 LoadHTML("<html>"
1844 "<head>" 1846 "<head>"
1845 "</head>" 1847 "</head>"
1846 "<body>" 1848 "<body>"
1847 "<input id=\"test1\" value=\"some test text hello\"></input>" 1849 "<input id=\"test1\" value=\"some test text hello\"></input>"
1848 "</body>" 1850 "</body>"
1849 "</html>"); 1851 "</html>");
1850 ExecuteJavaScript("document.getElementById('test1').focus();"); 1852 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1851 frame()->SetEditableSelectionOffsets(4, 8); 1853 frame()->SetEditableSelectionOffsets(4, 8);
1852 const std::vector<blink::WebCompositionUnderline> empty_underline; 1854 const std::vector<blink::WebCompositionUnderline> empty_underline;
1853 frame()->SetCompositionFromExistingText(7, 10, empty_underline); 1855 frame()->SetCompositionFromExistingText(7, 10, empty_underline);
1854 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1856 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1855 EXPECT_EQ(4, info.selectionStart); 1857 EXPECT_EQ(4, info.selectionStart);
1856 EXPECT_EQ(8, info.selectionEnd); 1858 EXPECT_EQ(8, info.selectionEnd);
1857 EXPECT_EQ(7, info.compositionStart); 1859 EXPECT_EQ(7, info.compositionStart);
1858 EXPECT_EQ(10, info.compositionEnd); 1860 EXPECT_EQ(10, info.compositionEnd);
1859 frame()->Unselect(); 1861 frame()->Unselect();
1860 info = view()->webview()->textInputInfo(); 1862 info = view()->webview()->textInputInfo();
1861 EXPECT_EQ(0, info.selectionStart); 1863 EXPECT_EQ(0, info.selectionStart);
1862 EXPECT_EQ(0, info.selectionEnd); 1864 EXPECT_EQ(0, info.selectionEnd);
1863 } 1865 }
1864 1866
1865 1867
1866 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { 1868 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
1867 // Load an HTML page consisting of an input field. 1869 // Load an HTML page consisting of an input field.
1868 LoadHTML("<html>" 1870 LoadHTML("<html>"
1869 "<head>" 1871 "<head>"
1870 "</head>" 1872 "</head>"
1871 "<body>" 1873 "<body>"
1872 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" 1874 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
1873 "</body>" 1875 "</body>"
1874 "</html>"); 1876 "</html>");
1875 ExecuteJavaScript("document.getElementById('test1').focus();"); 1877 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
1876 frame()->SetEditableSelectionOffsets(10, 10); 1878 frame()->SetEditableSelectionOffsets(10, 10);
1877 frame()->ExtendSelectionAndDelete(3, 4); 1879 frame()->ExtendSelectionAndDelete(3, 4);
1878 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); 1880 blink::WebTextInputInfo info = view()->webview()->textInputInfo();
1879 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); 1881 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
1880 EXPECT_EQ(7, info.selectionStart); 1882 EXPECT_EQ(7, info.selectionStart);
1881 EXPECT_EQ(7, info.selectionEnd); 1883 EXPECT_EQ(7, info.selectionEnd);
1882 frame()->SetEditableSelectionOffsets(4, 8); 1884 frame()->SetEditableSelectionOffsets(4, 8);
1883 frame()->ExtendSelectionAndDelete(2, 5); 1885 frame()->ExtendSelectionAndDelete(2, 5);
1884 info = view()->webview()->textInputInfo(); 1886 info = view()->webview()->textInputInfo();
1885 EXPECT_EQ("abuvwxyz", info.value); 1887 EXPECT_EQ("abuvwxyz", info.value);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 ssl_status = view()->GetSSLStatusOfFrame(frame); 1941 ssl_status = view()->GetSSLStatusOfFrame(frame);
1940 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); 1942 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status));
1941 } 1943 }
1942 1944
1943 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { 1945 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
1944 view()->OnSetInputMethodActive(true); 1946 view()->OnSetInputMethodActive(true);
1945 view()->set_send_content_state_immediately(true); 1947 view()->set_send_content_state_immediately(true);
1946 LoadHTML("<textarea id=\"test\"></textarea>"); 1948 LoadHTML("<textarea id=\"test\"></textarea>");
1947 1949
1948 view()->handling_input_event_ = true; 1950 view()->handling_input_event_ = true;
1949 ExecuteJavaScript("document.getElementById('test').focus();"); 1951 ExecuteJavaScriptForTests("document.getElementById('test').focus();");
1950 1952
1951 bool is_input_type_called = false; 1953 bool is_input_type_called = false;
1952 bool is_selection_called = false; 1954 bool is_selection_called = false;
1953 size_t last_input_type = 0; 1955 size_t last_input_type = 0;
1954 size_t last_selection = 0; 1956 size_t last_selection = 0;
1955 1957
1956 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 1958 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
1957 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); 1959 const uint32 type = render_thread_->sink().GetMessageAt(i)->type();
1958 if (type == ViewHostMsg_TextInputTypeChanged::ID) { 1960 if (type == ViewHostMsg_TextInputTypeChanged::ID) {
1959 is_input_type_called = true; 1961 is_input_type_called = true;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 "</head>" 2091 "</head>"
2090 "</html>"); 2092 "</html>");
2091 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 2093 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
2092 ViewHostMsg_UpdateFaviconURL::ID)); 2094 ViewHostMsg_UpdateFaviconURL::ID));
2093 } 2095 }
2094 2096
2095 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) { 2097 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) {
2096 LoadHTML("<input id='test1' value='hello1'></input>" 2098 LoadHTML("<input id='test1' value='hello1'></input>"
2097 "<input id='test2' value='hello2'></input>"); 2099 "<input id='test2' value='hello2'></input>");
2098 2100
2099 ExecuteJavaScript("document.getElementById('test1').focus();"); 2101 ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
2100 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 2102 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
2101 ViewHostMsg_FocusedNodeChanged::ID); 2103 ViewHostMsg_FocusedNodeChanged::ID);
2102 EXPECT_TRUE(msg1); 2104 EXPECT_TRUE(msg1);
2103 2105
2104 ViewHostMsg_FocusedNodeChanged::Param params; 2106 ViewHostMsg_FocusedNodeChanged::Param params;
2105 ViewHostMsg_FocusedNodeChanged::Read(msg1, &params); 2107 ViewHostMsg_FocusedNodeChanged::Read(msg1, &params);
2106 EXPECT_TRUE(base::get<0>(params)); 2108 EXPECT_TRUE(base::get<0>(params));
2107 render_thread_->sink().ClearMessages(); 2109 render_thread_->sink().ClearMessages();
2108 2110
2109 ExecuteJavaScript("document.getElementById('test2').focus();"); 2111 ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
2110 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( 2112 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
2111 ViewHostMsg_FocusedNodeChanged::ID); 2113 ViewHostMsg_FocusedNodeChanged::ID);
2112 EXPECT_TRUE(msg2); 2114 EXPECT_TRUE(msg2);
2113 ViewHostMsg_FocusedNodeChanged::Read(msg2, &params); 2115 ViewHostMsg_FocusedNodeChanged::Read(msg2, &params);
2114 EXPECT_TRUE(base::get<0>(params)); 2116 EXPECT_TRUE(base::get<0>(params));
2115 render_thread_->sink().ClearMessages(); 2117 render_thread_->sink().ClearMessages();
2116 2118
2117 view()->webview()->clearFocusedElement(); 2119 view()->webview()->clearFocusedElement();
2118 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( 2120 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
2119 ViewHostMsg_FocusedNodeChanged::ID); 2121 ViewHostMsg_FocusedNodeChanged::ID);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { 2316 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) {
2315 Attach(); 2317 Attach();
2316 EXPECT_FALSE(IsPaused()); 2318 EXPECT_FALSE(IsPaused());
2317 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); 2319 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}");
2318 2320
2319 // Executing javascript will pause the thread and create nested message loop. 2321 // Executing javascript will pause the thread and create nested message loop.
2320 // Posting task simulates message coming from browser. 2322 // Posting task simulates message coming from browser.
2321 base::ThreadTaskRunnerHandle::Get()->PostTask( 2323 base::ThreadTaskRunnerHandle::Get()->PostTask(
2322 FROM_HERE, 2324 FROM_HERE,
2323 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2325 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2324 ExecuteJavaScript("debugger;"); 2326 ExecuteJavaScriptForTests("debugger;");
2325 2327
2326 // CloseWhilePaused should resume execution and continue here. 2328 // CloseWhilePaused should resume execution and continue here.
2327 EXPECT_FALSE(IsPaused()); 2329 EXPECT_FALSE(IsPaused());
2328 Detach(); 2330 Detach();
2329 } 2331 }
2330 2332
2331 } // namespace content 2333 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698