зеркало из https://github.com/mozilla/gecko-dev.git
Bug 907062, resolve the promise if the popup is already open so that the test doesn't occasionally fail, r=paolo
This commit is contained in:
Родитель
de518c3819
Коммит
c3c6d3fde3
|
@ -191,12 +191,19 @@ const DownloadsPanel = {
|
|||
//// Panel interface
|
||||
|
||||
/**
|
||||
* Main panel element in the browser window.
|
||||
* Main panel element in the browser window, or null if the panel overlay
|
||||
* hasn't been loaded yet.
|
||||
*/
|
||||
get panel()
|
||||
{
|
||||
// If the downloads panel overlay hasn't loaded yet, just return null
|
||||
// without reseting this.panel.
|
||||
let downloadsPanel = document.getElementById("downloadsPanel");
|
||||
if (!downloadsPanel)
|
||||
return null;
|
||||
|
||||
delete this.panel;
|
||||
return this.panel = document.getElementById("downloadsPanel");
|
||||
return this.panel = downloadsPanel;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,9 @@ function test_task()
|
|||
];
|
||||
|
||||
try {
|
||||
// Wait for focus first
|
||||
yield promiseFocus();
|
||||
|
||||
// Ensure that state is reset in case previous tests didn't finish.
|
||||
yield task_resetState();
|
||||
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
*/
|
||||
function test_task()
|
||||
{
|
||||
// Clear the download panel has shown preference first as this test is used to
|
||||
// verify this preference's behaviour.
|
||||
let oldPrefValue = true;
|
||||
try {
|
||||
oldPrefValue = Services.prefs.getBoolPref("browser.download.panel.shown");
|
||||
} catch(ex) { }
|
||||
Services.prefs.setBoolPref("browser.download.panel.shown", false);
|
||||
|
||||
try {
|
||||
// Ensure that state is reset in case previous tests didn't finish.
|
||||
yield task_resetState();
|
||||
|
@ -49,5 +57,9 @@ function test_task()
|
|||
} finally {
|
||||
// Clean up when the test finishes.
|
||||
yield task_resetState();
|
||||
// Set the preference instead of clearing it afterwards to ensure the
|
||||
// right value is used no matter what the default was. This ensures the
|
||||
// panel doesn't appear and affect other tests.
|
||||
Services.prefs.setBoolPref("browser.download.panel.shown", oldPrefValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,10 @@ function promisePanelOpened()
|
|||
{
|
||||
let deferred = Promise.defer();
|
||||
|
||||
if (DownloadsPanel.panel && DownloadsPanel.panel.state == "open") {
|
||||
return deferred.resolve();
|
||||
}
|
||||
|
||||
// Hook to wait until the panel is shown.
|
||||
let originalOnPopupShown = DownloadsPanel.onPopupShown;
|
||||
DownloadsPanel.onPopupShown = function () {
|
||||
|
@ -75,9 +79,6 @@ function task_resetState()
|
|||
yield download.finalize(true);
|
||||
}
|
||||
|
||||
// Reset any prefs that might have been changed.
|
||||
Services.prefs.clearUserPref("browser.download.panel.shown");
|
||||
|
||||
DownloadsPanel.hidePanel();
|
||||
|
||||
yield promiseFocus();
|
||||
|
|
|
@ -148,3 +148,7 @@ user_pref("geo.provider.testing", true);
|
|||
// Background thumbnails in particular cause grief, and disabling thumbnails
|
||||
// in general can't hurt - we re-enable them when tests need them.
|
||||
user_pref("browser.pagethumbnails.capturing_disabled", true);
|
||||
|
||||
// Indicate that the download panel has been shown once so that whichever
|
||||
// download test runs first doesn't show the popup inconsistently.
|
||||
user_pref("browser.download.panel.shown", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче