Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
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 */
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>';
14 function test() {
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
26 // from its document.
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();
35 finish();
36 }, 0);
37 }, true);
39 content.location = testPage;
40 }