Bug 573808 - "domWin is null" error with new prompting backend and no active window. r=gavin

This commit is contained in:
Justin Dolske 2010-06-23 17:54:05 -07:00
Родитель a169dc68ec
Коммит 210ce4b9d2
2 изменённых файлов: 27 добавлений и 15 удалений

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

@ -204,18 +204,6 @@ let PromptUtils = {
return [buttonLabels[0], buttonLabels[1], buttonLabels[2], defaultButtonNum, isDelayEnabled];
},
// Returns true if some listener requested that the default action be prevented.
fireEvent : function (domWin, eventType) {
// XXX main use of DOMWillOpenModalDialog is so tabbrowser can focus
// the tab opening the modal prompt. DOMModalDialogClosed is
// unused (until bug 429287).
// XXX Maybe make these observer notifications instead?
// oh, content can see these? That seems unfortunate. Esp. for auth.
let event = domWin.document.createEvent("Events");
event.initEvent(eventType, true, true);
return !domWin.dispatchEvent(event);
},
getAuthInfo : function (authInfo) {
let username, password;
@ -384,13 +372,12 @@ ModalPrompter.prototype = {
if (!domWin)
domWin = Services.ww.activeWindow;
// XXX domWin may still be null here if there are _no_ windows open.
// Note that we don't need to fire DOMWillOpenModalDialog and
// DOMModalDialogClosed events here, wwatcher's OpenWindowJSInternal
// will do that. Similarly for enterModalState / leaveModalState.
let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
Services.ww.openWindow(domWin, uri, "_blank", "centerscreen,chrome,modal,titlebar", args);
},

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

@ -637,6 +637,24 @@ function handleDialog(doc, testNum) {
clickOK = false;
break;
case 29:
// Alert, null window
state = {
msg : "This is the alert text.",
title : "TestTitle",
iconClass : "alert-icon",
textHidden : true,
passHidden : true,
checkHidden : true,
textValue : "",
passValue : "",
checkMsg : "",
checked : false,
};
checkExpectedState(doc, state);
break;
case 100:
// PromptAuth (no realm, ok, with checkbox)
state = {
@ -1023,6 +1041,13 @@ is(clickedButton, 2, "checked expected button num click");
is(checkVal.value, true, "expected checkbox setting");
ok(didDialog, "handleDialog was invoked");
// ===== test 29 =====
// Alert, no window
testNum++;
startCallbackTimer();
prompter.alert(null, "TestTitle", "This is the alert text.");
ok(didDialog, "handleDialog was invoked");
// promptAuth already tested via password manager but do a few specific things here.