Commit a92d5af6 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Integration tests for form.js.

Bug: 554927
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id61ca6746d9ecacbb6e3787f7afa7f662e89d1fd
Reviewed-on: https://chromium-review.googlesource.com/816020
Commit-Queue: Eugene But <eugenebut@chromium.org>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523310}
parent 935caae0
......@@ -559,6 +559,7 @@ test("ios_web_inttests") {
"test/run_all_unittests.cc",
"web_state/favicon_callbacks_inttest.mm",
"web_state/http_auth_inttest.mm",
"web_state/js/form_inttest.mm",
"web_state/navigation_and_load_callbacks_inttest.mm",
"webui/web_ui_mojo_inttest.mm",
]
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/web/public/test/fakes/test_web_state_observer.h"
#import "ios/web/public/test/web_test_with_web_state.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace web {
using FormJsTest = WebTestWithWebState;
// Tests that keyup event correctly delivered to WebStateObserver.
TEST_F(FormJsTest, KeyUpEvent) {
TestWebStateObserver observer(web_state());
LoadHtml(@"<p></p>");
ASSERT_FALSE(observer.form_activity_info());
ExecuteJavaScript(@"document.dispatchEvent(new KeyboardEvent('keyup'));");
TestFormActivityInfo* info = observer.form_activity_info();
ASSERT_TRUE(info);
EXPECT_EQ("keyup", info->form_activity.type);
EXPECT_FALSE(info->form_activity.input_missing);
}
// Tests that focus event correctly delivered to WebStateObserver.
TEST_F(FormJsTest, FocusMainFrame) {
TestWebStateObserver observer(web_state());
LoadHtml(
@"<form>"
"<input type='text' name='username' id='id1'>"
"<input type='password' name='password' id='id2'>"
"</form>");
ASSERT_FALSE(observer.form_activity_info());
ExecuteJavaScript(@"document.getElementById('id1').focus();");
TestFormActivityInfo* info = observer.form_activity_info();
ASSERT_TRUE(info);
EXPECT_EQ("focus", info->form_activity.type);
EXPECT_FALSE(info->form_activity.input_missing);
}
// Tests that submit event correctly delivered to WebStateObserver.
TEST_F(FormJsTest, FormSubmitMainFrame) {
TestWebStateObserver observer(web_state());
LoadHtml(
@"<form id='form1'>"
"<input type='password'>"
"<input type='submit' id='submit_input'/>"
"</form>");
ASSERT_FALSE(observer.submit_document_info());
ExecuteJavaScript(@"document.getElementById('submit_input').click();");
TestSubmitDocumentInfo* info = observer.submit_document_info();
ASSERT_TRUE(info);
EXPECT_EQ("form1", info->form_name);
}
} // namespace web
......@@ -502,21 +502,6 @@ TEST_F(CRWWebControllerInvalidUrlTest, IFrameWithInvalidURL) {
EXPECT_EQ(url, web_state()->GetLastCommittedURL());
}
// Real WKWebView is required for CRWWebControllerFormActivityTest.
typedef WebTestWithWebState CRWWebControllerFormActivityTest;
// Tests that keyup event correctly delivered to WebStateObserver.
TEST_F(CRWWebControllerFormActivityTest, KeyUpEvent) {
TestWebStateObserver observer(web_state());
LoadHtml(@"<p></p>");
ASSERT_FALSE(observer.form_activity_info());
ExecuteJavaScript(@"document.dispatchEvent(new KeyboardEvent('keyup'));");
TestFormActivityInfo* info = observer.form_activity_info();
ASSERT_TRUE(info);
EXPECT_EQ("keyup", info->form_activity.type);
EXPECT_FALSE(info->form_activity.input_missing);
}
// Real WKWebView is required for CRWWebControllerJSExecutionTest.
typedef WebTestWithWebController CRWWebControllerJSExecutionTest;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment