Closed Bug 940300 Opened 11 years ago Closed 1 year ago

alerts in content fail in xulrunner apps

Categories

(Toolkit Graveyard :: Notifications and Alerts, defect)

defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: markh, Unassigned)

References

Details

From Dominik in bug 875157 comment 40: Hello! I am embedding Mozilla Browser by using XulRunner and since Version 24.0 all alerts within a web page don't work anymore. Reason: toolkit/components/prompts/src/nsPrompter.js line 380: winUtils.isParentWindowMainWidgetVisible throws a NS_ERROR_NOT_AVAILABLE exception. (the exception is NOT thrown in line 381 where an error is returned when the window is not visible). -------------------- 367 function openModalWindow(domWin, uri, args) { 368 // There's an implied contract that says modal prompts should still work 369 // when no "parent" window is passed for the dialog (eg, the "Master 370 // Password" dialog does this). These prompts must be shown even if there 371 // are *no* visible windows at all. 372 // There's also a requirement for prompts to be blocked if a window is 373 // passed and that window is hidden (eg, auth prompts are supressed if the 374 // passed window is the hidden window). 375 // See bug 875157 comment 30 for more... 376 if (domWin) { 377 // a domWin was passed, so we can apply the check for it being hidden. 378 let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor) 379 .getInterface(Ci.nsIDOMWindowUtils); 380 if (winUtils && !winUtils.isParentWindowMainWidgetVisible) { 381 throw Components.Exception("Cannot call openModalWindow on a hidden window", 382 Cr.NS_ERROR_NOT_AVAILABLE); 383 } 384 } else { 385 // We try and find a window to use as the parent, but don't consider 386 // if that is visible before showing the prompt. 387 domWin = Services.ww.activeWindow; 388 // domWin may still be null here if there are _no_ windows open. 389 } 390 // Note that we don't need to fire DOMWillOpenModalDialog and 391 // DOMModalDialogClosed events here, wwatcher's OpenWindowInternal 392 // will do that. Similarly for enterModalState / leaveModalState. 393 394 Services.ww.openWindow(domWin, uri, "_blank", "centerscreen,chrome,modal,titlebar", args); 395 } -------------------- I've debugged this function and figured out that in line 3297 of dom/base/nsDOMWindowUtils.cpp the call to parentWindow->GetMainWidget(getter_AddRefs(parentWidget)) returns NULL. -------------------- 3279 nsDOMWindowUtils::GetIsParentWindowMainWidgetVisible(bool* aIsVisible) 3280 { 3281 if (!nsContentUtils::IsCallerChrome()) { 3282 return NS_ERROR_DOM_SECURITY_ERR; 3283 } 3284 3285 // this should reflect the "is parent window visible" logic in 3286 // nsWindowWatcher::OpenWindowInternal() 3287 nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow); 3288 NS_ENSURE_STATE(window); 3289 3290 nsCOMPtr<nsIWidget> parentWidget; 3291 nsIDocShell *docShell = window->GetDocShell(); 3292 if (docShell) { 3293 nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner; 3294 docShell->GetTreeOwner(getter_AddRefs(parentTreeOwner)); 3295 nsCOMPtr<nsIBaseWindow> parentWindow(do_GetInterface(parentTreeOwner)); 3296 if (parentWindow) { 3297 parentWindow->GetMainWidget(getter_AddRefs(parentWidget)); 3298 } 3299 } 3300 if (!parentWidget) { 3301 return NS_ERROR_NOT_AVAILABLE; 3302 } 3303 3304 *aIsVisible = parentWidget->IsVisible(); 3305 return NS_OK; 3306 } -------------------- parentWindow was resolved to an instance of nsDocShellTreeOwner (embedding/browser/webBrowser/nsDocShellTreeOwner.cpp) and there the method GetMainWindow always returns NULL: -------------------- 647 NS_IMETHODIMP 648 nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget) 649 { 650 return NS_ERROR_NULL_POINTER; 651 } -------------------- What can i do to fix this problem?
Update: If I test a standalone XUL Application (as described in https://developer.mozilla.org/de/docs/Getting_started_with_XULRunner, containing a browser which displays an alert) with XulRunner 24.0, parentWindow resolves to an instance of xpfe\appshell\src\nsContentTreeOwner.cpp, and the alert succeeds. But in my case (embedding the browser like Eclipse SWT does; via XRE_InitEmbedding2 ...) it resolves to the "empty" embedding/browser/webBrowser/nsDocShellTreeOwner.cpp.
Bulk move to Toolkit::Notifications and Alerts Filter on notifications-and-alerts-component.
Component: General → Notifications and Alerts
Severity: normal → S3

XULRunner is no longer maintained, I'm afraid.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → INVALID
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.