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

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

Issue 694963003: Revert of Clean up the page state saving mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching( 333 const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
334 ViewHostMsg_SaveImageFromDataURL::ID); 334 ViewHostMsg_SaveImageFromDataURL::ID);
335 EXPECT_FALSE(msg4); 335 EXPECT_FALSE(msg4);
336 } 336 }
337 337
338 // Test that we get form state change notifications when input fields change. 338 // Test that we get form state change notifications when input fields change.
339 TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) { 339 TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) {
340 // Don't want any delay for form state sync changes. This will still post a 340 // Don't want any delay for form state sync changes. This will still post a
341 // message so updates will get coalesced, but as soon as we spin the message 341 // message so updates will get coalesced, but as soon as we spin the message
342 // loop, it will generate an update. 342 // loop, it will generate an update.
343 view()->set_page_state_sent_immediately(true); 343 view()->set_send_content_state_immediately(true);
344 344
345 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>"); 345 LoadHTML("<input type=\"text\" id=\"elt_text\"></input>");
346 346
347 // We should NOT have gotten a form state change notification yet. 347 // We should NOT have gotten a form state change notification yet.
348 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 348 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
349 ViewHostMsg_UpdateState::ID)); 349 ViewHostMsg_UpdateState::ID));
350 render_thread_->sink().ClearMessages(); 350 render_thread_->sink().ClearMessages();
351 351
352 // Change the value of the input. We should have gotten an update state 352 // Change the value of the input. We should have gotten an update state
353 // notification. We need to spin the message loop to catch this update. 353 // notification. We need to spin the message loop to catch this update.
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 EXPECT_EQ(2, view()->history_page_ids_[0]); 908 EXPECT_EQ(2, view()->history_page_ids_[0]);
909 } 909 }
910 910
911 // Test that our IME backend sends a notification message when the input focus 911 // Test that our IME backend sends a notification message when the input focus
912 // changes. 912 // changes.
913 TEST_F(RenderViewImplTest, OnImeTypeChanged) { 913 TEST_F(RenderViewImplTest, OnImeTypeChanged) {
914 // Enable our IME backend code. 914 // Enable our IME backend code.
915 view()->OnSetInputMethodActive(true); 915 view()->OnSetInputMethodActive(true);
916 916
917 // Load an HTML page consisting of two input fields. 917 // Load an HTML page consisting of two input fields.
918 view()->set_page_state_sent_immediately(true); 918 view()->set_send_content_state_immediately(true);
919 LoadHTML("<html>" 919 LoadHTML("<html>"
920 "<head>" 920 "<head>"
921 "</head>" 921 "</head>"
922 "<body>" 922 "<body>"
923 "<input id=\"test1\" type=\"text\" value=\"some text\"></input>" 923 "<input id=\"test1\" type=\"text\" value=\"some text\"></input>"
924 "<input id=\"test2\" type=\"password\"></input>" 924 "<input id=\"test2\" type=\"password\"></input>"
925 "<input id=\"test3\" type=\"text\" inputmode=\"verbatim\"></input>" 925 "<input id=\"test3\" type=\"text\" inputmode=\"verbatim\"></input>"
926 "<input id=\"test4\" type=\"text\" inputmode=\"latin\"></input>" 926 "<input id=\"test4\" type=\"text\" inputmode=\"latin\"></input>"
927 "<input id=\"test5\" type=\"text\" inputmode=\"latin-name\"></input>" 927 "<input id=\"test5\" type=\"text\" inputmode=\"latin-name\"></input>"
928 "<input id=\"test6\" type=\"text\" inputmode=\"latin-prose\">" 928 "<input id=\"test6\" type=\"text\" inputmode=\"latin-prose\">"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 }; 1097 };
1098 1098
1099 for (size_t i = 0; i < arraysize(kImeMessages); i++) { 1099 for (size_t i = 0; i < arraysize(kImeMessages); i++) {
1100 const ImeMessage* ime_message = &kImeMessages[i]; 1100 const ImeMessage* ime_message = &kImeMessages[i];
1101 switch (ime_message->command) { 1101 switch (ime_message->command) {
1102 case IME_INITIALIZE: 1102 case IME_INITIALIZE:
1103 // Load an HTML page consisting of a content-editable <div> element, 1103 // Load an HTML page consisting of a content-editable <div> element,
1104 // and move the input focus to the <div> element, where we can use 1104 // and move the input focus to the <div> element, where we can use
1105 // IMEs. 1105 // IMEs.
1106 view()->OnSetInputMethodActive(ime_message->enable); 1106 view()->OnSetInputMethodActive(ime_message->enable);
1107 view()->set_page_state_sent_immediately(true); 1107 view()->set_send_content_state_immediately(true);
1108 LoadHTML("<html>" 1108 LoadHTML("<html>"
1109 "<head>" 1109 "<head>"
1110 "</head>" 1110 "</head>"
1111 "<body>" 1111 "<body>"
1112 "<div id=\"test1\" contenteditable=\"true\"></div>" 1112 "<div id=\"test1\" contenteditable=\"true\"></div>"
1113 "</body>" 1113 "</body>"
1114 "</html>"); 1114 "</html>");
1115 ExecuteJavaScript("document.getElementById('test1').focus();"); 1115 ExecuteJavaScript("document.getElementById('test1').focus();");
1116 break; 1116 break;
1117 1117
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1165 }
1166 } 1166 }
1167 1167
1168 // Test that the RenderView::OnSetTextDirection() function can change the text 1168 // Test that the RenderView::OnSetTextDirection() function can change the text
1169 // direction of the selected input element. 1169 // direction of the selected input element.
1170 TEST_F(RenderViewImplTest, OnSetTextDirection) { 1170 TEST_F(RenderViewImplTest, OnSetTextDirection) {
1171 // Load an HTML page consisting of a <textarea> element and a <div> element. 1171 // Load an HTML page consisting of a <textarea> element and a <div> element.
1172 // This test changes the text direction of the <textarea> element, and 1172 // This test changes the text direction of the <textarea> element, and
1173 // writes the values of its 'dir' attribute and its 'direction' property to 1173 // writes the values of its 'dir' attribute and its 'direction' property to
1174 // verify that the text direction is changed. 1174 // verify that the text direction is changed.
1175 view()->set_page_state_sent_immediately(true); 1175 view()->set_send_content_state_immediately(true);
1176 LoadHTML("<html>" 1176 LoadHTML("<html>"
1177 "<head>" 1177 "<head>"
1178 "</head>" 1178 "</head>"
1179 "<body>" 1179 "<body>"
1180 "<textarea id=\"test\"></textarea>" 1180 "<textarea id=\"test\"></textarea>"
1181 "<div id=\"result\" contenteditable=\"true\"></div>" 1181 "<div id=\"result\" contenteditable=\"true\"></div>"
1182 "</body>" 1182 "</body>"
1183 "</html>"); 1183 "</html>");
1184 render_thread_->sink().ClearMessages(); 1184 render_thread_->sink().ClearMessages();
1185 1185
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 TEST_F(RenderViewImplTest, MAYBE_OnHandleKeyboardEvent) { 1224 TEST_F(RenderViewImplTest, MAYBE_OnHandleKeyboardEvent) {
1225 #if !defined(OS_MACOSX) 1225 #if !defined(OS_MACOSX)
1226 // Load an HTML page consisting of one <input> element and three 1226 // Load an HTML page consisting of one <input> element and three
1227 // contentediable <div> elements. 1227 // contentediable <div> elements.
1228 // The <input> element is used for sending keyboard events, and the <div> 1228 // The <input> element is used for sending keyboard events, and the <div>
1229 // elements are used for writing DOM events in the following format: 1229 // elements are used for writing DOM events in the following format:
1230 // "<keyCode>,<shiftKey>,<controlKey>,<altKey>". 1230 // "<keyCode>,<shiftKey>,<controlKey>,<altKey>".
1231 // TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to 1231 // TODO(hbono): <http://crbug.com/2215> Our WebKit port set |ev.metaKey| to
1232 // true when pressing an alt key, i.e. the |ev.metaKey| value is not 1232 // true when pressing an alt key, i.e. the |ev.metaKey| value is not
1233 // trustworthy. We will check the |ev.metaKey| value when this issue is fixed. 1233 // trustworthy. We will check the |ev.metaKey| value when this issue is fixed.
1234 view()->set_page_state_sent_immediately(true); 1234 view()->set_send_content_state_immediately(true);
1235 LoadHTML("<html>" 1235 LoadHTML("<html>"
1236 "<head>" 1236 "<head>"
1237 "<title></title>" 1237 "<title></title>"
1238 "<script type='text/javascript' language='javascript'>" 1238 "<script type='text/javascript' language='javascript'>"
1239 "function OnKeyEvent(ev) {" 1239 "function OnKeyEvent(ev) {"
1240 " var result = document.getElementById(ev.type);" 1240 " var result = document.getElementById(ev.type);"
1241 " result.innerText =" 1241 " result.innerText ="
1242 " (ev.which || ev.keyCode) + ',' +" 1242 " (ev.which || ev.keyCode) + ',' +"
1243 " ev.shiftKey + ',' +" 1243 " ev.shiftKey + ',' +"
1244 " ev.ctrlKey + ',' +" 1244 " ev.ctrlKey + ',' +"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 L"\x002e\x002f\x0060\x005b\x005c\x005d\x0027" 1511 L"\x002e\x002f\x0060\x005b\x005c\x005d\x0027"
1512 #endif 1512 #endif
1513 }, 1513 },
1514 }; 1514 };
1515 1515
1516 for (size_t i = 0; i < arraysize(kLayouts); ++i) { 1516 for (size_t i = 0; i < arraysize(kLayouts); ++i) {
1517 // Load an HTML page consisting of one <div> element. 1517 // Load an HTML page consisting of one <div> element.
1518 // This <div> element is used by the EditorClientImpl class to insert 1518 // This <div> element is used by the EditorClientImpl class to insert
1519 // characters received through the RenderWidget::OnHandleInputEvent() 1519 // characters received through the RenderWidget::OnHandleInputEvent()
1520 // function. 1520 // function.
1521 view()->set_page_state_sent_immediately(true); 1521 view()->set_send_content_state_immediately(true);
1522 LoadHTML("<html>" 1522 LoadHTML("<html>"
1523 "<head>" 1523 "<head>"
1524 "<title></title>" 1524 "<title></title>"
1525 "</head>" 1525 "</head>"
1526 "<body>" 1526 "<body>"
1527 "<div id='test' contenteditable='true'>" 1527 "<div id='test' contenteditable='true'>"
1528 "</div>" 1528 "</div>"
1529 "</body>" 1529 "</body>"
1530 "</html>"); 1530 "</html>");
1531 ExecuteJavaScript("document.getElementById('test').focus();"); 1531 ExecuteJavaScript("document.getElementById('test').focus();");
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()). 2131 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()).
2132 setSecurityInfo( 2132 setSecurityInfo(
2133 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0, 2133 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0,
2134 SignedCertificateTimestampIDStatusList())); 2134 SignedCertificateTimestampIDStatusList()));
2135 ssl_status = view()->GetSSLStatusOfFrame(frame); 2135 ssl_status = view()->GetSSLStatusOfFrame(frame);
2136 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); 2136 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status));
2137 } 2137 }
2138 2138
2139 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { 2139 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
2140 view()->OnSetInputMethodActive(true); 2140 view()->OnSetInputMethodActive(true);
2141 view()->set_page_state_sent_immediately(true); 2141 view()->set_send_content_state_immediately(true);
2142 LoadHTML("<textarea id=\"test\"></textarea>"); 2142 LoadHTML("<textarea id=\"test\"></textarea>");
2143 2143
2144 view()->handling_input_event_ = true; 2144 view()->handling_input_event_ = true;
2145 ExecuteJavaScript("document.getElementById('test').focus();"); 2145 ExecuteJavaScript("document.getElementById('test').focus();");
2146 2146
2147 bool is_input_type_called = false; 2147 bool is_input_type_called = false;
2148 bool is_selection_called = false; 2148 bool is_selection_called = false;
2149 size_t last_input_type = 0; 2149 size_t last_input_type = 0;
2150 size_t last_selection = 0; 2150 size_t last_selection = 0;
2151 2151
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 ProcessPendingMessages(); 2488 ProcessPendingMessages();
2489 base::Time after_navigation = 2489 base::Time after_navigation =
2490 base::Time::Now() + base::TimeDelta::FromDays(1); 2490 base::Time::Now() + base::TimeDelta::FromDays(1);
2491 2491
2492 base::Time late_nav_reported_start = 2492 base::Time late_nav_reported_start =
2493 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart()); 2493 base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
2494 EXPECT_LE(late_nav_reported_start, after_navigation); 2494 EXPECT_LE(late_nav_reported_start, after_navigation);
2495 } 2495 }
2496 2496
2497 } // namespace content 2497 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698