/** *Assertsonthecontentsofthesharingmodal. *IfleaveOpenistrue,returnsthesharingmodalel. * *@param{Window}window-Chromewindowinwhichtoopenthemodal. *@param{object}expected-expectedresultobjectwithshape *{share,url,isSignedIn}. *@param{boolean}leaveOpen-Iftrue,themodalelementisreturnedand *thedialogisleftopen.Otherwisethedialog *isclosedwhentheassertisfinished.
*/
async function assertContentSharingModal(window, expected, leaveOpen = false) { // Wait for the modal to be fully rendered const modalEl = await TestUtils.waitForCondition(() =>
window.gDialogBox.dialog.frameContentWindow.document.querySelector( "content-sharing-modal"
)
);
await TestUtils.waitForCondition(() => BrowserTestUtils.isVisible(modalEl));
// If the modal is still loading, wait for the loadingPromise to resolve // before asserting on the final shareResult state. if (modalEl.loading) {
await TestUtils.waitForCondition(() => !modalEl.loading);
}
Assert.ok(window.gDialogBox.isOpen, "Content sharing modal should be open");
const laodedShareResult = modalEl.shareResult; Assert.deepEqual(
laodedShareResult,
expected, "The window has the expected arguments"
);
Assert.deepEqual(
modalEl.shareResult,
expected, "Modal has the expected share result"
);
await TestUtils.waitForCondition(
() => modalEl.links?.length === Math.min(expected.share.links.length, 3)
);
Assert.equal(
modalEl.title.innerText,
expected.share.title, "Modal has the correct share title"
);
if (expected.share.type !== "tabs") { Assert.equal(
modalEl.linkCount.innerText,
`${expected.share.links.length}`, "Modal has the correct link count"
);
}
Assert.equal(
modalEl.links.length,
Math.min(expected.share.links.length, 3), "Modal has the expected number of links. Max of 3 links"
);
if (expected.error) { Assert.ok(
BrowserTestUtils.isVisible(modalEl.errorMessageBar), "Error message is visible"
);
} elseif (expected.isSignedIn) { Assert.ok(
BrowserTestUtils.isVisible(modalEl.copyButton), "Copy button is visible"
);
} else { Assert.ok(
BrowserTestUtils.isVisible(modalEl.signInButton), "Sign in button is visible"
);
}
if (expected.share.links.length > 3) { if (expected.warning === WARNINGS.TOO_MANY_LINKS) { Assert.ok(
BrowserTestUtils.isVisible(modalEl.tooManyLinks), "Too many links warning is visible"
);
} else {
await TestUtils.waitForCondition(() =>
modalEl.moreLinks.innerText.startsWith(
`+${expected.share.links.length - 3}`
)
); Assert.ok(
modalEl.moreLinks.innerText.startsWith(
`+${expected.share.links.length - 3}`
),
`Modal has +${expected.share.links.length - 3} more links text`
);
}
}
if (leaveOpen) { return modalEl;
}
window.gDialogBox.dialog.close(); returnnull;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.