gecko-dev/dom/tests/browser/browser_autofocus_preference.js
Mounir Lamouri 1df3f9208d Bug 601030 (2/2) - Don't let a frame steal focus with autofocus when the document has been loaded. r=smaug a=sicking
--HG--
rename : content/html/content/test/test_bug546995-1.html => content/html/content/test/test_bug546995.html
extra : rebase_source : 5f84b2ef8ce5bf4cad9c736dc63393e7286ae51f
2010-12-17 18:01:12 -08:00

25 lines
960 B
JavaScript

function test() {
waitForExplicitFinish();
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var gAutofocusPref = prefs.getBoolPref("browser.autofocus");
prefs.setBoolPref("browser.autofocus", false);
gBrowser.selectedTab.linkedBrowser.addEventListener("load", function () {
gBrowser.selectedTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
executeSoon(function () {
is(gBrowser.selectedTab.linkedBrowser.contentDocument.activeElement,
gBrowser.selectedTab.linkedBrowser.contentDocument.body,
"foo");
prefs.setBoolPref("browser.autofocus", gAutofocusPref);
finish();
});
}, true);
gBrowser.selectedTab.linkedBrowser.loadURI("data:text/html,<!DOCTYPE html><html><body><input autofocus><button autofocus></button><textarea autofocus></textarea><select autofocus></select></body></html>");
}