browser/base/content/test/general/browser_bug427559.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:af2db0e1e5a5
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/. */
4
5 /*
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.
9 */
10
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>';
13
14 function test() {
15 waitForExplicitFinish();
16
17 gBrowser.selectedTab = gBrowser.addTab();
18
19 gBrowser.selectedBrowser.addEventListener("load", function () {
20 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
21 setTimeout(function () {
22 var testPageWin = content;
23
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
26 // from its document.
27 gBrowser.selectedTab = gBrowser.addTab();
28 gBrowser.removeCurrentTab();
29
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");
33
34 gBrowser.removeCurrentTab();
35 finish();
36 }, 0);
37 }, true);
38
39 content.location = testPage;
40 }

mercurial