summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs')
-rw-r--r--toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs35
1 files changed, 35 insertions, 0 deletions
diff --git a/toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs b/toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs
new file mode 100644
index 0000000000..b99246c166
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/browser/file_focus_before_DOMContentLoaded.sjs
@@ -0,0 +1,35 @@
+/**
+ * Focus a username field before DOMContentLoaded.
+ */
+
+"use strict";
+
+const DELAY = 2 * 1000; // Delay two seconds before completing the request.
+
+// In an SJS file we need to get the setTimeout bits ourselves, despite
+// what eslint might think applies for browser tests.
+// eslint-disable-next-line mozilla/no-redeclare-with-import-autofix
+let { setTimeout } = ChromeUtils.importESModule(
+ "resource://gre/modules/Timer.sys.mjs"
+);
+
+function handleRequest(request, response) {
+ response.processAsync();
+
+ response.setHeader("Content-Type", "text/html;charset=utf-8", false);
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.write(`
+ <!DOCTYPE html><html><body>
+ <form id="early_focus_form" action="https://autocomplete:8888/formtest.js">
+ <input type="text" id="uname" name="uname">
+ <input type="password" id="pword" name="pword">
+ <button type="submit">Submit</button>
+ </form>
+ <script>document.querySelector("#uname").focus();</script>
+ `);
+
+ setTimeout(function finishOutput() {
+ response.write(`</body></html>`);
+ response.finish();
+ }, DELAY);
+}