Bug 509732 - Don't do slideIn animation if the height of the notification is 0. r=dtownsend

This commit is contained in:
Vivien Nicolas 2009-11-24 21:00:49 -08:00
Родитель d4881fd8e4
Коммит a2a597d568
3 изменённых файлов: 72 добавлений и 5 удалений

Просмотреть файл

@ -50,6 +50,7 @@ _TEST_FILES = test_bug360220.xul \
test_bug382990.xul \
test_bug457632.xul \
test_bug460942.xul \
test_bug509732.xul \
test_button.xul \
test_closemenu_attribute.xul \
test_colorpicker_popup.xul \

Просмотреть файл

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<!--
XUL Widget Test for bug 509732
-->
<window title="Bug 509732" width="500" height="600"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<notificationbox id="nb" hidden="true"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"
onload="test()"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
var gNotificationBox;
// Tests that a notification that is added in an hidden box didn't throw the animation
function test() {
SimpleTest.waitForExplicitFinish();
gNotificationBox = document.getElementById("nb");
is(gNotificationBox.allNotifications.length, 0, "There should be no initial notifications");
gNotificationBox.appendNotification("Test notification",
"notification1", null,
gNotificationBox.PRIORITY_INFO_LOW,
null);
is(gNotificationBox.allNotifications.length, 1, "Notification exists");
is(gNotificationBox._timer, null, "Notification timer should be null");
test1();
}
// Tests that a notification that is removed from an hidden box didn't throw the animation
function test1() {
let notification = gNotificationBox.getNotificationWithValue("notification1");
gNotificationBox.removeNotification(notification);
ok(!gNotificationBox.currentNotification, "Test 1 should show no current animation");
is(gNotificationBox._timer, null, "Notification timer should be null");
is(gNotificationBox.allNotifications.length, 0, "Test 1 should show no notifications present");
SimpleTest.finish();
}
]]>
</script>
</window>

Просмотреть файл

@ -64,7 +64,7 @@
<![CDATA[
var notifications = this.allNotifications;
for (var n = notifications.length - 1; n >= 0; n--) {
if (aValue == notifications[n].value)
if (aValue == notifications[n].getAttribute("value"))
return notifications[n];
}
return null;
@ -220,6 +220,7 @@
}
var height = aNotification.boxObject.height;
var skipAnimation = (height == 0);
var change = height / this.slideSteps;
var margin;
if (aSlideIn) {
@ -230,6 +231,12 @@
this.currentNotification = aNotification;
aNotification.style.removeProperty("position");
aNotification.style.removeProperty("top");
if (skipAnimation) {
this._setBlockingState(this.currentNotification);
return;
}
aNotification.style.marginTop = -height + "px";
aNotification.style.opacity = 0;
margin = -height;
@ -239,10 +246,15 @@
this._closedNotification = aNotification;
var notifications = this.allNotifications;
var idx = notifications.length - 1;
if (idx >= 0)
this.currentNotification = notifications[idx];
else
this.currentNotification = null;
this.currentNotification = (idx >= 0) ? notifications[idx] : null;
if (skipAnimation) {
this.removeChild(this._closedNotification);
this._closedNotification = null;
this._setBlockingState(this.currentNotification);
return;
}
var style = window.getComputedStyle(aNotification, null);
margin = style.getPropertyCSSValue("margin-top").
getFloatValue(CSSPrimitiveValue.CSS_PX);