async function closeContextMenu() {
let contextMenu = document.getElementById("contentAreaContextMenu");
let awaitPopupHidden = BrowserTestUtils.waitForEvent(
contextMenu, "popuphidden"
);
contextMenu.hidePopup();
await awaitPopupHidden;
}
async function testWithDomain(domain) { // Passing a query to make sure the next load is never a same-document // navigation.
let dummy = dummyPageURL("example.org", "?start");
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, dummy);
let browser = tab.linkedBrowser;
let sel = await SpecialPowers.spawn(browser, [], function () {
let sel = content.getSelection();
sel.removeAllRanges();
sel.selectAllChildren(content.document.body); return sel.toString();
});
await openContextMenu(browser);
let copyItem = document.getElementById("context-copy");
ok(!copyItem.disabled, "Copy item should be enabled if text is selected.");
let sel2 = await SpecialPowers.spawn(browser, [], function () { return content.getSelection().toString();
});
is(sel, sel2, "Selection should remain when coming out of BFCache.");
await openContextMenu(browser);
ok(!copyItem.disabled, "Copy item should be enabled if text is selected.");
await closeContextMenu();
await BrowserTestUtils.removeTab(tab);
}
add_task(async function testValidSameOrigin() {
await testWithDomain("example.org");
});
add_task(async function testValidCrossOrigin() {
await testWithDomain("example.com");
});
add_task(async function testInvalid() {
await testWithDomain("this.is.invalid");
});
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
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 ist noch experimentell.