summaryrefslogtreecommitdiffstats
path: root/dom/tests/browser/browser_autofocus_background.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/browser/browser_autofocus_background.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/browser/browser_autofocus_background.js')
-rw-r--r--dom/tests/browser/browser_autofocus_background.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/dom/tests/browser/browser_autofocus_background.js b/dom/tests/browser/browser_autofocus_background.js
new file mode 100644
index 000000000..8523ec047
--- /dev/null
+++ b/dom/tests/browser/browser_autofocus_background.js
@@ -0,0 +1,37 @@
+add_task(function* () {
+ let tabs = [ gBrowser.selectedTab, gBrowser.addTab() ];
+
+ // The first tab has an autofocused element.
+ // The second tab is exactly like the first one without the autofocus.
+ let testingList = [
+ { uri: "data:text/html,<!DOCTYPE html><html><body><input autofocus id='target'></body></html>",
+ tagName: "INPUT"},
+ ];
+
+ // Set the focus to the first tab.
+ tabs[0].linkedBrowser.focus();
+
+ // Load the second tab in the background.
+ let loadedPromise = BrowserTestUtils.browserLoaded(tabs[1].linkedBrowser);
+ tabs[1].linkedBrowser.loadURI(testingList[0].uri);
+ yield loadedPromise;
+
+ for (var i = 0; i < testingList.length; ++i) {
+ // Get active element in the tab.
+ let tagName = yield ContentTask.spawn(tabs[i + 1].linkedBrowser, null, function* () {
+ return content.document.activeElement.tagName;
+ });
+
+ is(tagName, testingList[i].tagName,
+ "The background tab's focused element should be " + testingList[i].tagName);
+ }
+
+ is(document.activeElement, tabs[0].linkedBrowser,
+ "The background tab's focused element should not cause the tab to be focused");
+
+ // Cleaning up.
+ for (let i = 1; i < tabs.length; i++) {
+ yield BrowserTestUtils.removeTab(tabs[i]);
+ }
+});
+