diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
index a00d9e2..5ee07d2 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
@@ -219,6 +219,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
       $item_attributes = $item->_attributes;
       unset($item->_attributes);
 
+      if (empty($image_style_setting)) {
+        $item_attributes['class'][] = 'image-style-none';
+      }
+
       $elements[$delta] = [
         '#theme' => 'image_formatter',
         '#item' => $item,
diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
index b5b42ff..f3a643a 100644
--- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
@@ -122,6 +122,39 @@ function testImageFormatterTheme() {
   }
 
   /**
+   * Tests usage of the image without style.
+   */
+  function testImageFormatterThemeNoStyle() {
+    /** @var \Drupal\Core\Render\RendererInterface $renderer */
+    $renderer = $this->container->get('renderer');
+
+    // Create an image.
+    $files = $this->drupalGetTestFiles('image');
+    $file = reset($files);
+    $original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
+
+    // Create a test entity with the image field set.
+    $entity = EntityTest::create();
+    $entity->image_test->target_id = $this->image->id();
+    $entity->image_test->alt = NULL;
+    $entity->image_test->uri = $original_uri;
+    $entity->save();
+
+    // Create the base element that we'll use in the tests below.
+    $path = $this->randomMachineName();
+    $base_element = [
+      '#theme' => 'image_formatter',
+      '#item' => $entity->image_test,
+      '#url' => Url::fromUri('base:' . $path),
+    ];
+
+    $element = $base_element;
+    $this->setRawContent($renderer->renderRoot($element));
+    $elements = $this->xpath('//img[@class=":class"]', [':class' => 'image-style-none']);
+    $this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly.');
+  }
+
+  /**
    * Tests usage of the image style theme function.
    */
   function testImageStyleTheme() {
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index aa1088f..479ad6a 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -680,20 +680,67 @@ function simpletest_clean_database() {
   else {
     drupal_set_message(t('No leftover tables to remove.'));
   }
+
+  return $result;
 }
 
 /**
  * Finds all leftover temporary directories and removes them.
+ *
+ * @param string $directory
+ *   (optional) The relative path to directory of a particular test site. Must
+ *   to be of the following pattern: sites/simpletest/12345678. If ommited, all
+ *   the test sites' directories found in sites/simpletest will be removed.
+ *
+ * @return null|bool
+ *   Returns TRUE if all attempted to remove directories are removed, FALSE if
+ *   at least one directory was not removed successfully, NULL if there is
+ *   nothing to remove or the directory is not eligible for removing.
+ *
+ * @see file_unmanaged_delete()
+ * @see http://php.net/manual/en/function.unlink.php
  */
-function simpletest_clean_temporary_directories() {
+function simpletest_clean_temporary_directories($directory = NULL) {
+  $directories = [];
   $count = 0;
-  if (is_dir(DRUPAL_ROOT . '/sites/simpletest')) {
-    $files = scandir(DRUPAL_ROOT . '/sites/simpletest');
-    foreach ($files as $file) {
+  $result = NULL;
+  $simpletest_root = \Drupal::root() . '/sites/simpletest/';
+
+  if (is_dir($simpletest_root)) {
+    // If the $directory is not valid string or NULL then get the type of it for
+    // debugging purposes in the error message below.
+    $path = is_string($directory) && !empty($directory) ? $directory : gettype($directory);
+    // Do not recognize any, except expected directory pattern as wrong
+    // directory being passed accidentally may cause catastrophic consequences.
+    preg_match('/^(sites\/simpletest\/)(.*)/', $path, $matches);
+
+    if (!empty($matches[2]) && is_dir($simpletest_root . $matches[2])) {
+      $directories[] = $matches[2];
+    }
+    elseif ($directory === NULL) {
+      $directories = scandir($simpletest_root);
+    }
+    else {
+      drupal_set_message(t('The %path is not eligible for removing in %func().', ['%path' => $path, '%func' => __FUNCTION__]));
+    }
+
+    foreach ($directories as $file) {
       if ($file[0] != '.') {
-        $path = DRUPAL_ROOT . '/sites/simpletest/' . $file;
-        file_unmanaged_delete_recursive($path, ['Drupal\simpletest\TestBase', 'filePreDeleteCallback']);
-        $count++;
+        $path = $simpletest_root . $file;
+        // When the webserver runs with the same system user as the test
+        // runner, we can make read-only files writable again. If not, chmod
+        // will fail while the file deletion still works if file permissions
+        // have been configured correctly. Thus, we ignore any chmod errors.
+        $deleted = file_unmanaged_delete_recursive($path, function ($any_path) {
+          @chmod($any_path, 0700);
+        });
+        $result = $result === FALSE ? $result : $deleted;
+        if ($deleted) {
+          $count++;
+        }
+        else {
+          drupal_set_message(t('This directory is failed to be removed: @path.', ['@path' => $path]));
+        }
       }
     }
   }
@@ -704,6 +751,8 @@ function simpletest_clean_temporary_directories() {
   else {
     drupal_set_message(t('No temporary directories to remove.'));
   }
+
+  return $result;
 }
 
 /**
