| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
| 10 #include "chrome/renderer/autofill/password_generation_test_utils.h" | 10 #include "chrome/renderer/autofill/password_generation_test_utils.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 class PasswordGenerationAgentTest : public ChromeRenderViewTest { | 32 class PasswordGenerationAgentTest : public ChromeRenderViewTest { |
| 33 public: | 33 public: |
| 34 PasswordGenerationAgentTest() {} | 34 PasswordGenerationAgentTest() {} |
| 35 | 35 |
| 36 void TearDown() override { | 36 void TearDown() override { |
| 37 LoadHTML(""); | 37 LoadHTML(""); |
| 38 ChromeRenderViewTest::TearDown(); | 38 ChromeRenderViewTest::TearDown(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ExpectPasswordGenerationAvailable(const char* element_id, | |
| 42 bool available) { | |
| 43 WebDocument document = GetMainFrame()->document(); | |
| 44 WebElement element = | |
| 45 document.getElementById(WebString::fromUTF8(element_id)); | |
| 46 ASSERT_FALSE(element.isNull()); | |
| 47 ExecuteJavaScript( | |
| 48 base::StringPrintf("document.getElementById('%s').focus();", | |
| 49 element_id).c_str()); | |
| 50 if (available) { | |
| 51 ASSERT_EQ(1u, password_generation_->messages().size()); | |
| 52 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, | |
| 53 password_generation_->messages()[0]->type()); | |
| 54 } else { | |
| 55 EXPECT_EQ(0u, password_generation_->messages().size()); | |
| 56 } | |
| 57 password_generation_->clear_messages(); | |
| 58 } | |
| 59 | |
| 60 void LoadHTMLWithUserGesture(const char* html) { | 41 void LoadHTMLWithUserGesture(const char* html) { |
| 61 LoadHTML(html); | 42 LoadHTML(html); |
| 62 | 43 |
| 63 // Enable show-ime event when element is focused by indicating that a user | 44 // Enable show-ime event when element is focused by indicating that a user |
| 64 // gesture has been processed since load. | 45 // gesture has been processed since load. |
| 65 EXPECT_TRUE(SimulateElementClick("dummy")); | 46 EXPECT_TRUE(SimulateElementClick("dummy")); |
| 66 } | 47 } |
| 67 | 48 |
| 49 void FocusField(const char* element_id) { |
| 50 WebDocument document = GetMainFrame()->document(); |
| 51 blink::WebElement element = |
| 52 document.getElementById(blink::WebString::fromUTF8(element_id)); |
| 53 ASSERT_FALSE(element.isNull()); |
| 54 ExecuteJavaScript( |
| 55 base::StringPrintf("document.getElementById('%s').focus();", |
| 56 element_id).c_str()); |
| 57 } |
| 58 |
| 59 void ExpectGenerationAvailable(const char* element_id, |
| 60 bool available) { |
| 61 FocusField(element_id); |
| 62 ExpectPasswordGenerationAvailable(password_generation_, |
| 63 available); |
| 64 } |
| 65 |
| 68 private: | 66 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest); | 67 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgentTest); |
| 70 }; | 68 }; |
| 71 | 69 |
| 72 const char kSigninFormHTML[] = | 70 const char kSigninFormHTML[] = |
| 73 "<FORM name = 'blah' action = 'http://www.random.com/'> " | 71 "<FORM name = 'blah' action = 'http://www.random.com/'> " |
| 74 " <INPUT type = 'text' id = 'username'/> " | 72 " <INPUT type = 'text' id = 'username'/> " |
| 75 " <INPUT type = 'password' id = 'password'/> " | 73 " <INPUT type = 'password' id = 'password'/> " |
| 76 " <INPUT type = 'button' id = 'dummy'/> " | 74 " <INPUT type = 'button' id = 'dummy'/> " |
| 77 " <INPUT type = 'submit' value = 'LOGIN' />" | 75 " <INPUT type = 'submit' value = 'LOGIN' />" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 " firstOnChangeCalled = true;" | 170 " firstOnChangeCalled = true;" |
| 173 " };" | 171 " };" |
| 174 " document.getElementById('second_password').onchange = function() {" | 172 " document.getElementById('second_password').onchange = function() {" |
| 175 " secondOnChangeCalled = true;" | 173 " secondOnChangeCalled = true;" |
| 176 " };" | 174 " };" |
| 177 "</script>"; | 175 "</script>"; |
| 178 | 176 |
| 179 TEST_F(PasswordGenerationAgentTest, DetectionTest) { | 177 TEST_F(PasswordGenerationAgentTest, DetectionTest) { |
| 180 // Don't shown the icon for non account creation forms. | 178 // Don't shown the icon for non account creation forms. |
| 181 LoadHTMLWithUserGesture(kSigninFormHTML); | 179 LoadHTMLWithUserGesture(kSigninFormHTML); |
| 182 ExpectPasswordGenerationAvailable("password", false); | 180 ExpectGenerationAvailable("password", false); |
| 183 | 181 |
| 184 // We don't show the decoration yet because the feature isn't enabled. | 182 // We don't show the decoration yet because the feature isn't enabled. |
| 185 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 183 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 186 ExpectPasswordGenerationAvailable("first_password", false); | 184 ExpectGenerationAvailable("first_password", false); |
| 187 | 185 |
| 188 // Pretend like We have received message indicating site is not blacklisted, | 186 // Pretend like We have received message indicating site is not blacklisted, |
| 189 // and we have received message indicating the form is classified as | 187 // and we have received message indicating the form is classified as |
| 190 // ACCOUNT_CREATION_FORM form Autofill server. We should show the icon. | 188 // ACCOUNT_CREATION_FORM form Autofill server. We should show the icon. |
| 191 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 189 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 192 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 190 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 193 SetAccountCreationFormsDetectedMessage(password_generation_, | 191 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 194 GetMainFrame()->document(), | 192 GetMainFrame()->document(), |
| 195 0); | 193 0); |
| 196 ExpectPasswordGenerationAvailable("first_password", true); | 194 ExpectGenerationAvailable("first_password", true); |
| 197 | 195 |
| 198 // Hidden fields are not treated differently. | 196 // Hidden fields are not treated differently. |
| 199 LoadHTMLWithUserGesture(kHiddenPasswordAccountCreationFormHTML); | 197 LoadHTMLWithUserGesture(kHiddenPasswordAccountCreationFormHTML); |
| 200 SetNotBlacklistedMessage(password_generation_, | 198 SetNotBlacklistedMessage(password_generation_, |
| 201 kHiddenPasswordAccountCreationFormHTML); | 199 kHiddenPasswordAccountCreationFormHTML); |
| 202 SetAccountCreationFormsDetectedMessage(password_generation_, | 200 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 203 GetMainFrame()->document(), | 201 GetMainFrame()->document(), |
| 204 0); | 202 0); |
| 205 ExpectPasswordGenerationAvailable("first_password", true); | 203 ExpectGenerationAvailable("first_password", true); |
| 206 | 204 |
| 207 // This doesn't trigger because the form action is invalid. | 205 // This doesn't trigger because the form action is invalid. |
| 208 LoadHTMLWithUserGesture(kInvalidActionAccountCreationFormHTML); | 206 LoadHTMLWithUserGesture(kInvalidActionAccountCreationFormHTML); |
| 209 SetNotBlacklistedMessage(password_generation_, | 207 SetNotBlacklistedMessage(password_generation_, |
| 210 kInvalidActionAccountCreationFormHTML); | 208 kInvalidActionAccountCreationFormHTML); |
| 211 SetAccountCreationFormsDetectedMessage(password_generation_, | 209 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 212 GetMainFrame()->document(), | 210 GetMainFrame()->document(), |
| 213 0); | 211 0); |
| 214 ExpectPasswordGenerationAvailable("first_password", false); | 212 ExpectGenerationAvailable("first_password", false); |
| 215 } | 213 } |
| 216 | 214 |
| 217 TEST_F(PasswordGenerationAgentTest, FillTest) { | 215 TEST_F(PasswordGenerationAgentTest, FillTest) { |
| 218 // Make sure that we are enabled before loading HTML. | 216 // Make sure that we are enabled before loading HTML. |
| 219 std::string html = std::string(kAccountCreationFormHTML) + | 217 std::string html = std::string(kAccountCreationFormHTML) + |
| 220 ChangeDetectionScript; | 218 ChangeDetectionScript; |
| 221 LoadHTMLWithUserGesture(html.c_str()); | 219 LoadHTMLWithUserGesture(html.c_str()); |
| 222 SetNotBlacklistedMessage(password_generation_, html.c_str()); | 220 SetNotBlacklistedMessage(password_generation_, html.c_str()); |
| 223 SetAccountCreationFormsDetectedMessage(password_generation_, | 221 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 224 GetMainFrame()->document(), | 222 GetMainFrame()->document(), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 password_generation_->messages()[1]->type()); | 317 password_generation_->messages()[1]->type()); |
| 320 } | 318 } |
| 321 | 319 |
| 322 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { | 320 TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { |
| 323 // Did not receive not blacklisted message. Don't show password generation | 321 // Did not receive not blacklisted message. Don't show password generation |
| 324 // icon. | 322 // icon. |
| 325 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 323 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 326 SetAccountCreationFormsDetectedMessage(password_generation_, | 324 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 327 GetMainFrame()->document(), | 325 GetMainFrame()->document(), |
| 328 0); | 326 0); |
| 329 ExpectPasswordGenerationAvailable("first_password", false); | 327 ExpectGenerationAvailable("first_password", false); |
| 330 | 328 |
| 331 // Receive one not blacklisted message for non account creation form. Don't | 329 // Receive one not blacklisted message for non account creation form. Don't |
| 332 // show password generation icon. | 330 // show password generation icon. |
| 333 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 331 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 334 SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); | 332 SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); |
| 335 SetAccountCreationFormsDetectedMessage(password_generation_, | 333 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 336 GetMainFrame()->document(), | 334 GetMainFrame()->document(), |
| 337 0); | 335 0); |
| 338 ExpectPasswordGenerationAvailable("first_password", false); | 336 ExpectGenerationAvailable("first_password", false); |
| 339 | 337 |
| 340 // Receive one not blacklisted message for account creation form. Show | 338 // Receive one not blacklisted message for account creation form. Show |
| 341 // password generation icon. | 339 // password generation icon. |
| 342 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 340 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 343 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 341 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 344 SetAccountCreationFormsDetectedMessage(password_generation_, | 342 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 345 GetMainFrame()->document(), | 343 GetMainFrame()->document(), |
| 346 0); | 344 0); |
| 347 ExpectPasswordGenerationAvailable("first_password", true); | 345 ExpectGenerationAvailable("first_password", true); |
| 348 | 346 |
| 349 // Receive two not blacklisted messages, one is for account creation form and | 347 // Receive two not blacklisted messages, one is for account creation form and |
| 350 // the other is not. Show password generation icon. | 348 // the other is not. Show password generation icon. |
| 351 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 349 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 352 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 350 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 353 SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); | 351 SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); |
| 354 SetAccountCreationFormsDetectedMessage(password_generation_, | 352 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 355 GetMainFrame()->document(), | 353 GetMainFrame()->document(), |
| 356 0); | 354 0); |
| 357 ExpectPasswordGenerationAvailable("first_password", true); | 355 ExpectGenerationAvailable("first_password", true); |
| 358 } | 356 } |
| 359 | 357 |
| 360 TEST_F(PasswordGenerationAgentTest, AccountCreationFormsDetectedTest) { | 358 TEST_F(PasswordGenerationAgentTest, AccountCreationFormsDetectedTest) { |
| 361 // Did not receive account creation forms detected message. Don't show | 359 // Did not receive account creation forms detected message. Don't show |
| 362 // password generation icon. | 360 // password generation icon. |
| 363 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 361 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 364 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 362 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 365 ExpectPasswordGenerationAvailable("first_password", false); | 363 ExpectGenerationAvailable("first_password", false); |
| 366 | 364 |
| 367 // Receive the account creation forms detected message. Show password | 365 // Receive the account creation forms detected message. Show password |
| 368 // generation icon. | 366 // generation icon. |
| 369 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 367 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 370 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 368 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 371 SetAccountCreationFormsDetectedMessage(password_generation_, | 369 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 372 GetMainFrame()->document(), | 370 GetMainFrame()->document(), |
| 373 0); | 371 0); |
| 374 ExpectPasswordGenerationAvailable("first_password", true); | 372 ExpectGenerationAvailable("first_password", true); |
| 375 } | 373 } |
| 376 | 374 |
| 377 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) { | 375 TEST_F(PasswordGenerationAgentTest, MaximumOfferSize) { |
| 378 base::HistogramTester histogram_tester; | 376 base::HistogramTester histogram_tester; |
| 379 | 377 |
| 380 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 378 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 381 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 379 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 382 SetAccountCreationFormsDetectedMessage(password_generation_, | 380 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 383 GetMainFrame()->document(), | 381 GetMainFrame()->document(), |
| 384 0); | 382 0); |
| 385 ExpectPasswordGenerationAvailable("first_password", true); | 383 ExpectGenerationAvailable("first_password", true); |
| 386 | 384 |
| 387 WebDocument document = GetMainFrame()->document(); | 385 WebDocument document = GetMainFrame()->document(); |
| 388 WebElement element = | 386 WebElement element = |
| 389 document.getElementById(WebString::fromUTF8("first_password")); | 387 document.getElementById(WebString::fromUTF8("first_password")); |
| 390 ASSERT_FALSE(element.isNull()); | 388 ASSERT_FALSE(element.isNull()); |
| 391 WebInputElement first_password_element = element.to<WebInputElement>(); | 389 WebInputElement first_password_element = element.to<WebInputElement>(); |
| 392 | 390 |
| 393 // Make a password just under maximum offer size. | 391 // Make a password just under maximum offer size. |
| 394 SimulateUserInputChangeForElement( | 392 SimulateUserInputChangeForElement( |
| 395 &first_password_element, | 393 &first_password_element, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 464 |
| 467 // This needs to come after the DOM has been modified. | 465 // This needs to come after the DOM has been modified. |
| 468 SetAccountCreationFormsDetectedMessage(password_generation_, | 466 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 469 GetMainFrame()->document(), | 467 GetMainFrame()->document(), |
| 470 1); | 468 1); |
| 471 | 469 |
| 472 // TODO(gcasto): I'm slightly worried about flakes in this test where | 470 // TODO(gcasto): I'm slightly worried about flakes in this test where |
| 473 // didAssociateFormControls() isn't called. If this turns out to be a problem | 471 // didAssociateFormControls() isn't called. If this turns out to be a problem |
| 474 // adding a call to OnDynamicFormsSeen(GetMainFrame()) will fix it, though | 472 // adding a call to OnDynamicFormsSeen(GetMainFrame()) will fix it, though |
| 475 // it will weaken the test. | 473 // it will weaken the test. |
| 476 ExpectPasswordGenerationAvailable("first_password", true); | 474 ExpectGenerationAvailable("first_password", true); |
| 477 } | 475 } |
| 478 | 476 |
| 479 TEST_F(PasswordGenerationAgentTest, MultiplePasswordFormsTest) { | 477 TEST_F(PasswordGenerationAgentTest, MultiplePasswordFormsTest) { |
| 480 // If two forms on the page looks like possible account creation forms, make | 478 // If two forms on the page looks like possible account creation forms, make |
| 481 // sure to trigger on the one that is specified from Autofill. | 479 // sure to trigger on the one that is specified from Autofill. |
| 482 LoadHTMLWithUserGesture(kMultipleAccountCreationFormHTML); | 480 LoadHTMLWithUserGesture(kMultipleAccountCreationFormHTML); |
| 483 SetNotBlacklistedMessage(password_generation_, | 481 SetNotBlacklistedMessage(password_generation_, |
| 484 kMultipleAccountCreationFormHTML); | 482 kMultipleAccountCreationFormHTML); |
| 485 | 483 |
| 486 // Should trigger on the second form. | 484 // Should trigger on the second form. |
| 487 SetAccountCreationFormsDetectedMessage(password_generation_, | 485 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 488 GetMainFrame()->document(), | 486 GetMainFrame()->document(), |
| 489 1); | 487 1); |
| 490 | 488 |
| 491 ExpectPasswordGenerationAvailable("password", false); | 489 ExpectGenerationAvailable("password", false); |
| 492 ExpectPasswordGenerationAvailable("first_password", true); | 490 ExpectGenerationAvailable("first_password", true); |
| 493 } | 491 } |
| 494 | 492 |
| 495 TEST_F(PasswordGenerationAgentTest, MessagesAfterAccountSignupFormFound) { | 493 TEST_F(PasswordGenerationAgentTest, MessagesAfterAccountSignupFormFound) { |
| 496 LoadHTMLWithUserGesture(kAccountCreationFormHTML); | 494 LoadHTMLWithUserGesture(kAccountCreationFormHTML); |
| 497 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 495 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 498 SetAccountCreationFormsDetectedMessage(password_generation_, | 496 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 499 GetMainFrame()->document(), | 497 GetMainFrame()->document(), |
| 500 0); | 498 0); |
| 501 | 499 |
| 502 // Generation should be enabled. | 500 // Generation should be enabled. |
| 503 ExpectPasswordGenerationAvailable("first_password", true); | 501 ExpectGenerationAvailable("first_password", true); |
| 504 | 502 |
| 505 // Extra not blacklisted messages can be sent. Make sure that they are handled | 503 // Extra not blacklisted messages can be sent. Make sure that they are handled |
| 506 // correctly (generation should still be available). | 504 // correctly (generation should still be available). |
| 507 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); | 505 SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); |
| 508 | 506 |
| 509 // Need to focus another field first for verification to work. | 507 // Need to focus another field first for verification to work. |
| 510 ExpectPasswordGenerationAvailable("second_password", false); | 508 ExpectGenerationAvailable("second_password", false); |
| 511 ExpectPasswordGenerationAvailable("first_password", true); | 509 ExpectGenerationAvailable("first_password", true); |
| 512 } | 510 } |
| 513 | 511 |
| 514 // Losing focus should not trigger a password generation popup. | 512 // Losing focus should not trigger a password generation popup. |
| 515 TEST_F(PasswordGenerationAgentTest, BlurTest) { | 513 TEST_F(PasswordGenerationAgentTest, BlurTest) { |
| 516 LoadHTMLWithUserGesture(kDisabledElementAccountCreationFormHTML); | 514 LoadHTMLWithUserGesture(kDisabledElementAccountCreationFormHTML); |
| 517 SetNotBlacklistedMessage(password_generation_, | 515 SetNotBlacklistedMessage(password_generation_, |
| 518 kDisabledElementAccountCreationFormHTML); | 516 kDisabledElementAccountCreationFormHTML); |
| 519 SetAccountCreationFormsDetectedMessage(password_generation_, | 517 SetAccountCreationFormsDetectedMessage(password_generation_, |
| 520 GetMainFrame()->document(), | 518 GetMainFrame()->document(), |
| 521 0); | 519 0); |
| 522 | 520 |
| 523 // Focus on the first password field: password generation popup should show | 521 // Focus on the first password field: password generation popup should show |
| 524 // up. | 522 // up. |
| 525 ExpectPasswordGenerationAvailable("first_password", true); | 523 ExpectGenerationAvailable("first_password", true); |
| 526 | 524 |
| 527 // Remove focus from everywhere by clicking an unfocusable element: password | 525 // Remove focus from everywhere by clicking an unfocusable element: password |
| 528 // generation popup should not show up. | 526 // generation popup should not show up. |
| 529 EXPECT_TRUE(SimulateElementClick("disabled")); | 527 EXPECT_TRUE(SimulateElementClick("disabled")); |
| 530 EXPECT_EQ(0u, password_generation_->messages().size()); | 528 EXPECT_EQ(0u, password_generation_->messages().size()); |
| 531 } | 529 } |
| 532 | 530 |
| 533 TEST_F(PasswordGenerationAgentTest, AutocompleteAttributesTest) { | 531 TEST_F(PasswordGenerationAgentTest, AutocompleteAttributesTest) { |
| 534 // Verify that autocomplete attributes can override Autofill to enable | 532 // Verify that autocomplete attributes can override Autofill to enable |
| 535 // generation | 533 // generation |
| 536 LoadHTMLWithUserGesture(kBothAutocompleteAttributesFormHTML); | 534 LoadHTMLWithUserGesture(kBothAutocompleteAttributesFormHTML); |
| 537 SetNotBlacklistedMessage(password_generation_, | 535 SetNotBlacklistedMessage(password_generation_, |
| 538 kBothAutocompleteAttributesFormHTML); | 536 kBothAutocompleteAttributesFormHTML); |
| 539 | 537 |
| 540 ExpectPasswordGenerationAvailable("first_password", true); | 538 ExpectGenerationAvailable("first_password", true); |
| 541 | 539 |
| 542 // Only setting one of the two attributes doesn't trigger generation. | 540 // Only setting one of the two attributes doesn't trigger generation. |
| 543 LoadHTMLWithUserGesture(kUsernameAutocompleteAttributeFormHTML); | 541 LoadHTMLWithUserGesture(kUsernameAutocompleteAttributeFormHTML); |
| 544 SetNotBlacklistedMessage(password_generation_, | 542 SetNotBlacklistedMessage(password_generation_, |
| 545 kUsernameAutocompleteAttributeFormHTML); | 543 kUsernameAutocompleteAttributeFormHTML); |
| 546 | 544 |
| 547 ExpectPasswordGenerationAvailable("first_password", false); | 545 ExpectGenerationAvailable("first_password", false); |
| 548 | 546 |
| 549 LoadHTMLWithUserGesture(kNewPasswordAutocompleteAttributeFormHTML); | 547 LoadHTMLWithUserGesture(kNewPasswordAutocompleteAttributeFormHTML); |
| 550 SetNotBlacklistedMessage(password_generation_, | 548 SetNotBlacklistedMessage(password_generation_, |
| 551 kNewPasswordAutocompleteAttributeFormHTML); | 549 kNewPasswordAutocompleteAttributeFormHTML); |
| 552 | 550 |
| 553 ExpectPasswordGenerationAvailable("first_password", false); | 551 ExpectGenerationAvailable("first_password", false); |
| 554 } | 552 } |
| 555 | 553 |
| 556 } // namespace autofill | 554 } // namespace autofill |
| OLD | NEW |