mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 511449, when a window is shown, update the system focus, as the focus may have been put into an about:blank page loaded beforehand, test by mstange, r=smaug
This commit is contained in:
parent
c0f8d0fac2
commit
605ff17f62
@ -80,5 +80,12 @@ _TEST_FILES = \
|
||||
file_bug509055.html \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
_TEST_FILES += \
|
||||
test_bug511449.html \
|
||||
file_bug511449.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
||||
|
6
docshell/test/file_bug511449.html
Normal file
6
docshell/test/file_bug511449.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE HTML>
|
||||
<title>Used in test for bug 511449</title>
|
||||
<input type="text" id="input">
|
||||
<script type="text/javascript">
|
||||
document.getElementById("input").focus();
|
||||
</script>
|
56
docshell/test/test_bug511449.html
Normal file
56
docshell/test/test_bug511449.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=511449
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 511449</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511449">Mozilla Bug 511449</a>
|
||||
<p id="display"></p>
|
||||
<div id="status"></div>
|
||||
<div id="content">
|
||||
</div>
|
||||
<input type="text" id="input">
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.7">
|
||||
|
||||
/** Test for Bug 511449 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
window.addEventListener('load', runTest, false);
|
||||
|
||||
var win = null;
|
||||
|
||||
function runTest() {
|
||||
document.getElementById("input").focus();
|
||||
win = window.open("file_bug511449.html", "");
|
||||
SimpleTest.waitForFocus(runNextTest, win);
|
||||
}
|
||||
|
||||
function runNextTest() {
|
||||
var didClose = false;
|
||||
win.onunload = function() {
|
||||
didClose = true;
|
||||
}
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
utils.sendNativeKeyEvent(0, 13 /* w */, 0x4000 /* cmd */, "w", "w");
|
||||
|
||||
ok(didClose, "Cmd+W should have closed the tab");
|
||||
if (!didClose) {
|
||||
win.close();
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -772,7 +772,7 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFocusManager::WindowShown(nsIDOMWindow* aWindow)
|
||||
nsFocusManager::WindowShown(nsIDOMWindow* aWindow, PRBool aNeedsFocus)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aWindow);
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_INVALID_ARG);
|
||||
@ -801,11 +801,19 @@ nsFocusManager::WindowShown(nsIDOMWindow* aWindow)
|
||||
if (mFocusedWindow != window)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> currentWindow;
|
||||
nsCOMPtr<nsIContent> currentFocus =
|
||||
GetFocusedDescendant(window, PR_TRUE, getter_AddRefs(currentWindow));
|
||||
if (currentWindow)
|
||||
Focus(currentWindow, currentFocus, 0, PR_TRUE, PR_FALSE, PR_FALSE);
|
||||
if (aNeedsFocus) {
|
||||
nsCOMPtr<nsPIDOMWindow> currentWindow;
|
||||
nsCOMPtr<nsIContent> currentFocus =
|
||||
GetFocusedDescendant(window, PR_TRUE, getter_AddRefs(currentWindow));
|
||||
if (currentWindow)
|
||||
Focus(currentWindow, currentFocus, 0, PR_TRUE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
// Sometimes, an element in a window can be focused before the window is
|
||||
// visible, which would mean that the widget may not be properly focused.
|
||||
// When the window becomes visible, make sure the right widget is focused.
|
||||
EnsureCurrentWidgetFocused();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -6836,15 +6836,12 @@ nsGlobalWindow::SetReadyForFocus()
|
||||
{
|
||||
FORWARD_TO_INNER_VOID(SetReadyForFocus, ());
|
||||
|
||||
// if we don't need to be focused, then just return
|
||||
if (!mNeedsFocus)
|
||||
return;
|
||||
|
||||
PRBool oldNeedsFocus = mNeedsFocus;
|
||||
mNeedsFocus = PR_FALSE;
|
||||
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm)
|
||||
fm->WindowShown(this);
|
||||
fm->WindowShown(this, oldNeedsFocus);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -39,7 +39,7 @@
|
||||
interface nsIDocument;
|
||||
interface nsIContent;
|
||||
|
||||
[scriptable, uuid(CD6040A8-243F-412A-8A16-0BF2AA1083B9)]
|
||||
[scriptable, uuid(64CAE24B-8C2D-4B75-9047-BC9668D85975)]
|
||||
/**
|
||||
* The focus manager deals with all focus related behaviour. Only one element
|
||||
* in the entire application may have the focus at a time; this element
|
||||
@ -245,8 +245,11 @@ interface nsIFocusManager : nsISupports
|
||||
|
||||
/**
|
||||
* Called when a new document in a window is shown.
|
||||
*
|
||||
* If aNeedsFocus is true, then focus events are expected to be fired on the
|
||||
* window if this window is in the focused window chain.
|
||||
*/
|
||||
[noscript] void windowShown(in nsIDOMWindow aWindow);
|
||||
[noscript] void windowShown(in nsIDOMWindow aWindow, in PRBool aNeedsFocus);
|
||||
|
||||
/**
|
||||
* Called when a document in a window has been hidden or otherwise can no
|
||||
|
Loading…
Reference in New Issue
Block a user