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 "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 Loading... |
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 {"test12", ui::TEXT_INPUT_MODE_EMAIL}, | 957 {"test12", ui::TEXT_INPUT_MODE_EMAIL}, |
957 {"test13", ui::TEXT_INPUT_MODE_URL}, | 958 {"test13", ui::TEXT_INPUT_MODE_URL}, |
958 {"test14", ui::TEXT_INPUT_MODE_DEFAULT}, | 959 {"test14", ui::TEXT_INPUT_MODE_DEFAULT}, |
959 {"test15", ui::TEXT_INPUT_MODE_VERBATIM}, | 960 {"test15", ui::TEXT_INPUT_MODE_VERBATIM}, |
960 }; | 961 }; |
961 | 962 |
962 const int kRepeatCount = 10; | 963 const int kRepeatCount = 10; |
963 for (int i = 0; i < kRepeatCount; i++) { | 964 for (int i = 0; i < kRepeatCount; i++) { |
964 // Move the input focus to the first <input> element, where we should | 965 // Move the input focus to the first <input> element, where we should |
965 // activate IMEs. | 966 // activate IMEs. |
966 ExecuteJavaScript("document.getElementById('test1').focus();"); | 967 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
967 ProcessPendingMessages(); | 968 ProcessPendingMessages(); |
968 render_thread_->sink().ClearMessages(); | 969 render_thread_->sink().ClearMessages(); |
969 | 970 |
970 // Update the IME status and verify if our IME backend sends an IPC message | 971 // Update the IME status and verify if our IME backend sends an IPC message |
971 // to activate IMEs. | 972 // to activate IMEs. |
972 view()->UpdateTextInputType(); | 973 view()->UpdateTextInputType(); |
973 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 974 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
974 EXPECT_TRUE(msg != NULL); | 975 EXPECT_TRUE(msg != NULL); |
975 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 976 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); |
976 ViewHostMsg_TextInputTypeChanged::Param params; | 977 ViewHostMsg_TextInputTypeChanged::Param params; |
977 ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); | 978 ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); |
978 ui::TextInputType type = base::get<0>(params); | 979 ui::TextInputType type = base::get<0>(params); |
979 ui::TextInputMode input_mode = base::get<1>(params); | 980 ui::TextInputMode input_mode = base::get<1>(params); |
980 bool can_compose_inline = base::get<2>(params); | 981 bool can_compose_inline = base::get<2>(params); |
981 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); | 982 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); |
982 EXPECT_EQ(true, can_compose_inline); | 983 EXPECT_EQ(true, can_compose_inline); |
983 | 984 |
984 // Move the input focus to the second <input> element, where we should | 985 // Move the input focus to the second <input> element, where we should |
985 // de-activate IMEs. | 986 // de-activate IMEs. |
986 ExecuteJavaScript("document.getElementById('test2').focus();"); | 987 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); |
987 ProcessPendingMessages(); | 988 ProcessPendingMessages(); |
988 render_thread_->sink().ClearMessages(); | 989 render_thread_->sink().ClearMessages(); |
989 | 990 |
990 // Update the IME status and verify if our IME backend sends an IPC message | 991 // Update the IME status and verify if our IME backend sends an IPC message |
991 // to de-activate IMEs. | 992 // to de-activate IMEs. |
992 view()->UpdateTextInputType(); | 993 view()->UpdateTextInputType(); |
993 msg = render_thread_->sink().GetMessageAt(0); | 994 msg = render_thread_->sink().GetMessageAt(0); |
994 EXPECT_TRUE(msg != NULL); | 995 EXPECT_TRUE(msg != NULL); |
995 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 996 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); |
996 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); | 997 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); |
(...skipping 29 matching lines...) Expand all Loading... |
1026 // Test that our IME backend can compose CJK words. | 1027 // Test that our IME backend can compose CJK words. |
1027 // Our IME front-end sends many platform-independent messages to the IME backend | 1028 // Our IME front-end sends many platform-independent messages to the IME backend |
1028 // while it composes CJK words. This test sends the minimal messages captured | 1029 // while it composes CJK words. This test sends the minimal messages captured |
1029 // on my local environment directly to the IME backend to verify if the backend | 1030 // on my local environment directly to the IME backend to verify if the backend |
1030 // can compose CJK words without any problems. | 1031 // can compose CJK words without any problems. |
1031 // This test uses an array of command sets because an IME composotion does not | 1032 // This test uses an array of command sets because an IME composotion does not |
1032 // only depends on IME events, but also depends on window events, e.g. moving | 1033 // only depends on IME events, but also depends on window events, e.g. moving |
1033 // the window focus while composing a CJK text. To handle such complicated | 1034 // the window focus while composing a CJK text. To handle such complicated |
1034 // cases, this test should not only call IME-related functions in the | 1035 // cases, this test should not only call IME-related functions in the |
1035 // RenderWidget class, but also call some RenderWidget members, e.g. | 1036 // RenderWidget class, but also call some RenderWidget members, e.g. |
1036 // ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc. | 1037 // ExecuteJavaScriptForTests(), RenderWidget::OnSetFocus(), etc. |
1037 TEST_F(RenderViewImplTest, ImeComposition) { | 1038 TEST_F(RenderViewImplTest, ImeComposition) { |
1038 enum ImeCommand { | 1039 enum ImeCommand { |
1039 IME_INITIALIZE, | 1040 IME_INITIALIZE, |
1040 IME_SETINPUTMODE, | 1041 IME_SETINPUTMODE, |
1041 IME_SETFOCUS, | 1042 IME_SETFOCUS, |
1042 IME_SETCOMPOSITION, | 1043 IME_SETCOMPOSITION, |
1043 IME_CONFIRMCOMPOSITION, | 1044 IME_CONFIRMCOMPOSITION, |
1044 IME_CANCELCOMPOSITION | 1045 IME_CANCELCOMPOSITION |
1045 }; | 1046 }; |
1046 struct ImeMessage { | 1047 struct ImeMessage { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 // and move the input focus to the <div> element, where we can use | 1102 // and move the input focus to the <div> element, where we can use |
1102 // IMEs. | 1103 // IMEs. |
1103 view()->set_send_content_state_immediately(true); | 1104 view()->set_send_content_state_immediately(true); |
1104 LoadHTML("<html>" | 1105 LoadHTML("<html>" |
1105 "<head>" | 1106 "<head>" |
1106 "</head>" | 1107 "</head>" |
1107 "<body>" | 1108 "<body>" |
1108 "<div id=\"test1\" contenteditable=\"true\"></div>" | 1109 "<div id=\"test1\" contenteditable=\"true\"></div>" |
1109 "</body>" | 1110 "</body>" |
1110 "</html>"); | 1111 "</html>"); |
1111 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1112 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1112 break; | 1113 break; |
1113 | 1114 |
1114 case IME_SETINPUTMODE: | 1115 case IME_SETINPUTMODE: |
1115 break; | 1116 break; |
1116 | 1117 |
1117 case IME_SETFOCUS: | 1118 case IME_SETFOCUS: |
1118 // Update the window focus. | 1119 // Update the window focus. |
1119 view()->OnSetFocus(ime_message->enable); | 1120 view()->OnSetFocus(ime_message->enable); |
1120 break; | 1121 break; |
1121 | 1122 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 | 1180 |
1180 static const struct { | 1181 static const struct { |
1181 WebTextDirection direction; | 1182 WebTextDirection direction; |
1182 const wchar_t* expected_result; | 1183 const wchar_t* expected_result; |
1183 } kTextDirection[] = { | 1184 } kTextDirection[] = { |
1184 { blink::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, | 1185 { blink::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, |
1185 { blink::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, | 1186 { blink::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, |
1186 }; | 1187 }; |
1187 for (size_t i = 0; i < arraysize(kTextDirection); ++i) { | 1188 for (size_t i = 0; i < arraysize(kTextDirection); ++i) { |
1188 // Set the text direction of the <textarea> element. | 1189 // Set the text direction of the <textarea> element. |
1189 ExecuteJavaScript("document.getElementById('test').focus();"); | 1190 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
1190 view()->OnSetTextDirection(kTextDirection[i].direction); | 1191 view()->OnSetTextDirection(kTextDirection[i].direction); |
1191 | 1192 |
1192 // Write the values of its DOM 'dir' attribute and its CSS 'direction' | 1193 // Write the values of its DOM 'dir' attribute and its CSS 'direction' |
1193 // property to the <div> element. | 1194 // property to the <div> element. |
1194 ExecuteJavaScript("var result = document.getElementById('result');" | 1195 ExecuteJavaScriptForTests( |
1195 "var node = document.getElementById('test');" | 1196 "var result = document.getElementById('result');" |
1196 "var style = getComputedStyle(node, null);" | 1197 "var node = document.getElementById('test');" |
1197 "result.innerText =" | 1198 "var style = getComputedStyle(node, null);" |
1198 " node.getAttribute('dir') + ',' +" | 1199 "result.innerText =" |
1199 " style.getPropertyValue('direction');"); | 1200 " node.getAttribute('dir') + ',' +" |
| 1201 " style.getPropertyValue('direction');"); |
1200 | 1202 |
1201 // Copy the document content to std::wstring and compare with the | 1203 // Copy the document content to std::wstring and compare with the |
1202 // expected result. | 1204 // expected result. |
1203 const int kMaxOutputCharacters = 16; | 1205 const int kMaxOutputCharacters = 16; |
1204 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 1206 base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); |
1205 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); | 1207 EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output); |
1206 } | 1208 } |
1207 } | 1209 } |
1208 | 1210 |
1209 // Test that we can receive correct DOM events when we send input events | 1211 // 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 Loading... |
1241 " onkeyup='return OnKeyEvent(event);'>" | 1243 " onkeyup='return OnKeyEvent(event);'>" |
1242 "</input>" | 1244 "</input>" |
1243 "<div id='keydown' contenteditable='true'>" | 1245 "<div id='keydown' contenteditable='true'>" |
1244 "</div>" | 1246 "</div>" |
1245 "<div id='keypress' contenteditable='true'>" | 1247 "<div id='keypress' contenteditable='true'>" |
1246 "</div>" | 1248 "</div>" |
1247 "<div id='keyup' contenteditable='true'>" | 1249 "<div id='keyup' contenteditable='true'>" |
1248 "</div>" | 1250 "</div>" |
1249 "</body>" | 1251 "</body>" |
1250 "</html>"); | 1252 "</html>"); |
1251 ExecuteJavaScript("document.getElementById('test').focus();"); | 1253 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
1252 render_thread_->sink().ClearMessages(); | 1254 render_thread_->sink().ClearMessages(); |
1253 | 1255 |
1254 static const MockKeyboard::Layout kLayouts[] = { | 1256 static const MockKeyboard::Layout kLayouts[] = { |
1255 #if defined(OS_WIN) | 1257 #if defined(OS_WIN) |
1256 // Since we ignore the mock keyboard layout on Linux and instead just use | 1258 // Since we ignore the mock keyboard layout on Linux and instead just use |
1257 // the screen's keyboard layout, these trivially pass. They are commented | 1259 // the screen's keyboard layout, these trivially pass. They are commented |
1258 // out to avoid the illusion that they work. | 1260 // out to avoid the illusion that they work. |
1259 MockKeyboard::LAYOUT_ARABIC, | 1261 MockKeyboard::LAYOUT_ARABIC, |
1260 MockKeyboard::LAYOUT_CANADIAN_FRENCH, | 1262 MockKeyboard::LAYOUT_CANADIAN_FRENCH, |
1261 MockKeyboard::LAYOUT_FRENCH, | 1263 MockKeyboard::LAYOUT_FRENCH, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 view()->set_send_content_state_immediately(true); | 1510 view()->set_send_content_state_immediately(true); |
1509 LoadHTML("<html>" | 1511 LoadHTML("<html>" |
1510 "<head>" | 1512 "<head>" |
1511 "<title></title>" | 1513 "<title></title>" |
1512 "</head>" | 1514 "</head>" |
1513 "<body>" | 1515 "<body>" |
1514 "<div id='test' contenteditable='true'>" | 1516 "<div id='test' contenteditable='true'>" |
1515 "</div>" | 1517 "</div>" |
1516 "</body>" | 1518 "</body>" |
1517 "</html>"); | 1519 "</html>"); |
1518 ExecuteJavaScript("document.getElementById('test').focus();"); | 1520 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
1519 render_thread_->sink().ClearMessages(); | 1521 render_thread_->sink().ClearMessages(); |
1520 | 1522 |
1521 // For each key code, we send three keyboard events. | 1523 // For each key code, we send three keyboard events. |
1522 // * Pressing only the key; | 1524 // * Pressing only the key; |
1523 // * Pressing the key and a left-shift key, and; | 1525 // * Pressing the key and a left-shift key, and; |
1524 // * Pressing the key and a right-alt (AltGr) key. | 1526 // * Pressing the key and a right-alt (AltGr) key. |
1525 static const MockKeyboard::Modifiers kModifiers[] = { | 1527 static const MockKeyboard::Modifiers kModifiers[] = { |
1526 MockKeyboard::NONE, | 1528 MockKeyboard::NONE, |
1527 MockKeyboard::LEFT_SHIFT, | 1529 MockKeyboard::LEFT_SHIFT, |
1528 #if defined(OS_WIN) | 1530 #if defined(OS_WIN) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 #if defined(OS_WIN) | 1736 #if defined(OS_WIN) |
1735 // http://crbug.com/304193 | 1737 // http://crbug.com/304193 |
1736 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 1738 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
1737 return; | 1739 return; |
1738 // http://crbug.com/508747 | 1740 // http://crbug.com/508747 |
1739 if (base::win::GetVersion() >= base::win::VERSION_WIN10) | 1741 if (base::win::GetVersion() >= base::win::VERSION_WIN10) |
1740 return; | 1742 return; |
1741 #endif | 1743 #endif |
1742 | 1744 |
1743 LoadHTML("<textarea id=\"test\"></textarea>"); | 1745 LoadHTML("<textarea id=\"test\"></textarea>"); |
1744 ExecuteJavaScript("document.getElementById('test').focus();"); | 1746 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
1745 | 1747 |
1746 const base::string16 empty_string; | 1748 const base::string16 empty_string; |
1747 const std::vector<blink::WebCompositionUnderline> empty_underline; | 1749 const std::vector<blink::WebCompositionUnderline> empty_underline; |
1748 std::vector<gfx::Rect> bounds; | 1750 std::vector<gfx::Rect> bounds; |
1749 view()->OnSetFocus(true); | 1751 view()->OnSetFocus(true); |
1750 | 1752 |
1751 // ASCII composition | 1753 // ASCII composition |
1752 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); | 1754 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); |
1753 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); | 1755 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); |
1754 view()->GetCompositionCharacterBounds(&bounds); | 1756 view()->GetCompositionCharacterBounds(&bounds); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 | 1838 |
1837 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { | 1839 TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) { |
1838 // Load an HTML page consisting of an input field. | 1840 // Load an HTML page consisting of an input field. |
1839 LoadHTML("<html>" | 1841 LoadHTML("<html>" |
1840 "<head>" | 1842 "<head>" |
1841 "</head>" | 1843 "</head>" |
1842 "<body>" | 1844 "<body>" |
1843 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1845 "<input id=\"test1\" value=\"some test text hello\"></input>" |
1844 "</body>" | 1846 "</body>" |
1845 "</html>"); | 1847 "</html>"); |
1846 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1848 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1847 frame()->SetEditableSelectionOffsets(4, 8); | 1849 frame()->SetEditableSelectionOffsets(4, 8); |
1848 const std::vector<blink::WebCompositionUnderline> empty_underline; | 1850 const std::vector<blink::WebCompositionUnderline> empty_underline; |
1849 frame()->SetCompositionFromExistingText(7, 10, empty_underline); | 1851 frame()->SetCompositionFromExistingText(7, 10, empty_underline); |
1850 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1852 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1851 EXPECT_EQ(4, info.selectionStart); | 1853 EXPECT_EQ(4, info.selectionStart); |
1852 EXPECT_EQ(8, info.selectionEnd); | 1854 EXPECT_EQ(8, info.selectionEnd); |
1853 EXPECT_EQ(7, info.compositionStart); | 1855 EXPECT_EQ(7, info.compositionStart); |
1854 EXPECT_EQ(10, info.compositionEnd); | 1856 EXPECT_EQ(10, info.compositionEnd); |
1855 frame()->Unselect(); | 1857 frame()->Unselect(); |
1856 info = view()->webview()->textInputInfo(); | 1858 info = view()->webview()->textInputInfo(); |
1857 EXPECT_EQ(0, info.selectionStart); | 1859 EXPECT_EQ(0, info.selectionStart); |
1858 EXPECT_EQ(0, info.selectionEnd); | 1860 EXPECT_EQ(0, info.selectionEnd); |
1859 } | 1861 } |
1860 | 1862 |
1861 | 1863 |
1862 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | 1864 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
1863 // Load an HTML page consisting of an input field. | 1865 // Load an HTML page consisting of an input field. |
1864 LoadHTML("<html>" | 1866 LoadHTML("<html>" |
1865 "<head>" | 1867 "<head>" |
1866 "</head>" | 1868 "</head>" |
1867 "<body>" | 1869 "<body>" |
1868 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1870 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1869 "</body>" | 1871 "</body>" |
1870 "</html>"); | 1872 "</html>"); |
1871 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1873 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
1872 frame()->SetEditableSelectionOffsets(10, 10); | 1874 frame()->SetEditableSelectionOffsets(10, 10); |
1873 frame()->ExtendSelectionAndDelete(3, 4); | 1875 frame()->ExtendSelectionAndDelete(3, 4); |
1874 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1876 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1875 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1877 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1876 EXPECT_EQ(7, info.selectionStart); | 1878 EXPECT_EQ(7, info.selectionStart); |
1877 EXPECT_EQ(7, info.selectionEnd); | 1879 EXPECT_EQ(7, info.selectionEnd); |
1878 frame()->SetEditableSelectionOffsets(4, 8); | 1880 frame()->SetEditableSelectionOffsets(4, 8); |
1879 frame()->ExtendSelectionAndDelete(2, 5); | 1881 frame()->ExtendSelectionAndDelete(2, 5); |
1880 info = view()->webview()->textInputInfo(); | 1882 info = view()->webview()->textInputInfo(); |
1881 EXPECT_EQ("abuvwxyz", info.value); | 1883 EXPECT_EQ("abuvwxyz", info.value); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 SignedCertificateTimestampIDStatusList())); | 1936 SignedCertificateTimestampIDStatusList())); |
1935 ssl_status = view()->GetSSLStatusOfFrame(frame); | 1937 ssl_status = view()->GetSSLStatusOfFrame(frame); |
1936 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); | 1938 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); |
1937 } | 1939 } |
1938 | 1940 |
1939 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { | 1941 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { |
1940 view()->set_send_content_state_immediately(true); | 1942 view()->set_send_content_state_immediately(true); |
1941 LoadHTML("<textarea id=\"test\"></textarea>"); | 1943 LoadHTML("<textarea id=\"test\"></textarea>"); |
1942 | 1944 |
1943 view()->handling_input_event_ = true; | 1945 view()->handling_input_event_ = true; |
1944 ExecuteJavaScript("document.getElementById('test').focus();"); | 1946 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
1945 | 1947 |
1946 bool is_input_type_called = false; | 1948 bool is_input_type_called = false; |
1947 bool is_selection_called = false; | 1949 bool is_selection_called = false; |
1948 size_t last_input_type = 0; | 1950 size_t last_input_type = 0; |
1949 size_t last_selection = 0; | 1951 size_t last_selection = 0; |
1950 | 1952 |
1951 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { | 1953 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { |
1952 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); | 1954 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); |
1953 if (type == ViewHostMsg_TextInputTypeChanged::ID) { | 1955 if (type == ViewHostMsg_TextInputTypeChanged::ID) { |
1954 is_input_type_called = true; | 1956 is_input_type_called = true; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 "</head>" | 2124 "</head>" |
2123 "</html>"); | 2125 "</html>"); |
2124 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 2126 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
2125 ViewHostMsg_UpdateFaviconURL::ID)); | 2127 ViewHostMsg_UpdateFaviconURL::ID)); |
2126 } | 2128 } |
2127 | 2129 |
2128 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) { | 2130 TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) { |
2129 LoadHTML("<input id='test1' value='hello1'></input>" | 2131 LoadHTML("<input id='test1' value='hello1'></input>" |
2130 "<input id='test2' value='hello2'></input>"); | 2132 "<input id='test2' value='hello2'></input>"); |
2131 | 2133 |
2132 ExecuteJavaScript("document.getElementById('test1').focus();"); | 2134 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
2133 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( | 2135 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( |
2134 ViewHostMsg_FocusedNodeChanged::ID); | 2136 ViewHostMsg_FocusedNodeChanged::ID); |
2135 EXPECT_TRUE(msg1); | 2137 EXPECT_TRUE(msg1); |
2136 | 2138 |
2137 ViewHostMsg_FocusedNodeChanged::Param params; | 2139 ViewHostMsg_FocusedNodeChanged::Param params; |
2138 ViewHostMsg_FocusedNodeChanged::Read(msg1, ¶ms); | 2140 ViewHostMsg_FocusedNodeChanged::Read(msg1, ¶ms); |
2139 EXPECT_TRUE(base::get<0>(params)); | 2141 EXPECT_TRUE(base::get<0>(params)); |
2140 render_thread_->sink().ClearMessages(); | 2142 render_thread_->sink().ClearMessages(); |
2141 | 2143 |
2142 ExecuteJavaScript("document.getElementById('test2').focus();"); | 2144 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); |
2143 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( | 2145 const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching( |
2144 ViewHostMsg_FocusedNodeChanged::ID); | 2146 ViewHostMsg_FocusedNodeChanged::ID); |
2145 EXPECT_TRUE(msg2); | 2147 EXPECT_TRUE(msg2); |
2146 ViewHostMsg_FocusedNodeChanged::Read(msg2, ¶ms); | 2148 ViewHostMsg_FocusedNodeChanged::Read(msg2, ¶ms); |
2147 EXPECT_TRUE(base::get<0>(params)); | 2149 EXPECT_TRUE(base::get<0>(params)); |
2148 render_thread_->sink().ClearMessages(); | 2150 render_thread_->sink().ClearMessages(); |
2149 | 2151 |
2150 view()->webview()->clearFocusedElement(); | 2152 view()->webview()->clearFocusedElement(); |
2151 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 2153 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
2152 ViewHostMsg_FocusedNodeChanged::ID); | 2154 ViewHostMsg_FocusedNodeChanged::ID); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { | 2349 TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) { |
2348 Attach(); | 2350 Attach(); |
2349 EXPECT_FALSE(IsPaused()); | 2351 EXPECT_FALSE(IsPaused()); |
2350 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); | 2352 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Debugger.enable\"}"); |
2351 | 2353 |
2352 // Executing javascript will pause the thread and create nested message loop. | 2354 // Executing javascript will pause the thread and create nested message loop. |
2353 // Posting task simulates message coming from browser. | 2355 // Posting task simulates message coming from browser. |
2354 base::ThreadTaskRunnerHandle::Get()->PostTask( | 2356 base::ThreadTaskRunnerHandle::Get()->PostTask( |
2355 FROM_HERE, | 2357 FROM_HERE, |
2356 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2358 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2357 ExecuteJavaScript("debugger;"); | 2359 ExecuteJavaScriptForTests("debugger;"); |
2358 | 2360 |
2359 // CloseWhilePaused should resume execution and continue here. | 2361 // CloseWhilePaused should resume execution and continue here. |
2360 EXPECT_FALSE(IsPaused()); | 2362 EXPECT_FALSE(IsPaused()); |
2361 Detach(); | 2363 Detach(); |
2362 } | 2364 } |
2363 | 2365 |
2364 } // namespace content | 2366 } // namespace content |
OLD | NEW |