fune/browser/base/content/test/trackingUI/head.js
Johann Hofmann 9764429134 Bug 1462470 - Part 6 - Add tests for the updated tracking protection UI in the identity popup. r=Paolo
This adds tests and moves the browser_trackingUI_1 test to the more general
trackingUI directory. The remaining TP tests will be moved in bug 1451307.

MozReview-Commit-ID: FHP4ULX0OQG

--HG--
rename : browser/base/content/test/general/browser_trackingUI_1.js => browser/base/content/test/trackingUI/browser_trackingUI_state.js
extra : rebase_source : 4f58e9f3aa3276536f43097257e312c6719a5cc6
2018-05-31 22:54:26 +02:00

32 lines
894 B
JavaScript

/**
* Waits for a load (or custom) event to finish in a given tab. If provided
* load an uri into the tab.
*
* @param tab
* The tab to load into.
* @param [optional] url
* The url to load, or the current url.
* @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) {
info("Wait tab event: load");
function handle(loadedUrl) {
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
info(`Skipping spurious load event for ${loadedUrl}`);
return false;
}
info("Tab event received: load");
return true;
}
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
if (url)
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
return loaded;
}