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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index a1d362d4c7bab21be70679b83a985373395505eb..eeeded43bc16224ffc8b47190a38d885187ccc18 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -427,7 +427,8 @@ TEST_F(RenderViewImplTest, DISABLED_OnNavStateChanged) {
// Change the value of the input. We should have gotten an update state
// notification. We need to spin the message loop to catch this update.
- ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';");
+ ExecuteJavaScriptForTests(
+ "document.getElementById('elt_text').value = 'foo';");
ProcessPendingMessages();
EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
ViewHostMsg_UpdateState::ID));
@@ -966,7 +967,7 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
for (int i = 0; i < kRepeatCount; i++) {
// Move the input focus to the first <input> element, where we should
// activate IMEs.
- ExecuteJavaScript("document.getElementById('test1').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
@@ -986,7 +987,7 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
// Move the input focus to the second <input> element, where we should
// de-activate IMEs.
- ExecuteJavaScript("document.getElementById('test2').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
ProcessPendingMessages();
render_thread_->sink().ClearMessages();
@@ -1036,7 +1037,7 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) {
// the window focus while composing a CJK text. To handle such complicated
// cases, this test should not only call IME-related functions in the
// RenderWidget class, but also call some RenderWidget members, e.g.
-// ExecuteJavaScript(), RenderWidget::OnSetFocus(), etc.
+// ExecuteJavaScriptForTests(), RenderWidget::OnSetFocus(), etc.
TEST_F(RenderViewImplTest, ImeComposition) {
enum ImeCommand {
IME_INITIALIZE,
@@ -1112,7 +1113,7 @@ TEST_F(RenderViewImplTest, ImeComposition) {
"<div id=\"test1\" contenteditable=\"true\"></div>"
"</body>"
"</html>");
- ExecuteJavaScript("document.getElementById('test1').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
break;
case IME_SETINPUTMODE:
@@ -1192,17 +1193,18 @@ TEST_F(RenderViewImplTest, OnSetTextDirection) {
};
for (size_t i = 0; i < arraysize(kTextDirection); ++i) {
// Set the text direction of the <textarea> element.
- ExecuteJavaScript("document.getElementById('test').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test').focus();");
view()->OnSetTextDirection(kTextDirection[i].direction);
// Write the values of its DOM 'dir' attribute and its CSS 'direction'
// property to the <div> element.
- ExecuteJavaScript("var result = document.getElementById('result');"
- "var node = document.getElementById('test');"
- "var style = getComputedStyle(node, null);"
- "result.innerText ="
- " node.getAttribute('dir') + ',' +"
- " style.getPropertyValue('direction');");
+ ExecuteJavaScriptForTests(
+ "var result = document.getElementById('result');"
+ "var node = document.getElementById('test');"
+ "var style = getComputedStyle(node, null);"
+ "result.innerText ="
+ " node.getAttribute('dir') + ',' +"
+ " style.getPropertyValue('direction');");
// Copy the document content to std::wstring and compare with the
// expected result.
@@ -1254,7 +1256,7 @@ TEST_F(RenderViewImplTest, OnHandleKeyboardEvent) {
"</div>"
"</body>"
"</html>");
- ExecuteJavaScript("document.getElementById('test').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test').focus();");
render_thread_->sink().ClearMessages();
static const MockKeyboard::Layout kLayouts[] = {
@@ -1521,7 +1523,7 @@ TEST_F(RenderViewImplTest, MAYBE_InsertCharacters) {
"</div>"
"</body>"
"</html>");
- ExecuteJavaScript("document.getElementById('test').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test').focus();");
render_thread_->sink().ClearMessages();
// For each key code, we send three keyboard events.
@@ -1744,7 +1746,7 @@ TEST_F(RenderViewImplTest, GetCompositionCharacterBoundsTest) {
#endif
LoadHTML("<textarea id=\"test\"></textarea>");
- ExecuteJavaScript("document.getElementById('test').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test').focus();");
const base::string16 empty_string;
const std::vector<blink::WebCompositionUnderline> empty_underline;
@@ -1847,7 +1849,7 @@ TEST_F(RenderViewImplTest, SetEditableSelectionAndComposition) {
"<input id=\"test1\" value=\"some test text hello\"></input>"
"</body>"
"</html>");
- ExecuteJavaScript("document.getElementById('test1').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
frame()->SetEditableSelectionOffsets(4, 8);
const std::vector<blink::WebCompositionUnderline> empty_underline;
frame()->SetCompositionFromExistingText(7, 10, empty_underline);
@@ -1872,7 +1874,7 @@ TEST_F(RenderViewImplTest, OnExtendSelectionAndDelete) {
"<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
"</body>"
"</html>");
- ExecuteJavaScript("document.getElementById('test1').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
frame()->SetEditableSelectionOffsets(10, 10);
frame()->ExtendSelectionAndDelete(3, 4);
blink::WebTextInputInfo info = view()->webview()->textInputInfo();
@@ -1946,7 +1948,7 @@ TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
LoadHTML("<textarea id=\"test\"></textarea>");
view()->handling_input_event_ = true;
- ExecuteJavaScript("document.getElementById('test').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test').focus();");
bool is_input_type_called = false;
bool is_selection_called = false;
@@ -2096,7 +2098,7 @@ TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) {
LoadHTML("<input id='test1' value='hello1'></input>"
"<input id='test2' value='hello2'></input>");
- ExecuteJavaScript("document.getElementById('test1').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
ViewHostMsg_FocusedNodeChanged::ID);
EXPECT_TRUE(msg1);
@@ -2106,7 +2108,7 @@ TEST_F(RenderViewImplTest, FocusElementCallsFocusedNodeChanged) {
EXPECT_TRUE(base::get<0>(params));
render_thread_->sink().ClearMessages();
- ExecuteJavaScript("document.getElementById('test2').focus();");
+ ExecuteJavaScriptForTests("document.getElementById('test2').focus();");
const IPC::Message* msg2 = render_thread_->sink().GetFirstMessageMatching(
ViewHostMsg_FocusedNodeChanged::ID);
EXPECT_TRUE(msg2);
@@ -2321,7 +2323,7 @@ TEST_F(DevToolsAgentTest, DevToolsResumeOnClose) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
- ExecuteJavaScript("debugger;");
+ ExecuteJavaScriptForTests("debugger;");
// CloseWhilePaused should resume execution and continue here.
EXPECT_FALSE(IsPaused());

Powered by Google App Engine
This is Rietveld 408576698