1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * Test bug 427559 to make sure focused elements that are no longer on the page
7 * will have focus transferred to the window when changing tabs back to that
8 * tab with the now-gone element.
11 // Default focus on a button and have it kill itself on blur
12 let testPage = 'data:text/html,<body><button onblur="this.parentNode.removeChild(this);"><script>document.body.firstChild.focus();</script></body>';
15 waitForExplicitFinish();
17 gBrowser.selectedTab = gBrowser.addTab();
19 gBrowser.selectedBrowser.addEventListener("load", function () {
20 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
21 setTimeout(function () {
22 var testPageWin = content;
24 // The test page loaded, so open an empty tab, select it, then restore
25 // the test tab. This causes the test page's focused element to be removed
27 gBrowser.selectedTab = gBrowser.addTab();
28 gBrowser.removeCurrentTab();
30 // Make sure focus is given to the window because the element is now gone
31 is(document.commandDispatcher.focusedWindow, testPageWin,
32 "content window is focused");
34 gBrowser.removeCurrentTab();
39 content.location = testPage;