diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 74b76ec..94a21b0 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -1141,6 +1141,12 @@ function _locale_parse_js_file($filepath) {
     throw new Exception('Only local files should be passed to _locale_parse_js_file().');
   }
 
+  // Make sure the file actually exists.
+  if (!file_exists($filepath)) {
+    \Drupal::logger('locale')->warning('Could not open JavaScript file: %s', ['%s' => $filepath]);
+    return;
+  }
+
   // Load the JavaScript file.
   $file = file_get_contents($filepath);
 
diff --git a/core/modules/locale/src/Tests/LocaleAddJSTest.php b/core/modules/locale/src/Tests/LocaleAddJSTest.php
new file mode 100644
index 0000000..ad03623
--- /dev/null
+++ b/core/modules/locale/src/Tests/LocaleAddJSTest.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\locale\Tests\LocaleAddJSTest.
+ */
+
+namespace Drupal\locale\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests adding JavaScript when locale module is enabled.
+ *
+ * @group locale
+ */
+class LocaleAddJSTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['locale_test_add_js'];
+
+  /**
+   * A normal user.
+   */
+  protected $user = NULL;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->user = $this->drupalCreateUser();
+    $this->drupalLogin($this->user);
+  }
+
+  /**
+   * Tests adding a non-existent javascript file while the locale module is
+   * enabled, to ensure that an error message is not thrown.
+   */
+  function testLocaleAddJS() {
+    // Request a page that attempts to add a non-existent JavaScript file. As
+    // this test is testing for a PHP error, no assertions are needed as the
+    // error in question will throw an exception causing the test to fail.
+    $this->drupalGet('');
+  }
+}
diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml
new file mode 100644
index 0000000..2176fab
--- /dev/null
+++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.info.yml
@@ -0,0 +1,9 @@
+name: 'Locale test add js'
+type: module
+description: 'Support module for adding javascript with the Interface Translation (locale) module enabled.'
+package: Testing
+version: VERSION
+core: 8.x
+dependencies:
+  - locale
+hidden: true
diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml
new file mode 100644
index 0000000..720bc93
--- /dev/null
+++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.libraries.yml
@@ -0,0 +1,4 @@
+drupal.locale_test_add_js:
+  version: VERSION
+  js:
+    non_existent_js_file.js: {}
diff --git a/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module
new file mode 100644
index 0000000..ea60f53
--- /dev/null
+++ b/core/modules/locale/tests/modules/locale_test_add_js/locale_test_add_js.module
@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * @file
+ * Attempts to add a non-existent JS file to test for non-existence of error
+ * message.
+ */
+
+/**
+ * Implements hook_page_attachments().
+ * Adds a non existent js file to the page.
+ */
+function locale_test_add_js_page_attachments(array &$attachments) {
+  $attachments['#attached']['library'][] = 'locale_test_add_js/drupal.locale_test_add_js';
+}
