summaryrefslogtreecommitdiffstats
path: root/browser/components/screenshots/tests/browser/head.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/screenshots/tests/browser/head.js')
-rw-r--r--browser/components/screenshots/tests/browser/head.js50
1 files changed, 33 insertions, 17 deletions
diff --git a/browser/components/screenshots/tests/browser/head.js b/browser/components/screenshots/tests/browser/head.js
index a36e955830..762da5f866 100644
--- a/browser/components/screenshots/tests/browser/head.js
+++ b/browser/components/screenshots/tests/browser/head.js
@@ -159,23 +159,23 @@ class ScreenshotsHelper {
});
}
- waitForStateChange(newState) {
- return SpecialPowers.spawn(this.browser, [newState], async state => {
+ waitForStateChange(newStateArr) {
+ return SpecialPowers.spawn(this.browser, [newStateArr], async stateArr => {
let screenshotsChild = content.windowGlobalChild.getActor(
"ScreenshotsComponent"
);
await ContentTaskUtils.waitForCondition(() => {
- info(`got ${screenshotsChild.overlay.state}. expected ${state}`);
- return screenshotsChild.overlay.state === state;
- }, `Wait for overlay state to be ${state}`);
+ info(`got ${screenshotsChild.overlay.state}. expected ${stateArr}`);
+ return stateArr.includes(screenshotsChild.overlay.state);
+ }, `Wait for overlay state to be ${stateArr}`);
return screenshotsChild.overlay.state;
});
}
async assertStateChange(newState) {
- let currentState = await this.waitForStateChange(newState);
+ let currentState = await this.waitForStateChange([newState]);
is(
currentState,
@@ -269,18 +269,13 @@ class ScreenshotsHelper {
mouse.down(startX, startY);
- await Promise.any([
- this.waitForStateChange("draggingReady"),
- this.waitForStateChange("resizing"),
- ]);
+ await this.waitForStateChange(["draggingReady", "resizing"]);
Assert.ok(true, "The overlay is in the draggingReady or resizing state");
mouse.move(endX, endY);
- await Promise.any([
- this.waitForStateChange("dragging"),
- this.waitForStateChange("resizing"),
- ]);
+ await this.waitForStateChange(["dragging", "resizing"]);
+
Assert.ok(true, "The overlay is in the dragging or resizing state");
// We intentionally turn off this a11y check, because the following mouse
// event is emitted at the end of the dragging event. Its keyboard
@@ -324,7 +319,6 @@ class ScreenshotsHelper {
overlay.topRightMover.focus({ focusVisible: true });
break;
}
- screenshotsChild.overlay.highlightEl.focus();
for (let event of eventsArr) {
EventUtils.synthesizeKey(
@@ -354,7 +348,6 @@ class ScreenshotsHelper {
}
async scrollContentWindow(x, y) {
- let promise = BrowserTestUtils.waitForContentEvent(this.browser, "scroll");
let contentDims = await this.getContentDimensions();
await ContentTask.spawn(
this.browser,
@@ -404,7 +397,6 @@ class ScreenshotsHelper {
}, `Waiting for window to scroll to ${xPos}, ${yPos}`);
}
);
- await promise;
}
async waitForScrollTo(x, y) {
@@ -521,6 +513,15 @@ class ScreenshotsHelper {
});
}
+ getOverlaySelectionSizeText(elementId = "testPageElement") {
+ return ContentTask.spawn(this.browser, [elementId], async () => {
+ let screenshotsChild = content.windowGlobalChild.getActor(
+ "ScreenshotsComponent"
+ );
+ return screenshotsChild.overlay.selectionSize.textContent;
+ });
+ }
+
async clickTestPageElement(elementId = "testPageElement") {
let rect = await this.getTestPageElementRect(elementId);
let dims = await this.getContentDimensions();
@@ -909,6 +910,21 @@ add_setup(async () => {
);
let screenshotBtn = document.getElementById("screenshot-button");
Assert.ok(screenshotBtn, "The screenshots button was added to the nav bar");
+
+ registerCleanupFunction(async () => {
+ info(`downloads panel should be visible: ${DownloadsPanel.isPanelShowing}`);
+ if (DownloadsPanel.isPanelShowing) {
+ let hiddenPromise = BrowserTestUtils.waitForEvent(
+ DownloadsPanel.panel,
+ "popuphidden"
+ );
+ DownloadsPanel.hidePanel();
+ await hiddenPromise;
+ info(
+ `downloads panel should not be visible: ${DownloadsPanel.isPanelShowing}`
+ );
+ }
+ });
});
function getContentDevicePixelRatio(browser) {