2017-06-22 13:51:42 +03:00
|
|
|
add_task(async function() {
|
2017-05-15 22:49:50 +03:00
|
|
|
let tabs = [ gBrowser.selectedTab, BrowserTestUtils.addTab(gBrowser) ];
|
2010-05-19 21:52:17 +04:00
|
|
|
|
|
|
|
// 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"},
|
|
|
|
];
|
|
|
|
|
2016-03-09 17:11:12 +03:00
|
|
|
// Set the focus to the first tab.
|
|
|
|
tabs[0].linkedBrowser.focus();
|
2010-05-19 21:52:17 +04:00
|
|
|
|
2016-03-09 17:11:12 +03:00
|
|
|
// Load the second tab in the background.
|
|
|
|
let loadedPromise = BrowserTestUtils.browserLoaded(tabs[1].linkedBrowser);
|
|
|
|
tabs[1].linkedBrowser.loadURI(testingList[0].uri);
|
2017-06-22 13:51:42 +03:00
|
|
|
await loadedPromise;
|
2010-05-19 21:52:17 +04:00
|
|
|
|
2016-03-09 17:11:12 +03:00
|
|
|
for (var i = 0; i < testingList.length; ++i) {
|
|
|
|
// Get active element in the tab.
|
2017-06-22 13:51:42 +03:00
|
|
|
let tagName = await ContentTask.spawn(tabs[i + 1].linkedBrowser, null, async function() {
|
2016-03-09 17:11:12 +03:00
|
|
|
return content.document.activeElement.tagName;
|
|
|
|
});
|
2010-05-19 21:52:17 +04:00
|
|
|
|
2016-03-09 17:11:12 +03:00
|
|
|
is(tagName, testingList[i].tagName,
|
|
|
|
"The background tab's focused element should be " + testingList[i].tagName);
|
2010-05-19 21:52:17 +04:00
|
|
|
}
|
|
|
|
|
2016-03-09 17:11:12 +03:00
|
|
|
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++) {
|
2018-03-19 05:16:45 +03:00
|
|
|
BrowserTestUtils.removeTab(tabs[i]);
|
2010-05-19 21:52:17 +04:00
|
|
|
}
|
2016-03-09 17:11:12 +03:00
|
|
|
});
|
2010-05-19 21:52:17 +04:00
|
|
|
|