Loading core/modules/comment/src/CommentForm.php +0 −8 Original line number Diff line number Diff line Loading @@ -120,11 +120,6 @@ public function form(array $form, FormStateInterface $form_state) { $anonymous_contact = $field_definition->getSetting('anonymous'); $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); if (!$this->currentUser->isAuthenticated() && $anonymous_contact != CommentInterface::ANONYMOUS_MAYNOT_CONTACT) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; } // If not replying to a comment, use our dedicated page callback for new // Comments on entities. if (!$comment->id() && !$comment->hasParentComment()) { Loading Loading @@ -194,9 +189,6 @@ public function form(array $form, FormStateInterface $form_state) { '#maxlength' => 60, '#access' => $this->currentUser->isAnonymous() || $is_admin, '#size' => 30, '#attributes' => [ 'data-drupal-default-value' => $config->get('anonymous'), ], ]; if ($is_admin) { Loading core/modules/contact/src/MessageForm.php +1 −5 Original line number Diff line number Diff line Loading @@ -123,13 +123,9 @@ public function form(array $form, FormStateInterface $form_state) { '#title' => $this->t('Your email address'), '#required' => TRUE, ]; if ($user->isAnonymous()) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; } // Do not allow authenticated users to alter the name or email values to // prevent the impersonation of other users. else { if ($user->isAuthenticated()) { $form['name']['#type'] = 'item'; $form['name']['#value'] = $user->getDisplayName(); $form['name']['#required'] = FALSE; Loading core/modules/user/src/RegisterForm.php +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ public function form(array $form, FormStateInterface $form_state) { $form['#attached']['library'][] = 'core/drupal.form'; // For non-admin users, populate the form fields using data from the // browser. if (!$admin) { $form['#attributes']['data-user-info-from-browser'] = TRUE; } // Because the user status has security implications, users are blocked by // default when created programmatically and need to be actively activated // if needed. When administrators create users from the user interface, Loading core/modules/user/tests/src/FunctionalJavascript/UserRegisterFormTest.php 0 → 100644 +42 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\user\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests user registration forms via JS. * * @group user */ class UserRegisterFormTest extends WebDriverTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests if registration form writes to localStorage. */ public function testRegistrationFormStorage(): void { // Load register form. $this->drupalGet('user/register'); // Register user. $name = $this->randomMachineName(); $page = $this->getSession()->getPage(); $page->fillField('edit-name', $name); $page->fillField('edit-mail', $name . '@example.com'); $page->pressButton('edit-submit'); // Test if localStorage is set now. $this->assertJsCondition("localStorage.getItem('Drupal.visitor.name') === null", 10000, 'Failed to assert that the visitor name was not written to localStorage.'); } } Loading
core/modules/comment/src/CommentForm.php +0 −8 Original line number Diff line number Diff line Loading @@ -120,11 +120,6 @@ public function form(array $form, FormStateInterface $form_state) { $anonymous_contact = $field_definition->getSetting('anonymous'); $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); if (!$this->currentUser->isAuthenticated() && $anonymous_contact != CommentInterface::ANONYMOUS_MAYNOT_CONTACT) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; } // If not replying to a comment, use our dedicated page callback for new // Comments on entities. if (!$comment->id() && !$comment->hasParentComment()) { Loading Loading @@ -194,9 +189,6 @@ public function form(array $form, FormStateInterface $form_state) { '#maxlength' => 60, '#access' => $this->currentUser->isAnonymous() || $is_admin, '#size' => 30, '#attributes' => [ 'data-drupal-default-value' => $config->get('anonymous'), ], ]; if ($is_admin) { Loading
core/modules/contact/src/MessageForm.php +1 −5 Original line number Diff line number Diff line Loading @@ -123,13 +123,9 @@ public function form(array $form, FormStateInterface $form_state) { '#title' => $this->t('Your email address'), '#required' => TRUE, ]; if ($user->isAnonymous()) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; } // Do not allow authenticated users to alter the name or email values to // prevent the impersonation of other users. else { if ($user->isAuthenticated()) { $form['name']['#type'] = 'item'; $form['name']['#value'] = $user->getDisplayName(); $form['name']['#required'] = FALSE; Loading
core/modules/user/src/RegisterForm.php +0 −6 Original line number Diff line number Diff line Loading @@ -35,12 +35,6 @@ public function form(array $form, FormStateInterface $form_state) { $form['#attached']['library'][] = 'core/drupal.form'; // For non-admin users, populate the form fields using data from the // browser. if (!$admin) { $form['#attributes']['data-user-info-from-browser'] = TRUE; } // Because the user status has security implications, users are blocked by // default when created programmatically and need to be actively activated // if needed. When administrators create users from the user interface, Loading
core/modules/user/tests/src/FunctionalJavascript/UserRegisterFormTest.php 0 → 100644 +42 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\Tests\user\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests user registration forms via JS. * * @group user */ class UserRegisterFormTest extends WebDriverTestBase { /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests if registration form writes to localStorage. */ public function testRegistrationFormStorage(): void { // Load register form. $this->drupalGet('user/register'); // Register user. $name = $this->randomMachineName(); $page = $this->getSession()->getPage(); $page->fillField('edit-name', $name); $page->fillField('edit-mail', $name . '@example.com'); $page->pressButton('edit-submit'); // Test if localStorage is set now. $this->assertJsCondition("localStorage.getItem('Drupal.visitor.name') === null", 10000, 'Failed to assert that the visitor name was not written to localStorage.'); } }