/** * COPIED FROM browser/base/content/test/general/head.js. * This function should be removed and replaced with BTU withNewTab calls * * 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.loadURIString(tab.linkedBrowser, url); } return loaded; } var gInvalidFormPopup = gBrowser.selectedBrowser.browsingContext.currentWindowGlobal .getActor("FormValidation") ._getAndMaybeCreatePanel(document); ok( gInvalidFormPopup, "The browser should have a popup to show when a form is invalid" ); function isWithinHalfPixel(a, b) { return Math.abs(a - b) <= 0.5; } function checkPopupShow(anchorRect) { ok( gInvalidFormPopup.state == "showing" || gInvalidFormPopup.state == "open", "[Test " + testId + "] The invalid form popup should be shown" ); // Just check the vertical position, as the horizontal position of an // arrow panel will be offset. is( isWithinHalfPixel(gInvalidFormPopup.screenY), isWithinHalfPixel(anchorRect.bottom), "popup top" ); } function checkPopupHide() { ok( gInvalidFormPopup.state != "showing" && gInvalidFormPopup.state != "open", "[Test " + testId + "] The invalid form popup should not be shown" ); } var testId = 0; function incrementTest() { testId++; info("Starting next part of test"); } function getDocHeader() { return "
" + getEmptyFrame(); } function getDocFooter() { return ""; } function getEmptyFrame() { return ( "