Skip to content

Commit 5408be2

Browse files
committed
Merge pull request mozilla#1972 from yurydelendik/notification-box-1
Finds correct window/notification box for fallback message
2 parents 7bfd74f + 4de0d31 commit 5408be2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

extensions/firefox/components/PdfStreamConverter.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,26 @@ ChromeActions.prototype = {
219219
var strings = getLocalizedStrings('chrome.properties');
220220
var message = getLocalizedString(strings, 'unsupported_feature');
221221

222-
var win = Services.wm.getMostRecentWindow('navigator:browser');
223-
var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document);
224-
var notificationBox = win.gBrowser.getNotificationBox(browser);
222+
var notificationBox = null;
223+
// Multiple browser windows can be opened, finding one for notification box
224+
var windowsEnum = Services.wm
225+
.getZOrderDOMWindowEnumerator('navigator:browser', true);
226+
while (windowsEnum.hasMoreElements()) {
227+
var win = windowsEnum.getNext();
228+
if (win.closed)
229+
continue;
230+
var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document);
231+
if (browser) {
232+
// right window/browser is found, getting the notification box
233+
notificationBox = win.gBrowser.getNotificationBox(browser);
234+
break;
235+
}
236+
}
237+
if (!notificationBox) {
238+
log('Unable to get a notification box for the fallback message');
239+
return;
240+
}
241+
225242
// Flag so we don't call the response callback twice, since if the user
226243
// clicks open with different viewer both the button callback and
227244
// eventCallback will be called.

0 commit comments

Comments
 (0)