#include "base/memory/shared_memory.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/time/time.h"
#include "base/win/windows_version.h"
+#include "content/child/request_extra_data.h"
+#include "content/child/service_worker/service_worker_network_provider.h"
#include "content/common/frame_messages.h"
#include "content/common/ssl_status_serialization.h"
#include "content/common/view_messages.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
+#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/document_state.h"
-#include "content/public/renderer/history_item_serialization.h"
#include "content/public/renderer/navigation_state.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/frame_load_waiter.h"
#include "content/public/test/render_view_test.h"
#include "content/public/test/test_utils.h"
+#include "content/renderer/accessibility/renderer_accessibility.h"
+#include "content/renderer/accessibility/renderer_accessibility_complete.h"
+#include "content/renderer/accessibility/renderer_accessibility_focus_only.h"
+#include "content/renderer/history_controller.h"
+#include "content/renderer/history_serialization.h"
+#include "content/renderer/render_process.h"
#include "content/renderer/render_view_impl.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
#include "third_party/WebKit/public/web/WebHistoryItem.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/WebKit/public/web/WebPerformance.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/WebKit/public/web/WebWindowFeatures.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/range/range.h"
-#if defined(OS_LINUX) && !defined(USE_AURA)
-#include "ui/base/gtk/event_synthesis_gtk.h"
-#endif
-
#if defined(USE_AURA)
#include "ui/events/event.h"
#endif
#include <X11/Xlib.h>
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
+#include "ui/events/test/events_test_utils.h"
#include "ui/events/test/events_test_utils_x11.h"
#endif
using blink::WebFrame;
using blink::WebInputEvent;
+using blink::WebLocalFrame;
using blink::WebMouseEvent;
using blink::WebRuntimeFeatures;
using blink::WebString;
namespace {
+static const int kProxyRoutingId = 13;
+
#if (defined(USE_AURA) && defined(USE_X11)) || defined(USE_OZONE)
// Converts MockKeyboard::Modifiers to ui::EventFlags.
int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) {
}
};
+} // namespace
+
class RenderViewImplTest : public RenderViewTest {
public:
RenderViewImplTest() {
return static_cast<RenderViewImpl*>(view_);
}
+ int view_page_id() {
+ return view()->page_id_;
+ }
+
RenderFrameImpl* frame() {
return static_cast<RenderFrameImpl*>(view()->GetMainRenderFrame());
}
// WM_CHAR sends a composed Unicode character.
MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt1(msg1, false);
+ ui::KeyEvent evt1(msg1);
NativeWebKeyboardEvent keydown_event(&evt1);
#else
NativeWebKeyboardEvent keydown_event(msg1);
MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt2(msg2, true);
+ ui::KeyEvent evt2(msg2);
NativeWebKeyboardEvent char_event(&evt2);
#else
NativeWebKeyboardEvent char_event(msg2);
MSG msg3 = { NULL, WM_KEYUP, key_code, 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt3(msg3, false);
+ ui::KeyEvent evt3(msg3);
NativeWebKeyboardEvent keyup_event(&evt3);
#else
NativeWebKeyboardEvent keyup_event(msg3);
xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event1(xevent, false);
+ ui::KeyEvent event1(xevent);
NativeWebKeyboardEvent keydown_event(&event1);
SendNativeKeyEvent(keydown_event);
+ // X11 doesn't actually have native character events, but give the test
+ // what it wants.
xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event2(xevent, true);
+ ui::KeyEvent event2(xevent);
+ event2.set_character(GetCharacterFromKeyCode(event2.key_code(),
+ event2.flags()));
+ ui::KeyEventTestApi test_event2(&event2);
+ test_event2.set_is_char(true);
NativeWebKeyboardEvent char_event(&event2);
SendNativeKeyEvent(char_event);
xevent.InitKeyEvent(ui::ET_KEY_RELEASED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event3(xevent, false);
+ ui::KeyEvent event3(xevent);
NativeWebKeyboardEvent keyup_event(&event3);
SendNativeKeyEvent(keyup_event);
#elif defined(USE_OZONE)
const int flags = ConvertMockKeyboardModifier(modifiers);
- // Ozone's native events are ui::Events. So first create the "native" event,
- // then create the actual ui::KeyEvent with the native event.
- ui::KeyEvent keydown_native_event(ui::ET_KEY_PRESSED,
- static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent keydown_event(&keydown_native_event, false);
+ ui::KeyEvent keydown_event(ui::ET_KEY_PRESSED,
+ static_cast<ui::KeyboardCode>(key_code),
+ flags);
NativeWebKeyboardEvent keydown_web_event(&keydown_event);
SendNativeKeyEvent(keydown_web_event);
- ui::KeyEvent char_native_event(ui::ET_KEY_PRESSED,
- static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent char_event(&char_native_event, true);
+ ui::KeyEvent char_event(keydown_event.GetCharacter(),
+ static_cast<ui::KeyboardCode>(key_code),
+ flags);
NativeWebKeyboardEvent char_web_event(&char_event);
SendNativeKeyEvent(char_web_event);
- ui::KeyEvent keyup_native_event(ui::ET_KEY_RELEASED,
- static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent keyup_event(&keyup_native_event, false);
+ ui::KeyEvent keyup_event(ui::ET_KEY_RELEASED,
+ static_cast<ui::KeyboardCode>(key_code),
+ flags);
NativeWebKeyboardEvent keyup_web_event(&keyup_event);
SendNativeKeyEvent(keyup_web_event);
flags);
output->assign(1, static_cast<base::char16>(c));
return 1;
-#elif defined(TOOLKIT_GTK)
- // We ignore |layout|, which means we are only testing the layout of the
- // current locale. TODO(estade): fix this to respect |layout|.
- std::vector<GdkEvent*> events;
- ui::SynthesizeKeyPressEvents(
- NULL, static_cast<ui::KeyboardCode>(key_code),
- modifiers & (MockKeyboard::LEFT_CONTROL | MockKeyboard::RIGHT_CONTROL),
- modifiers & (MockKeyboard::LEFT_SHIFT | MockKeyboard::RIGHT_SHIFT),
- modifiers & (MockKeyboard::LEFT_ALT | MockKeyboard::RIGHT_ALT),
- &events);
-
- guint32 unicode_key = 0;
- for (size_t i = 0; i < events.size(); ++i) {
- // Only send the up/down events for key press itself (skip the up/down
- // events for the modifier keys).
- if ((i + 1) == (events.size() / 2) || i == (events.size() / 2)) {
- unicode_key = gdk_keyval_to_unicode(events[i]->key.keyval);
- NativeWebKeyboardEvent webkit_event(events[i]);
- SendNativeKeyEvent(webkit_event);
-
- // Need to add a char event after the key down.
- if (webkit_event.type == blink::WebInputEvent::RawKeyDown) {
- NativeWebKeyboardEvent char_event = webkit_event;
- char_event.type = blink::WebInputEvent::Char;
- char_event.skip_in_browser = true;
- SendNativeKeyEvent(char_event);
- }
- }
- gdk_event_free(events[i]);
- }
-
- output->assign(1, static_cast<base::char16>(unicode_key));
- return 1;
#else
NOTIMPLEMENTED();
return L'\0';
scoped_ptr<MockKeyboard> mock_keyboard_;
};
-} // namespace
+TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
+ const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_FALSE(msg1);
+ render_thread_->sink().ClearMessages();
+
+ const std::string image_data_url =
+ "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_TRUE(msg2);
+
+ ViewHostMsg_SaveImageFromDataURL::Param param1;
+ ViewHostMsg_SaveImageFromDataURL::Read(msg2, ¶m1);
+ EXPECT_EQ(param1.b.length(), image_data_url.length());
+ EXPECT_EQ(param1.b, image_data_url);
+
+ ProcessPendingMessages();
+ render_thread_->sink().ClearMessages();
+
+ const std::string large_data_url(1024 * 1024 * 10 - 1, 'd');
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(large_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_TRUE(msg3);
+
+ ViewHostMsg_SaveImageFromDataURL::Param param2;
+ ViewHostMsg_SaveImageFromDataURL::Read(msg3, ¶m2);
+ EXPECT_EQ(param2.b.length(), large_data_url.length());
+ EXPECT_EQ(param2.b, large_data_url);
+
+ ProcessPendingMessages();
+ render_thread_->sink().ClearMessages();
+
+ const std::string exceeded_data_url(1024 * 1024 * 10 + 1, 'd');
+
+ view()->saveImageFromDataURL(WebString::fromUTF8(exceeded_data_url));
+ ProcessPendingMessages();
+ const IPC::Message* msg4 = render_thread_->sink().GetFirstMessageMatching(
+ ViewHostMsg_SaveImageFromDataURL::ID);
+ EXPECT_FALSE(msg4);
+}
// Test that we get form state change notifications when input fields change.
TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) {
// An http url will trigger a resource load so cannot be used here.
nav_params.url = GURL("data:text/html,<div>Page</div>");
nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- nav_params.transition = PAGE_TRANSITION_TYPED;
+ nav_params.transition = ui::PAGE_TRANSITION_TYPED;
nav_params.page_id = -1;
nav_params.is_post = true;
+ nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
// Set up post data.
const unsigned char* raw_data = reinterpret_cast<const unsigned char*>(
// Check post data sent to browser matches
EXPECT_TRUE(host_nav_params.a.page_state.IsValid());
- const blink::WebHistoryItem item = PageStateToHistoryItem(
- host_nav_params.a.page_state);
- blink::WebHTTPBody body = item.httpBody();
+ scoped_ptr<HistoryEntry> entry =
+ PageStateToHistoryEntry(host_nav_params.a.page_state);
+ blink::WebHTTPBody body = entry->root().httpBody();
blink::WebHTTPBody::Element element;
bool successful = body.elementAt(0, element);
EXPECT_TRUE(successful);
// Navigations to normal HTTP URLs can be handled locally.
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy);
// Verify that form posts to WebUI URLs will be sent to the browser process.
blink::WebURLRequest form_request(GURL("chrome://foo"));
+ blink::WebFrameClient::NavigationPolicyInfo form_policy_info(form_request);
+ form_policy_info.frame = GetMainFrame();
+ form_policy_info.extraData = &state;
+ form_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted;
+ form_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
form_request.setHTTPMethod("POST");
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- form_request,
- blink::WebNavigationTypeFormSubmitted,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy = frame()->decidePolicyForNavigation(form_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that popup links to WebUI URLs also are sent to browser.
blink::WebURLRequest popup_request(GURL("chrome://foo"));
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- popup_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyNewForegroundTab,
- false);
+ blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request);
+ popup_policy_info.frame = GetMainFrame();
+ popup_policy_info.extraData = &state;
+ popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab;
+ policy = frame()->decidePolicyForNavigation(popup_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
}
};
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+
for (size_t i = 0; i < arraysize(kNavTypes); ++i) {
+ policy_info.navigationType = kNavTypes[i];
+
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- kNavTypes[i],
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
}
}
// Navigations to normal HTTP URLs will be sent to browser process.
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Navigations to WebUI URLs will also be sent to browser process.
blink::WebURLRequest webui_request(GURL("chrome://foo"));
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- webui_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ blink::WebFrameClient::NavigationPolicyInfo webui_policy_info(webui_request);
+ webui_policy_info.frame = GetMainFrame();
+ webui_policy_info.extraData = &state;
+ webui_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ webui_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+ policy = frame()->decidePolicyForNavigation(webui_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that form posts to data URLs will be sent to the browser process.
blink::WebURLRequest data_request(GURL("data:text/html,foo"));
+ blink::WebFrameClient::NavigationPolicyInfo data_policy_info(data_request);
+ data_policy_info.frame = GetMainFrame();
+ data_policy_info.extraData = &state;
+ data_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted;
+ data_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
data_request.setHTTPMethod("POST");
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- data_request,
- blink::WebNavigationTypeFormSubmitted,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy = frame()->decidePolicyForNavigation(data_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that a popup that creates a view first and then navigates to a
GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
blink::WebNavigationPolicyNewForegroundTab, false);
RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
+ blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request);
+ popup_policy_info.frame = new_web_view->mainFrame()->toWebLocalFrame();
+ popup_policy_info.extraData = &state;
+ popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab;
policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())->
- decidePolicyForNavigation(
- new_web_view->mainFrame(),
- &state,
- popup_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyNewForegroundTab,
- false);
+ decidePolicyForNavigation(popup_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Clean up after the new view so we don't leak it.
// already swapped out. http://crbug.com/93427.
TEST_F(RenderViewImplTest, SendSwapOutACK) {
LoadHTML("<div>Page A</div>");
- int initial_page_id = view()->GetPageId();
+ int initial_page_id = view_page_id();
+
+ // Increment the ref count so that we don't exit when swapping out.
+ RenderProcess::current()->AddRefProcess();
// Respond to a swap out request.
- view()->OnSwapOut();
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
// Ensure the swap out commits synchronously.
- EXPECT_NE(initial_page_id, view()->GetPageId());
+ EXPECT_NE(initial_page_id, view_page_id());
// Check for a valid OnSwapOutACK.
const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
- ViewHostMsg_SwapOut_ACK::ID);
+ FrameHostMsg_SwapOut_ACK::ID);
ASSERT_TRUE(msg);
// It is possible to get another swap out request. Ensure that we send
// an ACK, even if we don't have to do anything else.
render_thread_->sink().ClearMessages();
- view()->OnSwapOut();
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
const IPC::Message* msg2 = render_thread_->sink().GetUniqueMessageMatching(
- ViewHostMsg_SwapOut_ACK::ID);
+ FrameHostMsg_SwapOut_ACK::ID);
ASSERT_TRUE(msg2);
// If we navigate back to this RenderView, ensure we don't send a state
FrameMsg_Navigate_Params nav_params;
nav_params.url = GURL("data:text/html,<div>Page B</div>");
nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- nav_params.transition = PAGE_TRANSITION_TYPED;
+ nav_params.transition = ui::PAGE_TRANSITION_TYPED;
nav_params.current_history_list_length = 1;
nav_params.current_history_list_offset = 0;
nav_params.pending_history_list_offset = 1;
nav_params.page_id = -1;
+ nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(nav_params);
ProcessPendingMessages();
const IPC::Message* msg3 = render_thread_->sink().GetUniqueMessageMatching(
const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_A);
- int page_id_A;
- PageState state_A;
- ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
+ ViewHostMsg_UpdateState::Param params;
+ ViewHostMsg_UpdateState::Read(msg_A, ¶ms);
+ int page_id_A = params.a;
+ PageState state_A = params.b;
EXPECT_EQ(1, page_id_A);
render_thread_->sink().ClearMessages();
// Back to page A (page_id 1) and commit.
FrameMsg_Navigate_Params params_A;
params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_A.current_history_list_length = 2;
params_A.current_history_list_offset = 1;
params_A.pending_history_list_offset = 0;
params_A.page_id = 1;
params_A.page_state = state_A;
+ params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_A);
ProcessPendingMessages();
// Respond to a swap out request.
- view()->OnSwapOut();
+ view()->GetMainRenderFrame()->OnSwapOut(kProxyRoutingId);
// Check for a OnSwapOutACK.
const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
- ViewHostMsg_SwapOut_ACK::ID);
+ FrameHostMsg_SwapOut_ACK::ID);
ASSERT_TRUE(msg);
render_thread_->sink().ClearMessages();
FrameMsg_Navigate_Params nav_params;
nav_params.url = GURL("data:text/html,<div>Page A</div>");
nav_params.navigation_type = FrameMsg_Navigate_Type::RELOAD;
- nav_params.transition = PAGE_TRANSITION_RELOAD;
+ nav_params.transition = ui::PAGE_TRANSITION_RELOAD;
nav_params.current_history_list_length = 2;
nav_params.current_history_list_offset = 0;
nav_params.pending_history_list_offset = 0;
nav_params.page_id = 1;
nav_params.page_state = state_A;
+ nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(nav_params);
ProcessPendingMessages();
const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_A);
- int page_id_A;
- PageState state_A;
- ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
+ ViewHostMsg_UpdateState::Param param;
+ ViewHostMsg_UpdateState::Read(msg_A, ¶m);
+ int page_id_A = param.a;
+ PageState state_A = param.b;
EXPECT_EQ(1, page_id_A);
render_thread_->sink().ClearMessages();
const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_B);
- int page_id_B;
- PageState state_B;
- ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B);
+ ViewHostMsg_UpdateState::Read(msg_B, ¶m);
+ int page_id_B = param.a;
+ PageState state_B = param.b;
EXPECT_EQ(2, page_id_B);
EXPECT_NE(state_A, state_B);
render_thread_->sink().ClearMessages();
const IPC::Message* msg_C = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_C);
- int page_id_C;
- PageState state_C;
- ViewHostMsg_UpdateState::Read(msg_C, &page_id_C, &state_C);
+ ViewHostMsg_UpdateState::Read(msg_C, ¶m);
+ int page_id_C = param.a;
+ PageState state_C = param.b;
EXPECT_EQ(3, page_id_C);
EXPECT_NE(state_B, state_C);
render_thread_->sink().ClearMessages();
// Go back to C and commit, preparing for our real test.
FrameMsg_Navigate_Params params_C;
params_C.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_C.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_C.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_C.current_history_list_length = 4;
params_C.current_history_list_offset = 3;
params_C.pending_history_list_offset = 2;
params_C.page_id = 3;
params_C.page_state = state_C;
+ params_C.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_C);
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
// Back to page B (page_id 2), without committing.
FrameMsg_Navigate_Params params_B;
params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_B.current_history_list_length = 4;
params_B.current_history_list_offset = 2;
params_B.pending_history_list_offset = 1;
params_B.page_id = 2;
params_B.page_state = state_B;
+ params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_B);
// Back to page A (page_id 1) and commit.
FrameMsg_Navigate_Params params;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_B.current_history_list_length = 4;
params_B.current_history_list_offset = 2;
params_B.pending_history_list_offset = 0;
params.page_id = 1;
params.page_state = state_A;
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params);
ProcessPendingMessages();
const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg);
- int page_id;
- PageState state;
- ViewHostMsg_UpdateState::Read(msg, &page_id, &state);
+ ViewHostMsg_UpdateState::Read(msg, ¶m);
+ int page_id = param.a;
+ PageState state = param.b;
EXPECT_EQ(page_id_C, page_id);
EXPECT_NE(state_A, state);
EXPECT_NE(state_B, state);
const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_A);
- int page_id_A;
- PageState state_A;
- ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
+ ViewHostMsg_UpdateState::Param param;
+ ViewHostMsg_UpdateState::Read(msg_A, ¶m);
+ int page_id_A = param.a;
+ PageState state_A = param.b;
EXPECT_EQ(1, page_id_A);
render_thread_->sink().ClearMessages();
// Back to page A (page_id 1) and commit.
FrameMsg_Navigate_Params params_A;
params_A.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_A.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_A.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_A.current_history_list_length = 2;
params_A.current_history_list_offset = 1;
params_A.pending_history_list_offset = 0;
params_A.page_id = 1;
params_A.page_state = state_A;
+ params_A.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_A);
ProcessPendingMessages();
// The browser then sends a stale navigation to B, which should be ignored.
FrameMsg_Navigate_Params params_B;
params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_B.current_history_list_length = 2;
params_B.current_history_list_offset = 0;
params_B.pending_history_list_offset = 1;
params_B.page_id = 2;
params_B.page_state = state_A; // Doesn't matter, just has to be present.
+ params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_B);
// State should be unchanged.
const IPC::Message* msg_A = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_A);
- int page_id_A;
- PageState state_A;
- ViewHostMsg_UpdateState::Read(msg_A, &page_id_A, &state_A);
+ ViewHostMsg_UpdateState::Param param;
+ ViewHostMsg_UpdateState::Read(msg_A, ¶m);
+ int page_id_A = param.a;
+ PageState state_A = param.b;
EXPECT_EQ(1, page_id_A);
render_thread_->sink().ClearMessages();
const IPC::Message* msg_B = render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID);
ASSERT_TRUE(msg_B);
- int page_id_B;
- PageState state_B;
- ViewHostMsg_UpdateState::Read(msg_B, &page_id_B, &state_B);
+ ViewHostMsg_UpdateState::Read(msg_B, ¶m);
+ int page_id_B = param.a;
+ PageState state_B = param.b;
EXPECT_EQ(2, page_id_B);
render_thread_->sink().ClearMessages();
// Ensure that going back to page B (page_id 2) at offset 0 is successful.
FrameMsg_Navigate_Params params_B;
params_B.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- params_B.transition = PAGE_TRANSITION_FORWARD_BACK;
+ params_B.transition = ui::PAGE_TRANSITION_FORWARD_BACK;
params_B.current_history_list_length = 2;
params_B.current_history_list_offset = 1;
params_B.pending_history_list_offset = 0;
params_B.page_id = 2;
params_B.page_state = state_B;
+ params_B.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params_B);
ProcessPendingMessages();
// Update the IME status and verify if our IME backend sends an IPC message
// to activate IMEs.
- view()->UpdateTextInputType();
+ view()->UpdateTextInputState(
+ RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
- EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type());
- ui::TextInputType type;
- bool can_compose_inline = false;
- ui::TextInputMode input_mode = ui::TEXT_INPUT_MODE_DEFAULT;
- ViewHostMsg_TextInputTypeChanged::Read(msg,
- &type,
- &input_mode,
- &can_compose_inline);
- EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type);
- EXPECT_EQ(true, can_compose_inline);
+ EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
+ ViewHostMsg_TextInputStateChanged::Param params;
+ ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms);
+ ViewHostMsg_TextInputState_Params p = params.a;
+ EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, p.type);
+ EXPECT_EQ(true, p.can_compose_inline);
// Move the input focus to the second <input> element, where we should
// de-activate IMEs.
// Update the IME status and verify if our IME backend sends an IPC message
// to de-activate IMEs.
- view()->UpdateTextInputType();
+ view()->UpdateTextInputState(
+ RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
msg = render_thread_->sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
- EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type());
- ViewHostMsg_TextInputTypeChanged::Read(msg,
- &type,
- &input_mode,
- &can_compose_inline);
- EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type);
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInputModeTestCases); i++) {
- const InputModeTestCase* test_case = &kInputModeTestCases[i];
+ EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
+ ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms);
+ EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, params.a.type);
+
+ for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kInputModeTestCases); j++) {
+ const InputModeTestCase* test_case = &kInputModeTestCases[j];
std::string javascript =
base::StringPrintf("document.getElementById('%s').focus();",
test_case->input_id);
// Move the input focus to the target <input> element, where we should
// activate IMEs.
- ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL);
+ ExecuteJavaScript(javascript.c_str());
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
// Update the IME status and verify if our IME backend sends an IPC
// message to activate IMEs.
- view()->UpdateTextInputType();
- const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
+ view()->UpdateTextInputState(
+ RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
+ msg = render_thread_->sink().GetMessageAt(0);
EXPECT_TRUE(msg != NULL);
- EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type());
- ViewHostMsg_TextInputTypeChanged::Read(msg,
- &type,
- &input_mode,
- &can_compose_inline);
- EXPECT_EQ(test_case->expected_mode, input_mode);
+ EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
+ ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms);
+ EXPECT_EQ(test_case->expected_mode, params.a.mode);
}
}
}
case IME_SETCOMPOSITION:
view()->OnImeSetComposition(
- base::WideToUTF16Hack(ime_message->ime_string),
+ base::WideToUTF16(ime_message->ime_string),
std::vector<blink::WebCompositionUnderline>(),
ime_message->selection_start,
ime_message->selection_end);
case IME_CONFIRMCOMPOSITION:
view()->OnImeConfirmComposition(
- base::WideToUTF16Hack(ime_message->ime_string),
+ base::WideToUTF16(ime_message->ime_string),
gfx::Range::InvalidRange(),
false);
break;
// Update the status of our IME back-end.
// TODO(hbono): we should verify messages to be sent from the back-end.
- view()->UpdateTextInputType();
+ view()->UpdateTextInputState(
+ RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
// Retrieve the content of this page and compare it with the expected
// result.
const int kMaxOutputCharacters = 128;
- std::wstring output = base::UTF16ToWideHack(
- GetMainFrame()->contentAsText(kMaxOutputCharacters));
- EXPECT_EQ(output, ime_message->result);
+ base::string16 output =
+ GetMainFrame()->contentAsText(kMaxOutputCharacters);
+ EXPECT_EQ(base::WideToUTF16(ime_message->result), output);
}
}
}
// Copy the document content to std::wstring and compare with the
// expected result.
const int kMaxOutputCharacters = 16;
- std::wstring output = base::UTF16ToWideHack(
- GetMainFrame()->contentAsText(kMaxOutputCharacters));
- EXPECT_EQ(output, kTextDirection[i].expected_result);
+ base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
+ EXPECT_EQ(base::WideToUTF16(kTextDirection[i].expected_result), output);
}
}
// text created from a virtual-key code, a character code, and the
// modifier-key status.
const int kMaxOutputCharacters = 4096;
- std::wstring output = base::UTF16ToWideHack(
- GetMainFrame()->contentAsText(kMaxOutputCharacters));
- EXPECT_EQ(kLayouts[i].expected_result, output);
+ base::string16 output = GetMainFrame()->contentAsText(kMaxOutputCharacters);
+ EXPECT_EQ(base::WideToUTF16(kLayouts[i].expected_result), output);
}
#else
NOTIMPLEMENTED();
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_FILE_NOT_FOUND;
error.unreachableURL = GURL("http://foo");
- WebFrame* web_frame = GetMainFrame();
+ WebLocalFrame* web_frame = GetMainFrame();
// Start a load that will reach provisional state synchronously,
// but won't complete synchronously.
params.page_id = -1;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
params.url = GURL("data:text/html,test data");
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params);
// An error occurred.
- view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
+ view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
// Frame should exit view-source mode.
EXPECT_FALSE(web_frame->isViewSourceModeEnabled());
}
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_ABORTED;
error.unreachableURL = GURL("http://foo");
- WebFrame* web_frame = GetMainFrame();
+ WebLocalFrame* web_frame = GetMainFrame();
// Start a load that will reach provisional state synchronously,
// but won't complete synchronously.
params.page_id = -1;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
params.url = GURL("data:text/html,test data");
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params);
// A cancellation occurred.
- view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
+ view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
// Frame should stay in view-source mode.
EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
}
EXPECT_EQ(-1, view()->history_page_ids_[1]);
ClearHistory();
+ blink::WebHistoryItem item;
+ item.initialize();
+
// No history to merge and a committed page to be kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(0, expected_page_id);
EXPECT_EQ(1, view()->history_list_length_);
ClearHistory();
// No history to merge and a committed page to be pruned.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(0, expected_page_id + 1);
EXPECT_EQ(0, view()->history_list_length_);
ClearHistory();
// No history to merge and a committed page that the browser was unaware of.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(0, -1);
EXPECT_EQ(1, view()->history_list_length_);
ClearHistory();
// History to merge and a committed page to be kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(2, expected_page_id);
EXPECT_EQ(3, view()->history_list_length_);
ClearHistory();
// History to merge and a committed page to be pruned.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(2, expected_page_id + 1);
EXPECT_EQ(2, view()->history_list_length_);
ClearHistory();
// History to merge and a committed page that the browser was unaware of.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
view()->OnSetHistoryLengthAndPrune(2, -1);
EXPECT_EQ(3, view()->history_list_length_);
int expected_page_id_2 = -1;
// No history to merge and two committed pages, both to be kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(0, expected_page_id);
ClearHistory();
// No history to merge and two committed pages, and only the second is kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(0, expected_page_id_2);
// No history to merge and two committed pages, both of which the browser was
// unaware of.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(0, -1);
ClearHistory();
// History to merge and two committed pages, both to be kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(2, expected_page_id);
ClearHistory();
// History to merge and two committed pages, and only the second is kept.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(2, expected_page_id_2);
// History to merge and two committed pages, both of which the browser was
// unaware of.
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id = view()->page_id_;
- frame()->didCommitProvisionalLoad(GetMainFrame(), true);
+ frame()->didCommitProvisionalLoad(GetMainFrame(),
+ item,
+ blink::WebStandardCommit);
expected_page_id_2 = view()->page_id_;
EXPECT_GT(expected_page_id_2, expected_page_id);
view()->OnSetHistoryLengthAndPrune(2, -1);
TEST_F(RenderViewImplTest, TestBackForward) {
LoadHTML("<div id=pagename>Page A</div>");
- blink::WebHistoryItem page_a_item = GetMainFrame()->currentHistoryItem();
+ PageState page_a_state =
+ HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry());
int was_page_a = -1;
base::string16 check_page_a =
base::ASCIIToUTF16(
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
+ PageState back_state =
+ HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry());
+
LoadHTML("<div id=pagename>Page C</div>");
int was_page_c = -1;
base::string16 check_page_c =
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
EXPECT_EQ(1, was_page_b);
- blink::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem();
- GoBack(GetMainFrame()->previousHistoryItem());
+ PageState forward_state =
+ HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry());
+ GoBack(back_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
- GoForward(forward_item);
+ PageState back_state2 =
+ HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry());
+
+ GoForward(forward_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_c, &was_page_c));
EXPECT_EQ(1, was_page_c);
- GoBack(GetMainFrame()->previousHistoryItem());
+ GoBack(back_state2);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
- forward_item = GetMainFrame()->currentHistoryItem();
- GoBack(page_a_item);
+ forward_state =
+ HistoryEntryToPageState(view()->history_controller()->GetCurrentEntry());
+ GoBack(page_a_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a));
EXPECT_EQ(1, was_page_a);
- GoForward(forward_item);
+ GoForward(forward_state);
EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_b, &was_page_b));
EXPECT_EQ(1, was_page_b);
}
-#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
+#if defined(OS_MACOSX) || defined(USE_AURA)
TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
#if defined(OS_WIN)
FrameMsg_Navigate_Params params;
params.page_id = -1;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
// Verifies navigation to a URL with preset zoom level indeed sets the level.
// Regression test for http://crbug.com/139559, where the level was not
"</body>"
"</html>");
ExecuteJavaScript("document.getElementById('test1').focus();");
- view()->OnSetEditableSelectionOffsets(4, 8);
+ frame()->OnSetEditableSelectionOffsets(4, 8);
const std::vector<blink::WebCompositionUnderline> empty_underline;
- view()->OnSetCompositionFromExistingText(7, 10, empty_underline);
+ frame()->OnSetCompositionFromExistingText(7, 10, empty_underline);
blink::WebTextInputInfo info = view()->webview()->textInputInfo();
EXPECT_EQ(4, info.selectionStart);
EXPECT_EQ(8, info.selectionEnd);
EXPECT_EQ(7, info.compositionStart);
EXPECT_EQ(10, info.compositionEnd);
- view()->OnUnselect();
+ frame()->OnUnselect();
info = view()->webview()->textInputInfo();
EXPECT_EQ(0, info.selectionStart);
EXPECT_EQ(0, info.selectionEnd);
"</body>"
"</html>");
ExecuteJavaScript("document.getElementById('test1').focus();");
- view()->OnSetEditableSelectionOffsets(10, 10);
- view()->OnExtendSelectionAndDelete(3, 4);
+ frame()->OnSetEditableSelectionOffsets(10, 10);
+ frame()->OnExtendSelectionAndDelete(3, 4);
blink::WebTextInputInfo info = view()->webview()->textInputInfo();
EXPECT_EQ("abcdefgopqrstuvwxyz", info.value);
EXPECT_EQ(7, info.selectionStart);
EXPECT_EQ(7, info.selectionEnd);
- view()->OnSetEditableSelectionOffsets(4, 8);
- view()->OnExtendSelectionAndDelete(2, 5);
+ frame()->OnSetEditableSelectionOffsets(4, 8);
+ frame()->OnExtendSelectionAndDelete(2, 5);
info = view()->webview()->textInputInfo();
EXPECT_EQ("abuvwxyz", info.value);
EXPECT_EQ(2, info.selectionStart);
FrameMsg_Navigate_Params nav_params;
nav_params.url = GURL("data:text/html,world");
nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
- nav_params.transition = PAGE_TRANSITION_TYPED;
+ nav_params.transition = ui::PAGE_TRANSITION_TYPED;
nav_params.current_history_list_length = 1;
nav_params.current_history_list_offset = 0;
nav_params.pending_history_list_offset = 1;
nav_params.page_id = -1;
nav_params.frame_to_navigate = "frame";
+ nav_params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(nav_params);
- ProcessPendingMessages();
+ FrameLoadWaiter(
+ RenderFrame::FromWebFrame(frame()->GetWebFrame()->firstChild())).Wait();
// Copy the document content to std::wstring and compare with the
// expected result.
const int kMaxOutputCharacters = 256;
- std::wstring output = base::UTF16ToWideHack(
+ std::string output = base::UTF16ToUTF8(
GetMainFrame()->contentAsText(kMaxOutputCharacters));
- EXPECT_EQ(output, L"hello \n\nworld");
+ EXPECT_EQ(output, "hello \n\nworld");
}
// This test ensures that a RenderFrame object is created for the top level
TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
LoadHTML("<!DOCTYPE html><html><body></body></html>");
- WebFrame* frame = GetMainFrame();
+ WebLocalFrame* frame = GetMainFrame();
SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame);
EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status));
for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
const uint32 type = render_thread_->sink().GetMessageAt(i)->type();
- if (type == ViewHostMsg_TextInputTypeChanged::ID) {
+ if (type == ViewHostMsg_TextInputStateChanged::ID) {
is_input_type_called = true;
last_input_type = i;
} else if (type == ViewHostMsg_SelectionChanged::ID) {
class SuppressErrorPageTest : public RenderViewTest {
public:
- virtual void SetUp() OVERRIDE {
- SetRendererClientForTesting(&client_);
- RenderViewTest::SetUp();
+ virtual ContentRendererClient* CreateContentRendererClient() OVERRIDE {
+ return new TestContentRendererClient;
}
RenderViewImpl* view() {
*error_html = "A suffusion of yellow.";
}
};
-
- TestContentRendererClient client_;
};
#if defined(OS_ANDROID)
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_FILE_NOT_FOUND;
error.unreachableURL = GURL("http://example.com/suppress");
- WebFrame* web_frame = GetMainFrame();
+ WebLocalFrame* web_frame = GetMainFrame();
// Start a load that will reach provisional state synchronously,
// but won't complete synchronously.
params.page_id = -1;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
params.url = GURL("data:text/html,test data");
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params);
// An error occurred.
- view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
+ view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
const int kMaxOutputCharacters = 22;
- EXPECT_EQ("", UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
+ EXPECT_EQ("",
+ base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
}
#if defined(OS_ANDROID)
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_FILE_NOT_FOUND;
error.unreachableURL = GURL("http://example.com/dont-suppress");
- WebFrame* web_frame = GetMainFrame();
+ WebLocalFrame* web_frame = GetMainFrame();
// Start a load that will reach provisional state synchronously,
// but won't complete synchronously.
params.page_id = -1;
params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
params.url = GURL("data:text/html,test data");
+ params.browser_navigation_start = base::TimeTicks::FromInternalValue(1);
frame()->OnNavigate(params);
// An error occurred.
- view()->main_render_frame()->didFailProvisionalLoad(web_frame, error);
- ProcessPendingMessages();
+ view()->GetMainRenderFrame()->didFailProvisionalLoad(web_frame, error);
+ // The error page itself is loaded asynchronously.
+ FrameLoadWaiter(frame()).Wait();
const int kMaxOutputCharacters = 22;
EXPECT_EQ("A suffusion of yellow.",
- UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
+ base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
}
// Tests if IME API's candidatewindow* events sent from browser are handled
EXPECT_TRUE(params.a);
render_thread_->sink().ClearMessages();
- view()->webview()->clearFocusedNode();
+ view()->webview()->clearFocusedElement();
const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching(
ViewHostMsg_FocusedNodeChanged::ID);
EXPECT_TRUE(msg3);
render_thread_->sink().ClearMessages();
}
+TEST_F(RenderViewImplTest, ServiceWorkerNetworkProviderSetup) {
+ ServiceWorkerNetworkProvider* provider = NULL;
+ RequestExtraData* extra_data = NULL;
+
+ // Make sure each new document has a new provider and
+ // that the main request is tagged with the provider's id.
+ LoadHTML("<b>A Document</b>");
+ ASSERT_TRUE(GetMainFrame()->dataSource());
+ provider = ServiceWorkerNetworkProvider::FromDocumentState(
+ DocumentState::FromDataSource(GetMainFrame()->dataSource()));
+ ASSERT_TRUE(provider);
+ extra_data = static_cast<RequestExtraData*>(
+ GetMainFrame()->dataSource()->request().extraData());
+ ASSERT_TRUE(extra_data);
+ EXPECT_EQ(extra_data->service_worker_provider_id(),
+ provider->provider_id());
+ int provider1_id = provider->provider_id();
+
+ LoadHTML("<b>New Document B Goes Here</b>");
+ ASSERT_TRUE(GetMainFrame()->dataSource());
+ provider = ServiceWorkerNetworkProvider::FromDocumentState(
+ DocumentState::FromDataSource(GetMainFrame()->dataSource()));
+ ASSERT_TRUE(provider);
+ EXPECT_NE(provider1_id, provider->provider_id());
+ extra_data = static_cast<RequestExtraData*>(
+ GetMainFrame()->dataSource()->request().extraData());
+ ASSERT_TRUE(extra_data);
+ EXPECT_EQ(extra_data->service_worker_provider_id(),
+ provider->provider_id());
+
+ // See that subresource requests are also tagged with the provider's id.
+ EXPECT_EQ(frame(), RenderFrameImpl::FromWebFrame(GetMainFrame()));
+ blink::WebURLRequest request(GURL("http://foo.com"));
+ request.setRequestContext(blink::WebURLRequest::RequestContextSubresource);
+ blink::WebURLResponse redirect_response;
+ frame()->willSendRequest(GetMainFrame(), 0, request, redirect_response);
+ extra_data = static_cast<RequestExtraData*>(request.extraData());
+ ASSERT_TRUE(extra_data);
+ EXPECT_EQ(extra_data->service_worker_provider_id(),
+ provider->provider_id());
+}
+
+TEST_F(RenderViewImplTest, OnSetAccessibilityMode) {
+ ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode());
+ ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility());
+
+ frame()->OnSetAccessibilityMode(AccessibilityModeTreeOnly);
+ ASSERT_EQ(AccessibilityModeTreeOnly, frame()->accessibility_mode());
+ ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility());
+ ASSERT_EQ(RendererAccessibilityTypeComplete,
+ frame()->renderer_accessibility()->GetType());
+
+ frame()->OnSetAccessibilityMode(AccessibilityModeOff);
+ ASSERT_EQ(AccessibilityModeOff, frame()->accessibility_mode());
+ ASSERT_EQ((RendererAccessibility*) NULL, frame()->renderer_accessibility());
+
+ frame()->OnSetAccessibilityMode(AccessibilityModeComplete);
+ ASSERT_EQ(AccessibilityModeComplete, frame()->accessibility_mode());
+ ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility());
+ ASSERT_EQ(RendererAccessibilityTypeComplete,
+ frame()->renderer_accessibility()->GetType());
+
+ frame()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly);
+ ASSERT_EQ(AccessibilityModeEditableTextOnly, frame()->accessibility_mode());
+ ASSERT_NE((RendererAccessibility*) NULL, frame()->renderer_accessibility());
+ ASSERT_EQ(RendererAccessibilityTypeFocusOnly,
+ frame()->renderer_accessibility()->GetType());
+}
+
+TEST_F(RenderViewImplTest, ScreenMetricsEmulation) {
+ LoadHTML("<body style='min-height:1000px;'></body>");
+
+ blink::WebDeviceEmulationParams params;
+ base::string16 get_width = base::ASCIIToUTF16("Number(window.innerWidth)");
+ base::string16 get_height = base::ASCIIToUTF16("Number(window.innerHeight)");
+ int width, height;
+
+ params.viewSize.width = 327;
+ params.viewSize.height = 415;
+ view()->EnableScreenMetricsEmulation(params);
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width));
+ EXPECT_EQ(params.viewSize.width, width);
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height));
+ EXPECT_EQ(params.viewSize.height, height);
+
+ params.viewSize.width = 1005;
+ params.viewSize.height = 1102;
+ view()->EnableScreenMetricsEmulation(params);
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width));
+ EXPECT_EQ(params.viewSize.width, width);
+ EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height));
+ EXPECT_EQ(params.viewSize.height, height);
+
+ view()->DisableScreenMetricsEmulation();
+
+ view()->EnableScreenMetricsEmulation(params);
+ // Don't disable here to test that emulation is being shutdown properly.
+}
+
+// Sanity checks for the Navigation Timing API |navigationStart| override. We
+// are asserting only most basic constraints, as TimeTicks (passed as the
+// override) are not comparable with the wall time (returned by the Blink API).
+TEST_F(RenderViewImplTest, NavigationStartOverride) {
+ // Verify that a navigation that claims to have started at the earliest
+ // possible TimeTicks is indeed reported as one that started before
+ // OnNavigate() is called.
+ base::Time before_navigation = base::Time::Now();
+ FrameMsg_Navigate_Params early_nav_params;
+ early_nav_params.url = GURL("data:text/html,<div>Page</div>");
+ early_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
+ early_nav_params.transition = ui::PAGE_TRANSITION_TYPED;
+ early_nav_params.page_id = -1;
+ early_nav_params.is_post = true;
+ early_nav_params.browser_navigation_start =
+ base::TimeTicks::FromInternalValue(1);
+
+ frame()->OnNavigate(early_nav_params);
+ ProcessPendingMessages();
+
+ base::Time early_nav_reported_start =
+ base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
+ EXPECT_LT(early_nav_reported_start, before_navigation);
+
+ // Verify that a navigation that claims to have started in the future - 42
+ // days from now is *not* reported as one that starts in the future; as we
+ // sanitize the override allowing a maximum of ::Now().
+ FrameMsg_Navigate_Params late_nav_params;
+ late_nav_params.url = GURL("data:text/html,<div>Another page</div>");
+ late_nav_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
+ late_nav_params.transition = ui::PAGE_TRANSITION_TYPED;
+ late_nav_params.page_id = -1;
+ late_nav_params.is_post = true;
+ late_nav_params.browser_navigation_start =
+ base::TimeTicks::Now() + base::TimeDelta::FromDays(42);
+
+ frame()->OnNavigate(late_nav_params);
+ ProcessPendingMessages();
+ base::Time after_navigation =
+ base::Time::Now() + base::TimeDelta::FromDays(1);
+
+ base::Time late_nav_reported_start =
+ base::Time::FromDoubleT(GetMainFrame()->performance().navigationStart());
+ EXPECT_LE(late_nav_reported_start, after_navigation);
+}
+
} // namespace content