diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php
index 414c86b..0276c81 100644
--- a/core/modules/file/src/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php
@@ -428,6 +428,9 @@ function testWidgetValidation() {
$test_file_image = $this->getTestFile('image');
$name = 'files[' . $field_name . '_0]';
+ // Check field is marked with expected attr for client-side validation.
+ $this->assertFieldByXPath('//input[@type="file" and @data-drupal-validate-extensions="txt"]', null, 'data-drupal-validate-extensions is present');
+
// Upload file with incorrect extension, check for validation error.
$edit[$name] = drupal_realpath($test_file_image->getFileUri());
switch ($type) {
diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php
index 07102a0..e9aa2a2 100644
--- a/core/modules/file/src/Tests/FileManagedFileElementTest.php
+++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php
@@ -18,6 +18,10 @@ function testManagedFile() {
$this->drupalGet('file/test');
$this->assertFieldByXpath('//input[@name="files[nested_file]" and @size="13"]', NULL, 'The custom #size attribute is passed to the child upload element.');
+ // Check that relevant data- attributes are present for validations
+ $this->drupalGet('file/test/validation/extension');
+ $this->assertFieldByXPath('//input[@name="files[file]" and @data-drupal-validate-extensions="txt"]', NULL, 'The data-drupal-validate-extensions attribute is present on the upload element.');
+
// Perform the tests with all permutations of $form['#tree'],
// $element['#extended'], and $element['#multiple'].
$test_file = $this->getTestFile('text');
diff --git a/core/modules/file/tests/file_module_test/file_module_test.routing.yml b/core/modules/file/tests/file_module_test/file_module_test.routing.yml
index 15f7d0f..0c85f6e 100644
--- a/core/modules/file/tests/file_module_test/file_module_test.routing.yml
+++ b/core/modules/file/tests/file_module_test/file_module_test.routing.yml
@@ -8,3 +8,11 @@ file_module_test.managed_test:
default_fids: NULL
requirements:
_access: 'TRUE'
+
+file_module_test.managed_validations_test:
+ path: '/file/test/validation/{validation_type}'
+ defaults:
+ _form: '\Drupal\file_module_test\Form\FileModuleTestValidationForm'
+ validation_type: 'extension'
+ requirements:
+ _access: 'TRUE'
diff --git a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestValidationForm.php b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestValidationForm.php
index e69de29..9674b09 100644
--- a/core/modules/file/tests/file_module_test/src/Form/FileModuleTestValidationForm.php
+++ b/core/modules/file/tests/file_module_test/src/Form/FileModuleTestValidationForm.php
@@ -0,0 +1,70 @@
+ ['txt']];
+ break;
+ case 'size':
+ $validator = ['file_validate_size' => [1024]];
+ break;
+ default:
+ return FALSE;
+ }
+
+ $form['file'] = array(
+ '#type' => 'managed_file',
+ '#title' => $this->t('Managed File'),
+ '#upload_location' => 'public://test',
+ '#progress_message' => $this->t('Please wait...'),
+ '#upload_validators' => $validator,
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => $this->t('Save'),
+ );
+
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ drupal_set_message($this->t('Test submission handler was allowed to execute.'));
+ }
+
+}
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index 666a791..61a6c9d 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -312,8 +312,13 @@ function testImageFieldSettings() {
'files[' . $field_name . '_2][]' => drupal_realpath($test_image->uri),
);
$this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button');
- $this->assertNoRaw('');
- $this->assertRaw('');
+ $this->assertNoFieldByXPath('//input[@id="edit-' . strtr($field_name, '_', '-') . '-2-upload"]', 'Upload field for second file not present after it is uploaded.');
+
+ $this->assertTrue($this->cssSelect('input#edit-' . strtr($field_name, '_', '-') . '-3-upload[multiple=multiple]'), 'Third file field presented having multiple attribute');
+ $this->assertFieldByName('files[' . $field_name . '_3][]', null, 'Third file field has correct name');
+ $this->assertTrue($this->cssSelect('input[id=edit-' . strtr($field_name, '_', '-') . '-3-upload][size=22]'), 'Third file field presented having correct size attribute');
+ $this->assertTrue($this->cssSelect('input.js-form-file.form-file[id=edit-' . strtr($field_name, '_', '-') . '-3-upload]'), 'Third file field presented having correct css classes');
+ $this->assertTrue($this->cssSelect('input[id=edit-' . strtr($field_name, '_', '-') . "-3-upload][data-drupal-validate-extensions=$test_image_extension]"), 'Third file field presented having correct data-drupal-validate-extensions');
}
/**