Backed out 1 changesets (bug 1428844) on request from johannh

Backed out changeset 44239d2b430a (bug 1428844)
This commit is contained in:
Coroiu Cristina 2018-01-23 14:02:25 +02:00
parent 8b570d5a30
commit fe07e42eba
6 changed files with 54 additions and 7 deletions

View File

@ -27,7 +27,7 @@ function test() {
open_preferences(async function tabOpened(aContentWindow) {
is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");
let dialog = await openAndLoadSubDialog(connectionURL);
let dialogClosingPromise = BrowserTestUtils.waitForEvent(dialog.document.documentElement, "dialogclosing");
let dialogClosingPromise = waitForEvent(dialog.document.documentElement, "dialogclosing");
ok(dialog, "connection window opened");
runConnectionTests(dialog);

View File

@ -50,7 +50,7 @@ function test() {
}
dialog = await openAndLoadSubDialog(connectionURL);
dialogClosingPromise = BrowserTestUtils.waitForEvent(dialog.document.documentElement, "dialogclosing");
dialogClosingPromise = waitForEvent(dialog.document.documentElement, "dialogclosing");
doc = dialog.document;
proxyTypePref = dialog.Preferences.get("network.proxy.type");

View File

@ -33,12 +33,12 @@ add_task(async function() {
ok(!checkbox.checked, "Checkbox should not be checked by default");
ok(!alertService.manualDoNotDisturb, "Do not disturb should be off by default");
let checkboxChanged = BrowserTestUtils.waitForEvent(checkbox, "command");
let checkboxChanged = waitForEvent(checkbox, "command");
checkbox.click();
await checkboxChanged;
ok(alertService.manualDoNotDisturb, "Do not disturb should be enabled when checked");
checkboxChanged = BrowserTestUtils.waitForEvent(checkbox, "command");
checkboxChanged = waitForEvent(checkbox, "command");
checkbox.click();
await checkboxChanged;
ok(!alertService.manualDoNotDisturb, "Do not disturb should be disabled when unchecked");

View File

@ -46,7 +46,7 @@ function test() {
open_preferences(async function tabOpened(aContentWindow) {
is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");
let dialog = await openAndLoadSubDialog(connectionURL);
let dialogClosingPromise = BrowserTestUtils.waitForEvent(dialog.document.documentElement, "dialogclosing");
let dialogClosingPromise = waitForEvent(dialog.document.documentElement, "dialogclosing");
ok(dialog, "connection window opened");
dialog.document.documentElement.acceptDialog();

View File

@ -140,7 +140,7 @@ add_task(async function() {
// Open a test site which would save into quota manager
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_QUOTA_USAGE_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
await BrowserTestUtils.waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
let updatedPromise = promiseSiteDataManagerSitesUpdated();
@ -224,7 +224,7 @@ add_task(async function() {
await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_QUOTA_USAGE_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
await BrowserTestUtils.waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await waitForEvent(gBrowser.selectedBrowser.contentWindowAsCPOW, "test-indexedDB-done");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true });

View File

@ -74,6 +74,53 @@ function promiseLoadSubDialog(aURL) {
});
}
/**
* Waits a specified number of miliseconds for a specified event to be
* fired on a specified element.
*
* Usage:
* let receivedEvent = waitForEvent(element, "eventName");
* // Do some processing here that will cause the event to be fired
* // ...
* // Now yield until the Promise is fulfilled
* yield receivedEvent;
* if (receivedEvent && !(receivedEvent instanceof Error)) {
* receivedEvent.msg == "eventName";
* // ...
* }
*
* @param aSubject the element that should receive the event
* @param aEventName the event to wait for
* @param aTimeoutMs the number of miliseconds to wait before giving up
* @returns a Promise that resolves to the received event, or to an Error
*/
function waitForEvent(aSubject, aEventName, aTimeoutMs, aTarget) {
let eventDeferred = Promise.defer();
let timeoutMs = aTimeoutMs || kDefaultWait;
let stack = new Error().stack;
let timerID = setTimeout(function wfe_canceller() {
aSubject.removeEventListener(aEventName, listener);
eventDeferred.reject(new Error(aEventName + " event timeout at " + stack));
}, timeoutMs);
var listener = function(aEvent) {
if (aTarget && aTarget !== aEvent.target)
return;
// stop the timeout clock and resume
clearTimeout(timerID);
eventDeferred.resolve(aEvent);
};
function cleanup(aEventOrError) {
// unhook listener in case of success or failure
aSubject.removeEventListener(aEventName, listener);
return aEventOrError;
}
aSubject.addEventListener(aEventName, listener);
return eventDeferred.promise.then(cleanup, cleanup);
}
function openPreferencesViaOpenPreferencesAPI(aPane, aOptions) {
return new Promise(resolve => {
let finalPrefPaneLoaded = TestUtils.topicObserved("sync-pane-loaded", () => true);