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 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ui/events/event.h" | 50 #include "ui/events/event.h" |
51 #endif | 51 #endif |
52 | 52 |
53 #if defined(USE_AURA) && defined(USE_X11) | 53 #if defined(USE_AURA) && defined(USE_X11) |
54 #include <X11/Xlib.h> | 54 #include <X11/Xlib.h> |
55 #include "ui/events/event_constants.h" | 55 #include "ui/events/event_constants.h" |
56 #include "ui/events/keycodes/keyboard_code_conversion.h" | 56 #include "ui/events/keycodes/keyboard_code_conversion.h" |
57 #include "ui/events/x/events_x_utils.h" | 57 #include "ui/events/x/events_x_utils.h" |
58 #endif | 58 #endif |
59 | 59 |
60 using WebKit::WebFrame; | 60 using blink::WebFrame; |
61 using WebKit::WebInputEvent; | 61 using blink::WebInputEvent; |
62 using WebKit::WebMouseEvent; | 62 using blink::WebMouseEvent; |
63 using WebKit::WebRuntimeFeatures; | 63 using blink::WebRuntimeFeatures; |
64 using WebKit::WebString; | 64 using blink::WebString; |
65 using WebKit::WebTextDirection; | 65 using blink::WebTextDirection; |
66 using WebKit::WebURLError; | 66 using blink::WebURLError; |
67 | 67 |
68 namespace content { | 68 namespace content { |
69 | 69 |
70 namespace { | 70 namespace { |
71 | 71 |
72 #if defined(USE_AURA) && defined(USE_X11) | 72 #if defined(USE_AURA) && defined(USE_X11) |
73 // Converts MockKeyboard::Modifiers to ui::EventFlags. | 73 // Converts MockKeyboard::Modifiers to ui::EventFlags. |
74 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { | 74 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { |
75 static struct ModifierMap { | 75 static struct ModifierMap { |
76 MockKeyboard::Modifiers src; | 76 MockKeyboard::Modifiers src; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 guint32 unicode_key = 0; | 240 guint32 unicode_key = 0; |
241 for (size_t i = 0; i < events.size(); ++i) { | 241 for (size_t i = 0; i < events.size(); ++i) { |
242 // Only send the up/down events for key press itself (skip the up/down | 242 // Only send the up/down events for key press itself (skip the up/down |
243 // events for the modifier keys). | 243 // events for the modifier keys). |
244 if ((i + 1) == (events.size() / 2) || i == (events.size() / 2)) { | 244 if ((i + 1) == (events.size() / 2) || i == (events.size() / 2)) { |
245 unicode_key = gdk_keyval_to_unicode(events[i]->key.keyval); | 245 unicode_key = gdk_keyval_to_unicode(events[i]->key.keyval); |
246 NativeWebKeyboardEvent webkit_event(events[i]); | 246 NativeWebKeyboardEvent webkit_event(events[i]); |
247 SendNativeKeyEvent(webkit_event); | 247 SendNativeKeyEvent(webkit_event); |
248 | 248 |
249 // Need to add a char event after the key down. | 249 // Need to add a char event after the key down. |
250 if (webkit_event.type == WebKit::WebInputEvent::RawKeyDown) { | 250 if (webkit_event.type == blink::WebInputEvent::RawKeyDown) { |
251 NativeWebKeyboardEvent char_event = webkit_event; | 251 NativeWebKeyboardEvent char_event = webkit_event; |
252 char_event.type = WebKit::WebInputEvent::Char; | 252 char_event.type = blink::WebInputEvent::Char; |
253 char_event.skip_in_browser = true; | 253 char_event.skip_in_browser = true; |
254 SendNativeKeyEvent(char_event); | 254 SendNativeKeyEvent(char_event); |
255 } | 255 } |
256 } | 256 } |
257 gdk_event_free(events[i]); | 257 gdk_event_free(events[i]); |
258 } | 258 } |
259 | 259 |
260 output->assign(1, static_cast<char16>(unicode_key)); | 260 output->assign(1, static_cast<char16>(unicode_key)); |
261 return 1; | 261 return 1; |
262 #else | 262 #else |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 render_thread_->sink().GetUniqueMessageMatching( | 315 render_thread_->sink().GetUniqueMessageMatching( |
316 ViewHostMsg_FrameNavigate::ID); | 316 ViewHostMsg_FrameNavigate::ID); |
317 EXPECT_TRUE(frame_navigate_msg); | 317 EXPECT_TRUE(frame_navigate_msg); |
318 | 318 |
319 ViewHostMsg_FrameNavigate::Param host_nav_params; | 319 ViewHostMsg_FrameNavigate::Param host_nav_params; |
320 ViewHostMsg_FrameNavigate::Read(frame_navigate_msg, &host_nav_params); | 320 ViewHostMsg_FrameNavigate::Read(frame_navigate_msg, &host_nav_params); |
321 EXPECT_TRUE(host_nav_params.a.is_post); | 321 EXPECT_TRUE(host_nav_params.a.is_post); |
322 | 322 |
323 // Check post data sent to browser matches | 323 // Check post data sent to browser matches |
324 EXPECT_TRUE(host_nav_params.a.page_state.IsValid()); | 324 EXPECT_TRUE(host_nav_params.a.page_state.IsValid()); |
325 const WebKit::WebHistoryItem item = PageStateToHistoryItem( | 325 const blink::WebHistoryItem item = PageStateToHistoryItem( |
326 host_nav_params.a.page_state); | 326 host_nav_params.a.page_state); |
327 WebKit::WebHTTPBody body = item.httpBody(); | 327 blink::WebHTTPBody body = item.httpBody(); |
328 WebKit::WebHTTPBody::Element element; | 328 blink::WebHTTPBody::Element element; |
329 bool successful = body.elementAt(0, element); | 329 bool successful = body.elementAt(0, element); |
330 EXPECT_TRUE(successful); | 330 EXPECT_TRUE(successful); |
331 EXPECT_EQ(WebKit::WebHTTPBody::Element::TypeData, element.type); | 331 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
332 EXPECT_EQ(length, element.data.size()); | 332 EXPECT_EQ(length, element.data.size()); |
333 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 333 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
334 } | 334 } |
335 | 335 |
336 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { | 336 TEST_F(RenderViewImplTest, DecideNavigationPolicy) { |
337 WebUITestWebUIControllerFactory factory; | 337 WebUITestWebUIControllerFactory factory; |
338 WebUIControllerFactory::RegisterFactory(&factory); | 338 WebUIControllerFactory::RegisterFactory(&factory); |
339 | 339 |
340 DocumentState state; | 340 DocumentState state; |
341 state.set_navigation_state(NavigationState::CreateContentInitiated()); | 341 state.set_navigation_state(NavigationState::CreateContentInitiated()); |
342 | 342 |
343 // Navigations to normal HTTP URLs can be handled locally. | 343 // Navigations to normal HTTP URLs can be handled locally. |
344 WebKit::WebURLRequest request(GURL("http://foo.com")); | 344 blink::WebURLRequest request(GURL("http://foo.com")); |
345 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( | 345 blink::WebNavigationPolicy policy = view()->decidePolicyForNavigation( |
346 GetMainFrame(), | 346 GetMainFrame(), |
347 &state, | 347 &state, |
348 request, | 348 request, |
349 WebKit::WebNavigationTypeLinkClicked, | 349 blink::WebNavigationTypeLinkClicked, |
350 WebKit::WebNavigationPolicyCurrentTab, | 350 blink::WebNavigationPolicyCurrentTab, |
351 false); | 351 false); |
352 EXPECT_EQ(WebKit::WebNavigationPolicyCurrentTab, policy); | 352 EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy); |
353 | 353 |
354 // Verify that form posts to WebUI URLs will be sent to the browser process. | 354 // Verify that form posts to WebUI URLs will be sent to the browser process. |
355 WebKit::WebURLRequest form_request(GURL("chrome://foo")); | 355 blink::WebURLRequest form_request(GURL("chrome://foo")); |
356 form_request.setHTTPMethod("POST"); | 356 form_request.setHTTPMethod("POST"); |
357 policy = view()->decidePolicyForNavigation( | 357 policy = view()->decidePolicyForNavigation( |
358 GetMainFrame(), | 358 GetMainFrame(), |
359 &state, | 359 &state, |
360 form_request, | 360 form_request, |
361 WebKit::WebNavigationTypeFormSubmitted, | 361 blink::WebNavigationTypeFormSubmitted, |
362 WebKit::WebNavigationPolicyCurrentTab, | 362 blink::WebNavigationPolicyCurrentTab, |
363 false); | 363 false); |
364 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 364 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
365 | 365 |
366 // Verify that popup links to WebUI URLs also are sent to browser. | 366 // Verify that popup links to WebUI URLs also are sent to browser. |
367 WebKit::WebURLRequest popup_request(GURL("chrome://foo")); | 367 blink::WebURLRequest popup_request(GURL("chrome://foo")); |
368 policy = view()->decidePolicyForNavigation( | 368 policy = view()->decidePolicyForNavigation( |
369 GetMainFrame(), | 369 GetMainFrame(), |
370 &state, | 370 &state, |
371 popup_request, | 371 popup_request, |
372 WebKit::WebNavigationTypeLinkClicked, | 372 blink::WebNavigationTypeLinkClicked, |
373 WebKit::WebNavigationPolicyNewForegroundTab, | 373 blink::WebNavigationPolicyNewForegroundTab, |
374 false); | 374 false); |
375 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 375 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
376 } | 376 } |
377 | 377 |
378 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { | 378 TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) { |
379 // Enable bindings to simulate a WebUI view. | 379 // Enable bindings to simulate a WebUI view. |
380 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI); | 380 view()->OnAllowBindings(BINDINGS_POLICY_WEB_UI); |
381 | 381 |
382 DocumentState state; | 382 DocumentState state; |
383 state.set_navigation_state(NavigationState::CreateContentInitiated()); | 383 state.set_navigation_state(NavigationState::CreateContentInitiated()); |
384 | 384 |
385 // Navigations to normal HTTP URLs will be sent to browser process. | 385 // Navigations to normal HTTP URLs will be sent to browser process. |
386 WebKit::WebURLRequest request(GURL("http://foo.com")); | 386 blink::WebURLRequest request(GURL("http://foo.com")); |
387 WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation( | 387 blink::WebNavigationPolicy policy = view()->decidePolicyForNavigation( |
388 GetMainFrame(), | 388 GetMainFrame(), |
389 &state, | 389 &state, |
390 request, | 390 request, |
391 WebKit::WebNavigationTypeLinkClicked, | 391 blink::WebNavigationTypeLinkClicked, |
392 WebKit::WebNavigationPolicyCurrentTab, | 392 blink::WebNavigationPolicyCurrentTab, |
393 false); | 393 false); |
394 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 394 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
395 | 395 |
396 // Navigations to WebUI URLs will also be sent to browser process. | 396 // Navigations to WebUI URLs will also be sent to browser process. |
397 WebKit::WebURLRequest webui_request(GURL("chrome://foo")); | 397 blink::WebURLRequest webui_request(GURL("chrome://foo")); |
398 policy = view()->decidePolicyForNavigation( | 398 policy = view()->decidePolicyForNavigation( |
399 GetMainFrame(), | 399 GetMainFrame(), |
400 &state, | 400 &state, |
401 webui_request, | 401 webui_request, |
402 WebKit::WebNavigationTypeLinkClicked, | 402 blink::WebNavigationTypeLinkClicked, |
403 WebKit::WebNavigationPolicyCurrentTab, | 403 blink::WebNavigationPolicyCurrentTab, |
404 false); | 404 false); |
405 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 405 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
406 | 406 |
407 // Verify that form posts to data URLs will be sent to the browser process. | 407 // Verify that form posts to data URLs will be sent to the browser process. |
408 WebKit::WebURLRequest data_request(GURL("data:text/html,foo")); | 408 blink::WebURLRequest data_request(GURL("data:text/html,foo")); |
409 data_request.setHTTPMethod("POST"); | 409 data_request.setHTTPMethod("POST"); |
410 policy = view()->decidePolicyForNavigation( | 410 policy = view()->decidePolicyForNavigation( |
411 GetMainFrame(), | 411 GetMainFrame(), |
412 &state, | 412 &state, |
413 data_request, | 413 data_request, |
414 WebKit::WebNavigationTypeFormSubmitted, | 414 blink::WebNavigationTypeFormSubmitted, |
415 WebKit::WebNavigationPolicyCurrentTab, | 415 blink::WebNavigationPolicyCurrentTab, |
416 false); | 416 false); |
417 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 417 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
418 | 418 |
419 // Verify that a popup that creates a view first and then navigates to a | 419 // Verify that a popup that creates a view first and then navigates to a |
420 // normal HTTP URL will be sent to the browser process, even though the | 420 // normal HTTP URL will be sent to the browser process, even though the |
421 // new view does not have any enabled_bindings_. | 421 // new view does not have any enabled_bindings_. |
422 WebKit::WebURLRequest popup_request(GURL("http://foo.com")); | 422 blink::WebURLRequest popup_request(GURL("http://foo.com")); |
423 WebKit::WebView* new_web_view = view()->createView( | 423 blink::WebView* new_web_view = view()->createView( |
424 GetMainFrame(), popup_request, WebKit::WebWindowFeatures(), "foo", | 424 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", |
425 WebKit::WebNavigationPolicyNewForegroundTab); | 425 blink::WebNavigationPolicyNewForegroundTab); |
426 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); | 426 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); |
427 policy = new_view->decidePolicyForNavigation( | 427 policy = new_view->decidePolicyForNavigation( |
428 new_web_view->mainFrame(), | 428 new_web_view->mainFrame(), |
429 &state, | 429 &state, |
430 popup_request, | 430 popup_request, |
431 WebKit::WebNavigationTypeLinkClicked, | 431 blink::WebNavigationTypeLinkClicked, |
432 WebKit::WebNavigationPolicyNewForegroundTab, | 432 blink::WebNavigationPolicyNewForegroundTab, |
433 false); | 433 false); |
434 EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy); | 434 EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy); |
435 | 435 |
436 // Clean up after the new view so we don't leak it. | 436 // Clean up after the new view so we don't leak it. |
437 new_view->Close(); | 437 new_view->Close(); |
438 new_view->Release(); | 438 new_view->Release(); |
439 } | 439 } |
440 | 440 |
441 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is | 441 // Ensure the RenderViewImpl sends an ACK to a SwapOut request, even if it is |
442 // already swapped out. http://crbug.com/93427. | 442 // already swapped out. http://crbug.com/93427. |
443 TEST_F(RenderViewImplTest, SendSwapOutACK) { | 443 TEST_F(RenderViewImplTest, SendSwapOutACK) { |
444 LoadHTML("<div>Page A</div>"); | 444 LoadHTML("<div>Page A</div>"); |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 break; | 1000 break; |
1001 | 1001 |
1002 case IME_SETFOCUS: | 1002 case IME_SETFOCUS: |
1003 // Update the window focus. | 1003 // Update the window focus. |
1004 view()->OnSetFocus(ime_message->enable); | 1004 view()->OnSetFocus(ime_message->enable); |
1005 break; | 1005 break; |
1006 | 1006 |
1007 case IME_SETCOMPOSITION: | 1007 case IME_SETCOMPOSITION: |
1008 view()->OnImeSetComposition( | 1008 view()->OnImeSetComposition( |
1009 WideToUTF16Hack(ime_message->ime_string), | 1009 WideToUTF16Hack(ime_message->ime_string), |
1010 std::vector<WebKit::WebCompositionUnderline>(), | 1010 std::vector<blink::WebCompositionUnderline>(), |
1011 ime_message->selection_start, | 1011 ime_message->selection_start, |
1012 ime_message->selection_end); | 1012 ime_message->selection_end); |
1013 break; | 1013 break; |
1014 | 1014 |
1015 case IME_CONFIRMCOMPOSITION: | 1015 case IME_CONFIRMCOMPOSITION: |
1016 view()->OnImeConfirmComposition( | 1016 view()->OnImeConfirmComposition( |
1017 WideToUTF16Hack(ime_message->ime_string), | 1017 WideToUTF16Hack(ime_message->ime_string), |
1018 gfx::Range::InvalidRange(), | 1018 gfx::Range::InvalidRange(), |
1019 false); | 1019 false); |
1020 break; | 1020 break; |
1021 | 1021 |
1022 case IME_CANCELCOMPOSITION: | 1022 case IME_CANCELCOMPOSITION: |
1023 view()->OnImeSetComposition( | 1023 view()->OnImeSetComposition( |
1024 string16(), | 1024 string16(), |
1025 std::vector<WebKit::WebCompositionUnderline>(), | 1025 std::vector<blink::WebCompositionUnderline>(), |
1026 0, 0); | 1026 0, 0); |
1027 break; | 1027 break; |
1028 } | 1028 } |
1029 | 1029 |
1030 // Update the status of our IME back-end. | 1030 // Update the status of our IME back-end. |
1031 // TODO(hbono): we should verify messages to be sent from the back-end. | 1031 // TODO(hbono): we should verify messages to be sent from the back-end. |
1032 view()->UpdateTextInputType(); | 1032 view()->UpdateTextInputType(); |
1033 ProcessPendingMessages(); | 1033 ProcessPendingMessages(); |
1034 render_thread_->sink().ClearMessages(); | 1034 render_thread_->sink().ClearMessages(); |
1035 | 1035 |
(...skipping 23 matching lines...) Expand all Loading... |
1059 "<textarea id=\"test\"></textarea>" | 1059 "<textarea id=\"test\"></textarea>" |
1060 "<div id=\"result\" contenteditable=\"true\"></div>" | 1060 "<div id=\"result\" contenteditable=\"true\"></div>" |
1061 "</body>" | 1061 "</body>" |
1062 "</html>"); | 1062 "</html>"); |
1063 render_thread_->sink().ClearMessages(); | 1063 render_thread_->sink().ClearMessages(); |
1064 | 1064 |
1065 static const struct { | 1065 static const struct { |
1066 WebTextDirection direction; | 1066 WebTextDirection direction; |
1067 const wchar_t* expected_result; | 1067 const wchar_t* expected_result; |
1068 } kTextDirection[] = { | 1068 } kTextDirection[] = { |
1069 { WebKit::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, | 1069 { blink::WebTextDirectionRightToLeft, L"\x000A" L"rtl,rtl" }, |
1070 { WebKit::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, | 1070 { blink::WebTextDirectionLeftToRight, L"\x000A" L"ltr,ltr" }, |
1071 }; | 1071 }; |
1072 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTextDirection); ++i) { | 1072 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTextDirection); ++i) { |
1073 // Set the text direction of the <textarea> element. | 1073 // Set the text direction of the <textarea> element. |
1074 ExecuteJavaScript("document.getElementById('test').focus();"); | 1074 ExecuteJavaScript("document.getElementById('test').focus();"); |
1075 view()->OnSetTextDirection(kTextDirection[i].direction); | 1075 view()->OnSetTextDirection(kTextDirection[i].direction); |
1076 | 1076 |
1077 // Write the values of its DOM 'dir' attribute and its CSS 'direction' | 1077 // Write the values of its DOM 'dir' attribute and its CSS 'direction' |
1078 // property to the <div> element. | 1078 // property to the <div> element. |
1079 ExecuteJavaScript("var result = document.getElementById('result');" | 1079 ExecuteJavaScript("var result = document.getElementById('result');" |
1080 "var node = document.getElementById('test');" | 1080 "var node = document.getElementById('test');" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 | 1516 |
1517 // A cancellation occurred. | 1517 // A cancellation occurred. |
1518 view()->didFailProvisionalLoad(web_frame, error); | 1518 view()->didFailProvisionalLoad(web_frame, error); |
1519 // Frame should stay in view-source mode. | 1519 // Frame should stay in view-source mode. |
1520 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); | 1520 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); |
1521 } | 1521 } |
1522 | 1522 |
1523 // Regression test for http://crbug.com/41562 | 1523 // Regression test for http://crbug.com/41562 |
1524 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { | 1524 TEST_F(RenderViewImplTest, UpdateTargetURLWithInvalidURL) { |
1525 const GURL invalid_gurl("http://"); | 1525 const GURL invalid_gurl("http://"); |
1526 view()->setMouseOverURL(WebKit::WebURL(invalid_gurl)); | 1526 view()->setMouseOverURL(blink::WebURL(invalid_gurl)); |
1527 EXPECT_EQ(invalid_gurl, view()->target_url_); | 1527 EXPECT_EQ(invalid_gurl, view()->target_url_); |
1528 } | 1528 } |
1529 | 1529 |
1530 TEST_F(RenderViewImplTest, SetHistoryLengthAndPrune) { | 1530 TEST_F(RenderViewImplTest, SetHistoryLengthAndPrune) { |
1531 int expected_page_id = -1; | 1531 int expected_page_id = -1; |
1532 | 1532 |
1533 // No history to merge and no committed pages. | 1533 // No history to merge and no committed pages. |
1534 view()->OnSetHistoryLengthAndPrune(0, -1); | 1534 view()->OnSetHistoryLengthAndPrune(0, -1); |
1535 EXPECT_EQ(0, view()->history_list_length_); | 1535 EXPECT_EQ(0, view()->history_list_length_); |
1536 EXPECT_EQ(-1, view()->history_list_offset_); | 1536 EXPECT_EQ(-1, view()->history_list_offset_); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 // Now simulate the corresponding up event which should display the menu | 1705 // Now simulate the corresponding up event which should display the menu |
1706 mouse_event.type = WebInputEvent::MouseUp; | 1706 mouse_event.type = WebInputEvent::MouseUp; |
1707 SendWebMouseEvent(mouse_event); | 1707 SendWebMouseEvent(mouse_event); |
1708 | 1708 |
1709 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( | 1709 EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching( |
1710 ViewHostMsg_ContextMenu::ID)); | 1710 ViewHostMsg_ContextMenu::ID)); |
1711 } | 1711 } |
1712 | 1712 |
1713 TEST_F(RenderViewImplTest, TestBackForward) { | 1713 TEST_F(RenderViewImplTest, TestBackForward) { |
1714 LoadHTML("<div id=pagename>Page A</div>"); | 1714 LoadHTML("<div id=pagename>Page A</div>"); |
1715 WebKit::WebHistoryItem page_a_item = GetMainFrame()->currentHistoryItem(); | 1715 blink::WebHistoryItem page_a_item = GetMainFrame()->currentHistoryItem(); |
1716 int was_page_a = -1; | 1716 int was_page_a = -1; |
1717 string16 check_page_a = | 1717 string16 check_page_a = |
1718 ASCIIToUTF16( | 1718 ASCIIToUTF16( |
1719 "Number(document.getElementById('pagename').innerHTML == 'Page A')"); | 1719 "Number(document.getElementById('pagename').innerHTML == 'Page A')"); |
1720 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); | 1720 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); |
1721 EXPECT_EQ(1, was_page_a); | 1721 EXPECT_EQ(1, was_page_a); |
1722 | 1722 |
1723 LoadHTML("<div id=pagename>Page B</div>"); | 1723 LoadHTML("<div id=pagename>Page B</div>"); |
1724 int was_page_b = -1; | 1724 int was_page_b = -1; |
1725 string16 check_page_b = | 1725 string16 check_page_b = |
1726 ASCIIToUTF16( | 1726 ASCIIToUTF16( |
1727 "Number(document.getElementById('pagename').innerHTML == 'Page B')"); | 1727 "Number(document.getElementById('pagename').innerHTML == 'Page B')"); |
1728 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1728 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
1729 EXPECT_EQ(1, was_page_b); | 1729 EXPECT_EQ(1, was_page_b); |
1730 | 1730 |
1731 LoadHTML("<div id=pagename>Page C</div>"); | 1731 LoadHTML("<div id=pagename>Page C</div>"); |
1732 int was_page_c = -1; | 1732 int was_page_c = -1; |
1733 string16 check_page_c = | 1733 string16 check_page_c = |
1734 ASCIIToUTF16( | 1734 ASCIIToUTF16( |
1735 "Number(document.getElementById('pagename').innerHTML == 'Page C')"); | 1735 "Number(document.getElementById('pagename').innerHTML == 'Page C')"); |
1736 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); | 1736 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); |
1737 EXPECT_EQ(1, was_page_b); | 1737 EXPECT_EQ(1, was_page_b); |
1738 | 1738 |
1739 WebKit::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem(); | 1739 blink::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem(); |
1740 GoBack(GetMainFrame()->previousHistoryItem()); | 1740 GoBack(GetMainFrame()->previousHistoryItem()); |
1741 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1741 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
1742 EXPECT_EQ(1, was_page_b); | 1742 EXPECT_EQ(1, was_page_b); |
1743 | 1743 |
1744 GoForward(forward_item); | 1744 GoForward(forward_item); |
1745 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); | 1745 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c)); |
1746 EXPECT_EQ(1, was_page_c); | 1746 EXPECT_EQ(1, was_page_c); |
1747 | 1747 |
1748 GoBack(GetMainFrame()->previousHistoryItem()); | 1748 GoBack(GetMainFrame()->previousHistoryItem()); |
1749 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); | 1749 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b)); |
(...skipping 15 matching lines...) Expand all Loading... |
1765 #if defined(OS_WIN) | 1765 #if defined(OS_WIN) |
1766 // http://crbug.com/304193 | 1766 // http://crbug.com/304193 |
1767 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 1767 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
1768 return; | 1768 return; |
1769 #endif | 1769 #endif |
1770 | 1770 |
1771 LoadHTML("<textarea id=\"test\"></textarea>"); | 1771 LoadHTML("<textarea id=\"test\"></textarea>"); |
1772 ExecuteJavaScript("document.getElementById('test').focus();"); | 1772 ExecuteJavaScript("document.getElementById('test').focus();"); |
1773 | 1773 |
1774 const string16 empty_string = UTF8ToUTF16(""); | 1774 const string16 empty_string = UTF8ToUTF16(""); |
1775 const std::vector<WebKit::WebCompositionUnderline> empty_underline; | 1775 const std::vector<blink::WebCompositionUnderline> empty_underline; |
1776 std::vector<gfx::Rect> bounds; | 1776 std::vector<gfx::Rect> bounds; |
1777 view()->OnSetFocus(true); | 1777 view()->OnSetFocus(true); |
1778 view()->OnSetInputMethodActive(true); | 1778 view()->OnSetInputMethodActive(true); |
1779 | 1779 |
1780 // ASCII composition | 1780 // ASCII composition |
1781 const string16 ascii_composition = UTF8ToUTF16("aiueo"); | 1781 const string16 ascii_composition = UTF8ToUTF16("aiueo"); |
1782 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); | 1782 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); |
1783 view()->GetCompositionCharacterBounds(&bounds); | 1783 view()->GetCompositionCharacterBounds(&bounds); |
1784 ASSERT_EQ(ascii_composition.size(), bounds.size()); | 1784 ASSERT_EQ(ascii_composition.size(), bounds.size()); |
1785 for (size_t i = 0; i < bounds.size(); ++i) | 1785 for (size_t i = 0; i < bounds.size(); ++i) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 // Load an HTML page consisting of an input field. | 1867 // Load an HTML page consisting of an input field. |
1868 LoadHTML("<html>" | 1868 LoadHTML("<html>" |
1869 "<head>" | 1869 "<head>" |
1870 "</head>" | 1870 "</head>" |
1871 "<body>" | 1871 "<body>" |
1872 "<input id=\"test1\" value=\"some test text hello\"></input>" | 1872 "<input id=\"test1\" value=\"some test text hello\"></input>" |
1873 "</body>" | 1873 "</body>" |
1874 "</html>"); | 1874 "</html>"); |
1875 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1875 ExecuteJavaScript("document.getElementById('test1').focus();"); |
1876 view()->OnSetEditableSelectionOffsets(4, 8); | 1876 view()->OnSetEditableSelectionOffsets(4, 8); |
1877 const std::vector<WebKit::WebCompositionUnderline> empty_underline; | 1877 const std::vector<blink::WebCompositionUnderline> empty_underline; |
1878 view()->OnSetCompositionFromExistingText(7, 10, empty_underline); | 1878 view()->OnSetCompositionFromExistingText(7, 10, empty_underline); |
1879 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1879 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1880 EXPECT_EQ(4, info.selectionStart); | 1880 EXPECT_EQ(4, info.selectionStart); |
1881 EXPECT_EQ(8, info.selectionEnd); | 1881 EXPECT_EQ(8, info.selectionEnd); |
1882 EXPECT_EQ(7, info.compositionStart); | 1882 EXPECT_EQ(7, info.compositionStart); |
1883 EXPECT_EQ(10, info.compositionEnd); | 1883 EXPECT_EQ(10, info.compositionEnd); |
1884 view()->OnUnselect(); | 1884 view()->OnUnselect(); |
1885 info = view()->webview()->textInputInfo(); | 1885 info = view()->webview()->textInputInfo(); |
1886 EXPECT_EQ(0, info.selectionStart); | 1886 EXPECT_EQ(0, info.selectionStart); |
1887 EXPECT_EQ(0, info.selectionEnd); | 1887 EXPECT_EQ(0, info.selectionEnd); |
1888 } | 1888 } |
1889 | 1889 |
1890 | 1890 |
1891 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { | 1891 TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) { |
1892 // Load an HTML page consisting of an input field. | 1892 // Load an HTML page consisting of an input field. |
1893 LoadHTML("<html>" | 1893 LoadHTML("<html>" |
1894 "<head>" | 1894 "<head>" |
1895 "</head>" | 1895 "</head>" |
1896 "<body>" | 1896 "<body>" |
1897 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" | 1897 "<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>" |
1898 "</body>" | 1898 "</body>" |
1899 "</html>"); | 1899 "</html>"); |
1900 ExecuteJavaScript("document.getElementById('test1').focus();"); | 1900 ExecuteJavaScript("document.getElementById('test1').focus();"); |
1901 view()->OnSetEditableSelectionOffsets(10, 10); | 1901 view()->OnSetEditableSelectionOffsets(10, 10); |
1902 view()->OnExtendSelectionAndDelete(3, 4); | 1902 view()->OnExtendSelectionAndDelete(3, 4); |
1903 WebKit::WebTextInputInfo info = view()->webview()->textInputInfo(); | 1903 blink::WebTextInputInfo info = view()->webview()->textInputInfo(); |
1904 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1904 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1905 EXPECT_EQ(7, info.selectionStart); | 1905 EXPECT_EQ(7, info.selectionStart); |
1906 EXPECT_EQ(7, info.selectionEnd); | 1906 EXPECT_EQ(7, info.selectionEnd); |
1907 view()->OnSetEditableSelectionOffsets(4, 8); | 1907 view()->OnSetEditableSelectionOffsets(4, 8); |
1908 view()->OnExtendSelectionAndDelete(2, 5); | 1908 view()->OnExtendSelectionAndDelete(2, 5); |
1909 info = view()->webview()->textInputInfo(); | 1909 info = view()->webview()->textInputInfo(); |
1910 EXPECT_EQ("abuvwxyz", info.value); | 1910 EXPECT_EQ("abuvwxyz", info.value); |
1911 EXPECT_EQ(2, info.selectionStart); | 1911 EXPECT_EQ(2, info.selectionStart); |
1912 EXPECT_EQ(2, info.selectionEnd); | 1912 EXPECT_EQ(2, info.selectionEnd); |
1913 } | 1913 } |
(...skipping 30 matching lines...) Expand all Loading... |
1944 EXPECT_TRUE(view()->main_render_frame_.get()); | 1944 EXPECT_TRUE(view()->main_render_frame_.get()); |
1945 } | 1945 } |
1946 | 1946 |
1947 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { | 1947 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { |
1948 LoadHTML("<!DOCTYPE html><html><body></body></html>"); | 1948 LoadHTML("<!DOCTYPE html><html><body></body></html>"); |
1949 | 1949 |
1950 WebFrame* frame = GetMainFrame(); | 1950 WebFrame* frame = GetMainFrame(); |
1951 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame); | 1951 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame); |
1952 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); | 1952 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); |
1953 | 1953 |
1954 const_cast<WebKit::WebURLResponse&>(frame->dataSource()->response()). | 1954 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()). |
1955 setSecurityInfo( | 1955 setSecurityInfo( |
1956 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0)); | 1956 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0)); |
1957 ssl_status = view()->GetSSLStatusOfFrame(frame); | 1957 ssl_status = view()->GetSSLStatusOfFrame(frame); |
1958 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); | 1958 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); |
1959 } | 1959 } |
1960 | 1960 |
1961 class SuppressErrorPageTest : public RenderViewTest { | 1961 class SuppressErrorPageTest : public RenderViewTest { |
1962 public: | 1962 public: |
1963 virtual void SetUp() OVERRIDE { | 1963 virtual void SetUp() OVERRIDE { |
1964 SetRendererClientForTesting(&client_); | 1964 SetRendererClientForTesting(&client_); |
1965 RenderViewTest::SetUp(); | 1965 RenderViewTest::SetUp(); |
1966 } | 1966 } |
1967 | 1967 |
1968 RenderViewImpl* view() { | 1968 RenderViewImpl* view() { |
1969 return static_cast<RenderViewImpl*>(view_); | 1969 return static_cast<RenderViewImpl*>(view_); |
1970 } | 1970 } |
1971 | 1971 |
1972 private: | 1972 private: |
1973 class TestContentRendererClient : public ContentRendererClient { | 1973 class TestContentRendererClient : public ContentRendererClient { |
1974 public: | 1974 public: |
1975 virtual bool ShouldSuppressErrorPage(const GURL& url) OVERRIDE { | 1975 virtual bool ShouldSuppressErrorPage(const GURL& url) OVERRIDE { |
1976 return url == GURL("http://example.com/suppress"); | 1976 return url == GURL("http://example.com/suppress"); |
1977 } | 1977 } |
1978 | 1978 |
1979 virtual void GetNavigationErrorStrings( | 1979 virtual void GetNavigationErrorStrings( |
1980 WebKit::WebFrame* frame, | 1980 blink::WebFrame* frame, |
1981 const WebKit::WebURLRequest& failed_request, | 1981 const blink::WebURLRequest& failed_request, |
1982 const WebKit::WebURLError& error, | 1982 const blink::WebURLError& error, |
1983 const std::string& accept_languages, | 1983 const std::string& accept_languages, |
1984 std::string* error_html, | 1984 std::string* error_html, |
1985 string16* error_description) OVERRIDE { | 1985 string16* error_description) OVERRIDE { |
1986 if (error_html) | 1986 if (error_html) |
1987 *error_html = "A suffusion of yellow."; | 1987 *error_html = "A suffusion of yellow."; |
1988 } | 1988 } |
1989 }; | 1989 }; |
1990 | 1990 |
1991 TestContentRendererClient client_; | 1991 TestContentRendererClient client_; |
1992 }; | 1992 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 | 2043 |
2044 // An error occurred. | 2044 // An error occurred. |
2045 view()->didFailProvisionalLoad(web_frame, error); | 2045 view()->didFailProvisionalLoad(web_frame, error); |
2046 ProcessPendingMessages(); | 2046 ProcessPendingMessages(); |
2047 const int kMaxOutputCharacters = 22; | 2047 const int kMaxOutputCharacters = 22; |
2048 EXPECT_EQ("A suffusion of yellow.", | 2048 EXPECT_EQ("A suffusion of yellow.", |
2049 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2049 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
2050 } | 2050 } |
2051 | 2051 |
2052 } // namespace content | 2052 } // namespace content |
OLD | NEW |