summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/browser/head.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/content/tests/browser/head.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/content/tests/browser/head.js')
-rw-r--r--toolkit/content/tests/browser/head.js123
1 files changed, 0 insertions, 123 deletions
diff --git a/toolkit/content/tests/browser/head.js b/toolkit/content/tests/browser/head.js
deleted file mode 100644
index d7ed7a9ff..000000000
--- a/toolkit/content/tests/browser/head.js
+++ /dev/null
@@ -1,123 +0,0 @@
-"use strict";
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "Promise",
- "resource://gre/modules/Promise.jsm");
-
-/**
- * A wrapper for the findbar's method "close", which is not synchronous
- * because of animation.
- */
-function closeFindbarAndWait(findbar) {
- return new Promise((resolve) => {
- if (findbar.hidden) {
- resolve();
- return;
- }
- findbar.addEventListener("transitionend", function cont(aEvent) {
- if (aEvent.propertyName != "visibility") {
- return;
- }
- findbar.removeEventListener("transitionend", cont);
- resolve();
- });
- findbar.close();
- });
-}
-
-function pushPrefs(...aPrefs) {
- let deferred = Promise.defer();
- SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve);
- return deferred.promise;
-}
-
-/**
- * Helper class for testing datetime input picker widget
- */
-class DateTimeTestHelper {
- constructor() {
- this.panel = document.getElementById("DateTimePickerPanel");
- this.panel.setAttribute("animate", false);
- this.tab = null;
- this.frame = null;
- }
-
- /**
- * Opens a new tab with the URL of the test page, and make sure the picker is
- * ready for testing.
- *
- * @param {String} pageUrl
- */
- async openPicker(pageUrl) {
- this.tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl);
- await BrowserTestUtils.synthesizeMouseAtCenter("input", {}, gBrowser.selectedBrowser);
- // If dateTimePopupFrame doesn't exist yet, wait for the binding to be attached
- if (!this.panel.dateTimePopupFrame) {
- await BrowserTestUtils.waitForEvent(this.panel, "DateTimePickerBindingReady")
- }
- this.frame = this.panel.dateTimePopupFrame;
- await this.waitForPickerReady();
- }
-
- async waitForPickerReady() {
- await BrowserTestUtils.waitForEvent(this.frame, "load", true);
- // Wait for picker elements to be ready
- await BrowserTestUtils.waitForEvent(this.frame.contentDocument, "PickerReady");
- }
-
- /**
- * Find an element on the picker.
- *
- * @param {String} selector
- * @return {DOMElement}
- */
- getElement(selector) {
- return this.frame.contentDocument.querySelector(selector);
- }
-
- /**
- * Find the children of an element on the picker.
- *
- * @param {String} selector
- * @return {Array<DOMElement>}
- */
- getChildren(selector) {
- return Array.from(this.getElement(selector).children);
- }
-
- /**
- * Click on an element
- *
- * @param {DOMElement} element
- */
- click(element) {
- EventUtils.synthesizeMouseAtCenter(element, {}, this.frame.contentWindow);
- }
-
- /**
- * Close the panel and the tab
- */
- async tearDown() {
- if (!this.panel.hidden) {
- let pickerClosePromise = new Promise(resolve => {
- this.panel.addEventListener("popuphidden", resolve, {once: true});
- });
- this.panel.hidePopup();
- this.panel.closePicker();
- await pickerClosePromise;
- }
- await BrowserTestUtils.removeTab(this.tab);
- this.tab = null;
- }
-
- /**
- * Clean up after tests. Remove the frame to prevent leak.
- */
- cleanup() {
- this.frame.remove();
- this.frame = null;
- this.panel.removeAttribute("animate");
- this.panel = null;
- }
-}