diff --git a/test/core/js/modules/form_panel.js.js b/test/core/js/modules/form_panel.js.js
index f0cf34336292f95c17c9349270494ac8fa54b877..3a26aee2d8a6ca6cf0021d7c35ddae71c5560145 100644
--- a/test/core/js/modules/form_panel.js.js
+++ b/test/core/js/modules/form_panel.js.js
@@ -23,25 +23,24 @@
 'use strict';
 
 QUnit.module("form_panel.js", {
-    before: function (assert) {
+    before: function(assert) {
 
     },
-    after: function (assert) {
-    }
+    after: function(assert) {}
 });
 
-QUnit.test("availability", function (assert) {
+QUnit.test("availability", function(assert) {
     assert.ok(form_panel.init, "init available");
-    assert.ok(form_panel.create_show_form_callback , "version available");
+    assert.ok(form_panel.create_show_form_callback, "version available");
 });
 
-QUnit.test("create_show_form_callback ", function (assert) {
+QUnit.test("create_show_form_callback ", function(assert) {
     const title = "Upload CSV File"; // title of the form and text in the toolbox
     const panel_id = "csv_upload_form_panel";
     const server_side_script = "csv_script.py";
     const tool_box = "Tools"; // Name of the drop-down menu where the button is added in the navbar
     const help_text = "something";
-    const accepted_files_formats = [ ".csv", "text/tsv", ] // Mime types and file endings.
+    const accepted_files_formats = [".csv", "text/tsv", ] // Mime types and file endings.
 
     const csv_form_config = {
         script: server_side_script,
@@ -80,3 +79,37 @@ QUnit.test("create_show_form_callback ", function (assert) {
 });
 
 
+QUnit.test("autofocus_without_form", function(assert) {
+    const title = "My not-form title";
+    const id = "not_form_id";
+    // callback function that creates a "form" without HTML form
+    // elements.  Trivial here, but could be e.g., the file upload
+    // from LinkAhead WebUI Core Components.
+    const init_not_form_field = () => {
+        const container = $(`<div class="row"/>`);
+        return container[0];
+    };
+    // This should always work
+    cb_without_autofocus = form_panel.create_show_form_callback(
+        id,
+        title,
+        undefined,
+        init_not_form_field,
+        false
+    );
+    const nav = document.createElement("nav");
+    document.body.appendChild(nav);
+    cb_without_autofocus();
+    assert.ok(document.querySelector(`#${id}`), "Callback was called without autofocus.");
+    $(`#${id}`).remove();
+
+    cb_with_autofocus = form_panel.create_show_form_callback(
+        id,
+        title,
+        undefined,
+        init_not_form_field,
+        true
+    );
+    cb_with_autofocus();
+    assert.ok(document.querySelector(`#${id}`), "Callback was called with autofocus, bt still okay.");
+});