author | Neil Deakin <enndeakin@gmail.com> |
Thu, 06 Jan 2011 11:05:00 -0800 | |
changeset 60229 | 5e8b96f85355488871c18597d38635801dc2f8c8 |
parent 60228 | 556d2c5bef08e48abcd1010bb5ef1494e8de3b23 |
child 60230 | 310cfcff5588ff5abc2d09ada42f8a084511530a |
push id | 17890 |
push user | jdolske@mozilla.com |
push date | Sat, 08 Jan 2011 01:44:53 +0000 |
treeherder | mozilla-central@906f834203ff [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug, blocking |
bugs | 620145 |
milestone | 2.0b9pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -179,16 +179,17 @@ #include "nsCDefaultURIFixup.h" #include "nsEventDispatcher.h" #include "nsIObserverService.h" #include "nsIXULAppInfo.h" #include "nsNetUtil.h" #include "nsFocusManager.h" #include "nsIJSON.h" #include "nsIXULWindow.h" +#include "nsEventStateManager.h" #ifdef MOZ_XUL #include "nsXULPopupManager.h" #include "nsIDOMXULControlElement.h" #include "nsIFrame.h" #endif #include "xpcprivate.h" @@ -6261,16 +6262,29 @@ nsGlobalWindow::EnterModalState() nsGlobalWindow* topWin = GetTop(); if (!topWin) { NS_ERROR("Uh, EnterModalState() called w/o a reachable top window?"); return; } + // If there is an active ESM in this window, clear it. Otherwise, this can + // cause a problem if a modal state is entered during a mouseup event. + nsEventStateManager* activeESM = + static_cast<nsEventStateManager*>(nsEventStateManager::GetActiveEventStateManager()); + if (activeESM && activeESM->GetPresContext()) { + nsIPresShell* activeShell = activeESM->GetPresContext()->GetPresShell(); + if (activeShell && ( + nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(), mDoc) || + nsContentUtils::ContentIsCrossDocDescendantOf(mDoc, activeShell->GetDocument()))) { + nsEventStateManager::ClearGlobalActiveContent(activeESM); + } + } + if (topWin->mModalStateDepth == 0) { NS_ASSERTION(!mSuspendedDoc, "Shouldn't have mSuspendedDoc here!"); mSuspendedDoc = do_QueryInterface(topWin->GetExtantDocument()); if (mSuspendedDoc && mSuspendedDoc->EventHandlingSuppressed()) { mSuspendedDoc->SuppressEventHandling(); } else { mSuspendedDoc = nsnull;
--- a/toolkit/components/prompts/test/Makefile.in +++ b/toolkit/components/prompts/test/Makefile.in @@ -46,16 +46,17 @@ include $(DEPTH)/config/autoconf.mk # Module name for xpcshell tests. MODULE = test_prompter # Mochitest tests MOCHI_TESTS = \ test_modal_select.html \ test_modal_prompts.html \ test_bug619644.html \ + test_bug620145.html \ $(NULL) MOCHI_CONTENT = \ prompt_common.js \ bug619644_inner.html \ $(NULL) include $(topsrcdir)/config/rules.mk
new file mode 100644 --- /dev/null +++ b/toolkit/components/prompts/test/test_bug620145.html @@ -0,0 +1,51 @@ +<html> +<head> + <title>Test for Bug 620145</title> + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="prompt_common.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body onload="runtest()"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620145">Mozilla Bug 620145</a> +<pre id="test"> +</pre> + +<button id="button" onmouseup="alert('message\n');">Button</button> + +<script class="testbody" type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +var testNum = 0; + +function runtest() +{ + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + isTabModal = true; + startCallbackTimer(); + + var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils); + + var e = document.createEvent("MouseEvent"); + e.initEvent("mousedown", false, false, window, 0, 1, 1, 1, 1, + false, false, false, false, 0, null); + utils.dispatchDOMEventViaPresShell($("button"), e, true); + + e = document.createEvent("MouseEvent"); + e.initEvent("mouseup", false, false, window, 0, 1, 1, 1, 1, + false, false, false, false, 0, null); + utils.dispatchDOMEventViaPresShell($("button"), e, true); + + ok(true, "dialog closed"); + SimpleTest.finish(); +} + +function handleDialog(ui, testNum) +{ + synthesizeMouse(ui.button0, 5, 5, { }, ui.button0.ownerDocument.defaultView); +} +</script> + +</body> +</html>