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

Side by Side Diff: ios/web/web_state/js/core_js_unittest.mm

Issue 2814773002: Move password-related methods from core.js to password_controller.js. (Closed)
Patch Set: Address reviewer comment (fix verb tense in test comment) Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « ios/web/BUILD.gn ('k') | ios/web/web_state/js/resources/core.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <vector>
6
7 #include "base/macros.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/strings/sys_string_conversions.h"
10 #import "ios/web/public/test/web_test_with_web_state.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/gtest_mac.h"
13
14 // Unit tests for ios/web/web_state/js/resources/core.js.
15
16 namespace web {
17
18 // Test fixture to test core.js.
19 typedef web::WebTestWithWebState CoreJsTest;
20
21 struct TestDataForPasswordFormDetection {
22 NSString* pageContent;
23 NSNumber* containsPassword;
24 };
25
26 TEST_F(CoreJsTest, HasPasswordField) {
27 TestDataForPasswordFormDetection testData[] = {
28 // Form without a password field.
29 {@"<form><input type='text' name='password'></form>", @NO},
30 // Form with a password field.
31 {@"<form><input type='password' name='password'></form>", @YES}};
32 for (size_t i = 0; i < arraysize(testData); i++) {
33 TestDataForPasswordFormDetection& data = testData[i];
34 LoadHtml(data.pageContent);
35 id result = ExecuteJavaScript(@"__gCrWeb.hasPasswordField()");
36 EXPECT_NSEQ(data.containsPassword, result)
37 << " in test " << i << ": "
38 << base::SysNSStringToUTF8(data.pageContent);
39 }
40 }
41
42 TEST_F(CoreJsTest, HasPasswordFieldinFrame) {
43 TestDataForPasswordFormDetection data = {
44 // Form with a password field in a nested iframe.
45 @"<iframe name='pf'></iframe>"
46 "<script>"
47 " var doc = frames['pf'].document.open();"
48 " doc.write('<form><input type=\\'password\\'></form>');"
49 " doc.close();"
50 "</script>",
51 @YES
52 };
53 LoadHtml(data.pageContent);
54 id result = ExecuteJavaScript(@"__gCrWeb.hasPasswordField()");
55 EXPECT_NSEQ(data.containsPassword, result)
56 << base::SysNSStringToUTF8(data.pageContent);
57 }
58
59 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/BUILD.gn ('k') | ios/web/web_state/js/resources/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698