Bug 1195295 - Fix browser_tab_detach_restore.js and browser_popupNotifications_4.js r=felipe

These tests seemed to rely on the synchronous infrastructure that the
now defunct SyncHandler for SessionStore provided. This moves them
to safer, more modern alternatives.

--HG--
extra : commitid : QYhBXsLvPO
extra : rebase_source : bea13b3d34d7375e8d1f44491844742f68d81c11
extra : __touch-noise__ : 4185659896
extra : histedit_source : bc0f22800f4976f8bd622c606ef47e245bd1a7be
This commit is contained in:
Mike Conley 2015-12-10 17:44:26 -05:00
Родитель f2127e9ebb
Коммит 3d567c8694
2 изменённых файлов: 6 добавлений и 28 удалений

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

@ -19,7 +19,7 @@ add_task(function*() {
yield new Promise(resolve => whenDelayedStartupFinished(win, resolve));
is(win.gBrowser.selectedBrowser.permanentKey, key, "Should have properly copied the permanentKey");
yield promiseWindowClosed(win);
yield BrowserTestUtils.closeWindow(win);
is(SessionStore.getClosedWindowCount(), 1, "Should have restore data for the closed window");

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

@ -46,41 +46,19 @@ function promiseTopicObserved(topic)
* The tab to load into.
* @param [optional] url
* The url to load, or the current url.
* @param [optional] event
* The load event type to wait for. Defaults to "load".
* @return {Promise} resolved when the event is handled.
* @resolves to the received event
* @rejects if a valid load event is not received within a meaningful interval
*/
function promiseTabLoadEvent(tab, url, eventType="load")
function promiseTabLoadEvent(tab, url)
{
let deferred = Promise.defer();
info("Wait tab event: " + eventType);
let browser = tab.linkedBrowser;
function handle(event) {
if (event.originalTarget != tab.linkedBrowser.contentDocument ||
event.target.location.href == "about:blank" ||
(url && event.target.location.href != url)) {
info("Skipping spurious '" + eventType + "'' event" +
" for " + event.target.location.href);
return;
}
clearTimeout(timeout);
tab.linkedBrowser.removeEventListener(eventType, handle, true);
info("Tab event received: " + eventType);
deferred.resolve(event);
if (url) {
browser.loadURI(url);
}
let timeout = setTimeout(() => {
if (tab.linkedBrowser)
tab.linkedBrowser.removeEventListener(eventType, handle, true);
deferred.reject(new Error("Timed out while waiting for a '" + eventType + "'' event"));
}, 30000);
tab.linkedBrowser.addEventListener(eventType, handle, true, true);
if (url)
tab.linkedBrowser.loadURI(url);
return deferred.promise;
return BrowserTestUtils.browserLoaded(browser, false, url);
}
const PREF_SECURITY_DELAY_INITIAL = Services.prefs.getIntPref("security.notification_enable_delay");