diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2017-02-04 19:12:34 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2017-02-04 19:12:34 +0100 |
commit | 32c4bd8b6b49c44a28eb47464208f60881c2d2ca (patch) | |
tree | c38d6c880de6c49c86c51af50a97050cb17eb7a1 /toolkit/components | |
parent | dfe35096e39043f5f902860ae58dc9b8b0bf93d1 (diff) | |
download | palemoon-gre-32c4bd8b6b49c44a28eb47464208f60881c2d2ca.tar.gz |
Run (Desktop) Notification twice (and more) in a row does not work
Diffstat (limited to 'toolkit/components')
-rw-r--r-- | toolkit/components/alerts/resources/content/alert.js | 28 | ||||
-rw-r--r-- | toolkit/components/alerts/resources/content/alert.xul | 1 |
2 files changed, 27 insertions, 2 deletions
diff --git a/toolkit/components/alerts/resources/content/alert.js b/toolkit/components/alerts/resources/content/alert.js index 6d1ad49e8..e97c0c23d 100644 --- a/toolkit/components/alerts/resources/content/alert.js +++ b/toolkit/components/alerts/resources/content/alert.js @@ -12,7 +12,21 @@ const Cc = Components.classes; var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"] .getService(Ci.nsIWindowMediator); -// Copied from nsILookAndFeel.h, see comments on eMetric_AlertNotificationOrigin +/* + * This indicates from which corner of the screen alerts slide in, + * and from which direction (horizontal/vertical). + * 0, the default, represents bottom right, sliding vertically. + * Use any bitwise combination of the following constants: + * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4). + * + * 6 4 + * +-----------+ + * 7| |5 + * | | + * 3| |1 + * +-----------+ + * 2 0 + */ const NS_ALERT_HORIZONTAL = 1; const NS_ALERT_LEFT = 2; const NS_ALERT_TOP = 4; @@ -39,6 +53,8 @@ function prefillAlertInfo() { // arguments[8] --> replaced alert window (nsIDOMWindow) // arguments[9] --> an optional callback listener (nsIObserver) + document.getElementById('alertTime').setAttribute('value', (new Date).getTime()); + switch (window.arguments.length) { default: case 10: @@ -143,7 +159,15 @@ function moveWindowToEnd() { let windows = windowMediator.getEnumerator('alert:alert'); while (windows.hasMoreElements()) { let alertWindow = windows.getNext(); - if (alertWindow != window) { + let alertWindowTime = Number( + alertWindow.document.getElementById('alertTime').getAttribute('value')); + let windowTime = Number( + window.document.getElementById('alertTime').getAttribute('value')); + // The time of window creation. + // Otherwise calling the notification twice (and more) in a row + // does not work. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1263155 + if ((alertWindow != window) && (alertWindowTime <= windowTime)) { if (gOrigin & NS_ALERT_TOP) { y = Math.max(y, alertWindow.screenY + alertWindow.outerHeight); } else { diff --git a/toolkit/components/alerts/resources/content/alert.xul b/toolkit/components/alerts/resources/content/alert.xul index 6850aa50a..1a9eefd29 100644 --- a/toolkit/components/alerts/resources/content/alert.xul +++ b/toolkit/components/alerts/resources/content/alert.xul @@ -24,6 +24,7 @@ <script type="application/javascript" src="chrome://global/content/alerts/alert.js"/> <box id="alertBox" class="alertBox"> + <label id="alertTime" value="" hidden="true"/> <box> <hbox id="alertImageBox" class="alertImageBox" align="center" pack="center"> <image id="alertImage"/> |