PasswordWidgetThemeFunctionTest throws a Javascript Error

Created on 8 June 2021, over 3 years ago
Updated 24 August 2023, over 1 year ago

Problem/Motivation

In #3091870: Fail Functional Javascript tests that throw Javascript errors it was discovered that PasswordWidgetThemeFunctionTest created #3067523: Add Drupal JavaScript theme functions for password confirm widget has Javascript error in the test.

This doesn't currently fail the test but it should be fixed.

#3091870 can add flag to to not fail the this test with a todo to this issue

To see the error you can

  1. Put the line
    $this->assertSession()->waitForElementVisible('css', '.test-go', 9999999999999999); at the end of \Drupal\Tests\user\FunctionalJavascript\PasswordWidgetThemeFunctionTest::setUp()

    This will stop the test at the end of setup

  2. run the test.
  3. When the browser pauses on the user page if you look in the js inspector console there should be an error "Uncaught TypeError: Cannot read property 'username' of undefined"

The error is

drupal.js?v=9.2.0-dev:16 Uncaught TypeError: Cannot read property 'username' of undefined
at Object.Drupal.evaluatePasswordStrength (user.js?v=9.2.0-dev:152)
at Object.attach (password-theme-functions.js?quee51:29)
at drupal.js?v=9.2.0-dev:27
at Array.forEach ()
at Object.Drupal.attachBehaviors (drupal.js?v=9.2.0-dev:24)
at drupal.init.js?v=9.2.0-dev:29
at HTMLDocument.listener (drupal.init.js?v=9.2.0-dev:17)

Proposed resolution

Fix the error

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: outdated

Version

11.0 🔥

Component
Theme 

Last updated 24 minutes ago

Created by

🇺🇸United States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    I believe this is outdated, looking at user.js:

    The only thing accessing .username in evaluatePasswordStrength is passwordSettings.username
    The only thing calling evaluatePasswordStrength is passwordCheck()
    The very top of that function has

              if (settings.password.showStrengthIndicator) {
                // Evaluate the password strength.
                const result = Drupal.evaluatePasswordStrength(
                  $mainInput[0].value,
                  settings.password,
                );
    

    Therefore, evaluatePasswordStrength wouldn't be called unless settings.password is defined.

    The test mentioned in the IS also no longer exists.

Production build 0.71.5 2024