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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 }

mercurial