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