зеркало из https://github.com/mozilla/gecko-dev.git
Bug 715867 - Don't fire duplicate sizemodechange events on Mac. r=smichaud
--HG-- rename : widget/tests/window_bug596600.xul => widget/tests/empty_window.xul
This commit is contained in:
Родитель
cc35a16277
Коммит
9adc5ef72f
|
@ -1062,17 +1062,14 @@ NS_METHOD nsCocoaWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note bug 278777, we need to update state when the window is unminimized
|
|
||||||
// from the dock by users.
|
|
||||||
NS_METHOD nsCocoaWindow::SetSizeMode(PRInt32 aMode)
|
NS_METHOD nsCocoaWindow::SetSizeMode(PRInt32 aMode)
|
||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
PRInt32 previousMode;
|
// mSizeMode will be updated in DispatchSizeModeEvent, which will be called
|
||||||
nsBaseWidget::GetSizeMode(&previousMode);
|
// from a delegate method that handles the state change during one of the
|
||||||
|
// calls below.
|
||||||
nsresult rv = nsBaseWidget::SetSizeMode(aMode);
|
nsSizeMode previousMode = mSizeMode;
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (aMode == nsSizeMode_Normal) {
|
if (aMode == nsSizeMode_Normal) {
|
||||||
if ([mWindow isMiniaturized])
|
if ([mWindow isMiniaturized])
|
||||||
|
@ -1419,8 +1416,13 @@ nsCocoaWindow::ReportMoveEvent()
|
||||||
void
|
void
|
||||||
nsCocoaWindow::DispatchSizeModeEvent()
|
nsCocoaWindow::DispatchSizeModeEvent()
|
||||||
{
|
{
|
||||||
|
nsSizeMode newMode = GetWindowSizeMode(mWindow);
|
||||||
|
if (mSizeMode == newMode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mSizeMode = newMode;
|
||||||
nsSizeModeEvent event(true, NS_SIZEMODE, this);
|
nsSizeModeEvent event(true, NS_SIZEMODE, this);
|
||||||
event.mSizeMode = GetWindowSizeMode(mWindow);
|
event.mSizeMode = mSizeMode;
|
||||||
event.time = PR_IntervalNow();
|
event.time = PR_IntervalNow();
|
||||||
|
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
|
|
|
@ -87,6 +87,8 @@ _CHROME_FILES = test_bug343416.xul \
|
||||||
window_composition_text_querycontent.xul \
|
window_composition_text_querycontent.xul \
|
||||||
test_input_events_on_deactive_window.xul \
|
test_input_events_on_deactive_window.xul \
|
||||||
test_position_on_resize.xul \
|
test_position_on_resize.xul \
|
||||||
|
empty_window.xul \
|
||||||
|
test_sizemode_events.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# test_bug413277.html mac-only based on 604789, 605178
|
# test_bug413277.html mac-only based on 604789, 605178
|
||||||
|
@ -109,7 +111,6 @@ _CHROME_FILES += native_menus_window.xul \
|
||||||
bug586713_window.xul \
|
bug586713_window.xul \
|
||||||
test_key_event_counts.xul \
|
test_key_event_counts.xul \
|
||||||
test_bug596600.xul \
|
test_bug596600.xul \
|
||||||
window_bug596600.xul \
|
|
||||||
test_bug673301.xul \
|
test_bug673301.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
<window title="Window for Test for Mozilla Bug 596600"
|
<window title="Empty window"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
|
|
@ -36,9 +36,9 @@ function moveMouseTo(x, y, andThen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openWindows() {
|
function openWindows() {
|
||||||
gLeftWindow = open('window_bug596600.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
|
gLeftWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200');
|
||||||
SimpleTest.waitForFocus(function () {
|
SimpleTest.waitForFocus(function () {
|
||||||
gRightWindow = open('window_bug596600.xul', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
|
gRightWindow = open('empty_window.xul', '', 'chrome,screenX=300,screenY=50,width=200,height=200');
|
||||||
SimpleTest.waitForFocus(attachIFrameToRightWindow, gRightWindow);
|
SimpleTest.waitForFocus(attachIFrameToRightWindow, gRightWindow);
|
||||||
}, gLeftWindow);
|
}, gLeftWindow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||||
|
type="text/css"?>
|
||||||
|
<window title="Test for bug 715867"
|
||||||
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
|
||||||
|
<title>Test for bug 715867</title>
|
||||||
|
<script type="application/javascript"
|
||||||
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||||
|
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script class="testbody" type="application/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
|
||||||
|
gWindow = null;
|
||||||
|
|
||||||
|
gSizeModeDidChange = false;
|
||||||
|
gSizeModeDidChangeTo = 0;
|
||||||
|
|
||||||
|
function sizemodeChanged(e) {
|
||||||
|
gSizeModeDidChange = true;
|
||||||
|
gSizeModeDidChangeTo = gWindow.windowState;
|
||||||
|
}
|
||||||
|
|
||||||
|
function expectSizeModeChange(newMode, duringActionCallback) {
|
||||||
|
gSizeModeDidChange = false;
|
||||||
|
|
||||||
|
duringActionCallback();
|
||||||
|
|
||||||
|
if (newMode == 0) {
|
||||||
|
// No change should have taken place, no event should have fired.
|
||||||
|
ok(!gSizeModeDidChange, "No sizemodechange event should have fired.");
|
||||||
|
} else {
|
||||||
|
// Size mode change event was expected to fire.
|
||||||
|
ok(gSizeModeDidChange, "A sizemodechanged event should have fired.");
|
||||||
|
is(gSizeModeDidChangeTo, newMode, "The new sizemode should have the expected value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTest() {
|
||||||
|
if (navigator.platform.indexOf("Lin") != -1) {
|
||||||
|
ok(true, "This test is disabled on Linux because it expects window sizemode changes to be synchronous (which is not the case on Linux).");
|
||||||
|
SimpleTest.finish();
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
openWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWindow() {
|
||||||
|
gWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200,resizable');
|
||||||
|
SimpleTest.waitForFocus(runTest, gWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTest() {
|
||||||
|
// Install event handler.
|
||||||
|
gWindow.addEventListener("sizemodechange", sizemodeChanged, false);
|
||||||
|
|
||||||
|
// Run tests.
|
||||||
|
expectSizeModeChange(gWindow.STATE_MINIMIZED, function () {
|
||||||
|
gWindow.minimize();
|
||||||
|
});
|
||||||
|
|
||||||
|
expectSizeModeChange(gWindow.STATE_NORMAL, function () {
|
||||||
|
gWindow.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
expectSizeModeChange(gWindow.STATE_MAXIMIZED, function () {
|
||||||
|
gWindow.maximize();
|
||||||
|
});
|
||||||
|
|
||||||
|
expectSizeModeChange(gWindow.STATE_NORMAL, function () {
|
||||||
|
gWindow.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Normal window resizing shouldn't fire a sizemodechanged event, bug 715867.
|
||||||
|
expectSizeModeChange(0, function () {
|
||||||
|
gWindow.resizeTo(gWindow.outerWidth + 10, gWindow.outerHeight);
|
||||||
|
});
|
||||||
|
|
||||||
|
expectSizeModeChange(0, function () {
|
||||||
|
gWindow.resizeTo(gWindow.outerWidth, gWindow.outerHeight + 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
gWindow.removeEventListener("sizemodechange", sizemodeChanged, false);
|
||||||
|
gWindow.close();
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
SimpleTest.waitForFocus(startTest);
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</window>
|
Загрузка…
Ссылка в новой задаче