Bug 691389 - Error: win is null when performing drag&drop of a XPI file to Add-ons Manager tab. r=dtownsend

This commit is contained in:
Blair McBride 2012-01-05 01:17:52 +13:00
Родитель e1530b34b1
Коммит 025fdc5b88
2 изменённых файлов: 48 добавлений и 7 удалений

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

@ -3292,8 +3292,8 @@ var gDragDrop = {
if (pos == urls.length) { if (pos == urls.length) {
if (installs.length > 0) { if (installs.length > 0) {
// Display the normal install confirmation for the installs // Display the normal install confirmation for the installs
AddonManager.installAddonsFromWebpage("application/x-xpinstall", this, AddonManager.installAddonsFromWebpage("application/x-xpinstall",
null, installs); window, null, installs);
} }
return; return;
} }

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

@ -75,6 +75,17 @@ WindowOpenListener.prototype = {
} }
}; };
var gSawInstallNotification = false;
var gInstallNotificationObserver = {
observe: function(aSubject, aTopic, aData) {
var installInfo = aSubject.QueryInterface(Ci.amIWebInstallInfo);
isnot(installInfo.originatingWindow, null, "Notification should have non-null originatingWindow");
gSawInstallNotification = true;
Services.obs.removeObserver(this, "addon-install-started");
}
};
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
@ -113,9 +124,15 @@ function test_confirmation(aWindow, aExpectedURLs) {
add_test(function() { add_test(function() {
var url = TESTROOT + "addons/browser_dragdrop1.xpi"; var url = TESTROOT + "addons/browser_dragdrop1.xpi";
Services.obs.addObserver(gInstallNotificationObserver,
"addon-install-started", false);
new WindowOpenListener(INSTALL_URI, function(aWindow) { new WindowOpenListener(INSTALL_URI, function(aWindow) {
test_confirmation(aWindow, [url]); test_confirmation(aWindow, [url]);
}, run_next_test); }, function() {
is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
run_next_test();
});
var viewContainer = gManagerWindow.document.getElementById("view-port"); var viewContainer = gManagerWindow.document.getElementById("view-port");
var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer, var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer,
@ -128,9 +145,15 @@ add_test(function() {
add_test(function() { add_test(function() {
var fileurl = get_addon_file_url("browser_dragdrop1.xpi"); var fileurl = get_addon_file_url("browser_dragdrop1.xpi");
Services.obs.addObserver(gInstallNotificationObserver,
"addon-install-started", false);
new WindowOpenListener(INSTALL_URI, function(aWindow) { new WindowOpenListener(INSTALL_URI, function(aWindow) {
test_confirmation(aWindow, [fileurl.spec]); test_confirmation(aWindow, [fileurl.spec]);
}, run_next_test); }, function() {
is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
run_next_test();
});
var viewContainer = gManagerWindow.document.getElementById("view-port"); var viewContainer = gManagerWindow.document.getElementById("view-port");
var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer, var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer,
@ -144,9 +167,15 @@ add_test(function() {
var url1 = TESTROOT + "addons/browser_dragdrop1.xpi"; var url1 = TESTROOT + "addons/browser_dragdrop1.xpi";
var url2 = TESTROOT2 + "addons/browser_dragdrop2.xpi"; var url2 = TESTROOT2 + "addons/browser_dragdrop2.xpi";
Services.obs.addObserver(gInstallNotificationObserver,
"addon-install-started", false);
new WindowOpenListener(INSTALL_URI, function(aWindow) { new WindowOpenListener(INSTALL_URI, function(aWindow) {
test_confirmation(aWindow, [url1, url2]); test_confirmation(aWindow, [url1, url2]);
}, run_next_test); }, function() {
is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
run_next_test();
});
var viewContainer = gManagerWindow.document.getElementById("view-port"); var viewContainer = gManagerWindow.document.getElementById("view-port");
var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer, var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer,
@ -161,9 +190,15 @@ add_test(function() {
var fileurl1 = get_addon_file_url("browser_dragdrop1.xpi"); var fileurl1 = get_addon_file_url("browser_dragdrop1.xpi");
var fileurl2 = get_addon_file_url("browser_dragdrop2.xpi"); var fileurl2 = get_addon_file_url("browser_dragdrop2.xpi");
Services.obs.addObserver(gInstallNotificationObserver,
"addon-install-started", false);
new WindowOpenListener(INSTALL_URI, function(aWindow) { new WindowOpenListener(INSTALL_URI, function(aWindow) {
test_confirmation(aWindow, [fileurl1.spec, fileurl2.spec]); test_confirmation(aWindow, [fileurl1.spec, fileurl2.spec]);
}, run_next_test); }, function() {
is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
run_next_test();
});
var viewContainer = gManagerWindow.document.getElementById("view-port"); var viewContainer = gManagerWindow.document.getElementById("view-port");
var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer, var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer,
@ -178,9 +213,15 @@ add_test(function() {
var url = TESTROOT + "addons/browser_dragdrop1.xpi"; var url = TESTROOT + "addons/browser_dragdrop1.xpi";
var fileurl = get_addon_file_url("browser_dragdrop2.xpi"); var fileurl = get_addon_file_url("browser_dragdrop2.xpi");
Services.obs.addObserver(gInstallNotificationObserver,
"addon-install-started", false);
new WindowOpenListener(INSTALL_URI, function(aWindow) { new WindowOpenListener(INSTALL_URI, function(aWindow) {
test_confirmation(aWindow, [url, fileurl.spec]); test_confirmation(aWindow, [url, fileurl.spec]);
}, run_next_test); }, function() {
is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
run_next_test();
});
var viewContainer = gManagerWindow.document.getElementById("view-port"); var viewContainer = gManagerWindow.document.getElementById("view-port");
var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer, var effect = chromeUtils.synthesizeDrop(viewContainer, viewContainer,