зеркало из https://github.com/mozilla/pjs.git
Backed out changeset ed4c2de9fa70 from bug 112294 - failing unit tests
This commit is contained in:
Родитель
512a636390
Коммит
483e638bb9
|
@ -693,7 +693,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEventStateManager)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLastFocus);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLastContentFocus);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstBlurEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstDocumentBlurEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstFocusEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstMouseOverEventElement);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFirstMouseOutEventElement);
|
||||
|
@ -717,7 +716,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsEventStateManager)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLastFocus);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLastContentFocus);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBlurEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstDocumentBlurEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstFocusEvent);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOverEventElement);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstMouseOutEventElement);
|
||||
|
@ -1092,32 +1090,29 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
// Clear our global variables before firing the event to prevent
|
||||
// duplicate blur events (bug 112294).
|
||||
nsCOMPtr<nsIDocument> lastFocusedDocument;
|
||||
lastFocusedDocument.swap(gLastFocusedDocument);
|
||||
nsCOMPtr<nsPresContext> lastFocusedPresContext;
|
||||
lastFocusedPresContext.swap(gLastFocusedPresContext);
|
||||
mCurrentTarget = nsnull;
|
||||
|
||||
// fire blur on document and window
|
||||
if (lastFocusedDocument) {
|
||||
if (gLastFocusedDocument) {
|
||||
// get the window here, in case the event causes
|
||||
// gLastFocusedDocument to change.
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window(lastFocusedDocument->GetWindow());
|
||||
nsCOMPtr<nsPIDOMWindow> window(gLastFocusedDocument->GetWindow());
|
||||
|
||||
event.target = nsnull;
|
||||
nsEventDispatcher::Dispatch(lastFocusedDocument,
|
||||
lastFocusedPresContext,
|
||||
nsEventDispatcher::Dispatch(gLastFocusedDocument,
|
||||
gLastFocusedPresContext,
|
||||
&event, nsnull, &status);
|
||||
|
||||
if (window) {
|
||||
event.target = nsnull;
|
||||
nsEventDispatcher::Dispatch(window, lastFocusedPresContext,
|
||||
nsEventDispatcher::Dispatch(window, gLastFocusedPresContext,
|
||||
&event, nsnull, &status);
|
||||
}
|
||||
}
|
||||
|
||||
// Now clear our our global variables
|
||||
mCurrentTarget = nsnull;
|
||||
NS_IF_RELEASE(gLastFocusedDocument);
|
||||
gLastFocusedPresContext = nsnull;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1238,15 +1233,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
|
||||
// Now fire blurs. Blur the content, then the document, then the window.
|
||||
|
||||
if (gLastFocusedDocument && gLastFocusedDocument == mDocument &&
|
||||
gLastFocusedDocument != mFirstDocumentBlurEvent) {
|
||||
if (gLastFocusedDocument && gLastFocusedDocument == mDocument) {
|
||||
|
||||
PRBool clearFirstDocumentBlurEvent = PR_FALSE;
|
||||
if (!mFirstDocumentBlurEvent) {
|
||||
mFirstDocumentBlurEvent = gLastFocusedDocument;
|
||||
clearFirstDocumentBlurEvent = PR_TRUE;
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event(PR_TRUE, NS_BLUR_CONTENT);
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
|
@ -1276,12 +1264,6 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
// Clear our global variables before firing the event to prevent
|
||||
// duplicate blur events (bug 112294).
|
||||
mCurrentTarget = nsnull;
|
||||
NS_IF_RELEASE(gLastFocusedDocument);
|
||||
gLastFocusedPresContext = nsnull;
|
||||
|
||||
// fire blur on document and window
|
||||
event.target = nsnull;
|
||||
nsEventDispatcher::Dispatch(mDocument, aPresContext, &event, nsnull,
|
||||
|
@ -1292,9 +1274,11 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
|||
nsEventDispatcher::Dispatch(ourWindow, aPresContext, &event, nsnull,
|
||||
&status);
|
||||
}
|
||||
if (clearFirstDocumentBlurEvent) {
|
||||
mFirstDocumentBlurEvent = nsnull;
|
||||
}
|
||||
|
||||
// Now clear our our global variables
|
||||
mCurrentTarget = nsnull;
|
||||
NS_IF_RELEASE(gLastFocusedDocument);
|
||||
gLastFocusedPresContext = nsnull;
|
||||
}
|
||||
|
||||
if (focusController) {
|
||||
|
|
|
@ -379,7 +379,6 @@ protected:
|
|||
//Anti-recursive stack controls
|
||||
|
||||
nsCOMPtr<nsIContent> mFirstBlurEvent;
|
||||
nsCOMPtr<nsIDocument> mFirstDocumentBlurEvent;
|
||||
nsCOMPtr<nsIContent> mFirstFocusEvent;
|
||||
|
||||
// The last element on which we fired a mouseover event, or null if
|
||||
|
|
|
@ -45,7 +45,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_bug112294.html \
|
||||
test_bug238987.html \
|
||||
test_bug288392.html \
|
||||
test_bug328885.html \
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=112294
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 112294</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=112294">Mozilla Bug 112294</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 112294 **/
|
||||
|
||||
var countFocus = 0;
|
||||
var countBlur = 0;
|
||||
|
||||
function handleBlur()
|
||||
{
|
||||
++countBlur;
|
||||
if (countBlur < 5)
|
||||
{
|
||||
// Try to simulate an alert
|
||||
alert = window.open("about:blank", "Alert", "width=200,height=200");
|
||||
alert.focus();
|
||||
alert.close();
|
||||
}
|
||||
}
|
||||
|
||||
function handleFocus()
|
||||
{
|
||||
++countFocus;
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
window.focus();
|
||||
window.onblur = handleBlur;
|
||||
window.onfocus = handleFocus;
|
||||
|
||||
var popup = window.open("about:blank", "Bug 112294", "width=10,height=10");
|
||||
popup.focus();
|
||||
popup.close();
|
||||
setTimeout(finishTest, 0);
|
||||
}
|
||||
|
||||
function finishTest()
|
||||
{
|
||||
is(countFocus, 1, "onfocus count");
|
||||
is(countBlur, 1, "onblur count");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
setTimeout(doTest, 0);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -522,8 +522,7 @@ nsFocusController::SetSuppressFocus(PRBool aSuppressFocus, const char* aReason)
|
|||
//#endif
|
||||
}
|
||||
else
|
||||
// It's ok to unsuppress even if no suppression is active (bug 112294)
|
||||
return NS_OK;
|
||||
NS_ASSERTION(PR_FALSE, "Attempt to decrement focus controller's suppression when no suppression active!\n");
|
||||
|
||||
// we are unsuppressing after activating, so update focus-related commands
|
||||
// we need this to update command, including the case where there is no element
|
||||
|
|
|
@ -675,18 +675,8 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
|
|||
if (popupConditions)
|
||||
contextFlags |= nsIWindowCreator2::PARENT_IS_LOADING_OR_RUNNING_TIMEOUT;
|
||||
|
||||
PRBool parentVisible = PR_TRUE;
|
||||
if (parentChrome)
|
||||
{
|
||||
nsCOMPtr<nsIBaseWindow> parentWindow(do_GetInterface(parentTreeOwner));
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
if (parentWindow)
|
||||
parentWindow->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
if (parentWidget)
|
||||
parentWidget->IsVisible(parentVisible);
|
||||
}
|
||||
PRBool cancel = PR_FALSE;
|
||||
rv = windowCreator2->CreateChromeWindow2(parentVisible ? parentChrome : nsnull, chromeFlags,
|
||||
rv = windowCreator2->CreateChromeWindow2(parentChrome, chromeFlags,
|
||||
contextFlags, uriToLoad,
|
||||
&cancel,
|
||||
getter_AddRefs(newChrome));
|
||||
|
|
|
@ -1608,8 +1608,6 @@ PRBool nsWindow::CanTakeFocus()
|
|||
|
||||
NS_METHOD nsWindow::Show(PRBool bState)
|
||||
{
|
||||
mIsVisible = bState;
|
||||
|
||||
if (mWnd) {
|
||||
if (bState) {
|
||||
if (!mIsVisible && mWindowType == eWindowType_toplevel) {
|
||||
|
@ -1674,6 +1672,8 @@ NS_METHOD nsWindow::Show(PRBool bState)
|
|||
Invalidate(PR_FALSE);
|
||||
#endif
|
||||
|
||||
mIsVisible = bState;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -478,31 +478,23 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
|||
mWindow->Show(PR_FALSE);
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
// We need to explicitly set the focus on Windows, but
|
||||
// only if the parent is visible.
|
||||
// We need to explicitly set the focus on Windows
|
||||
nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
|
||||
if (parent) {
|
||||
PRBool parentVisible = PR_TRUE;
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
parent->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
if (parentWidget)
|
||||
parentWidget->IsVisible(parentVisible);
|
||||
if (parentVisible) {
|
||||
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
|
||||
if (appShell) {
|
||||
nsCOMPtr<nsIXULWindow> hiddenWindow;
|
||||
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
|
||||
if (hiddenWindow)
|
||||
baseHiddenWindow = do_GetInterface(hiddenWindow);
|
||||
}
|
||||
// somebody screwed up somewhere. hiddenwindow shouldn't be anybody's
|
||||
// parent. still, when it happens, skip activating it.
|
||||
if (baseHiddenWindow != parent) {
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
parent->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
if (parentWidget)
|
||||
parentWidget->PlaceBehind(eZPlacementTop, 0, PR_TRUE);
|
||||
}
|
||||
nsCOMPtr<nsIBaseWindow> baseHiddenWindow;
|
||||
if (appShell) {
|
||||
nsCOMPtr<nsIXULWindow> hiddenWindow;
|
||||
appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
|
||||
if (hiddenWindow)
|
||||
baseHiddenWindow = do_GetInterface(hiddenWindow);
|
||||
}
|
||||
// somebody screwed up somewhere. hiddenwindow shouldn't be anybody's
|
||||
// parent. still, when it happens, skip activating it.
|
||||
if (baseHiddenWindow != parent) {
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
parent->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
if (parentWidget)
|
||||
parentWidget->PlaceBehind(eZPlacementTop, 0, PR_TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче