const Cc = SpecialPowers.Cc;
const Ci = SpecialPowers.Ci;
function hasExpectedFlavors() { var cb = Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard);
ok(cb.hasDataMatchingFlavors(["text/plain"], cb.kGlobalClipboard), "The clipboard has text/plain");
ok(cb.hasDataMatchingFlavors(["text/html"], cb.kGlobalClipboard), "The clipboard has text/html");
if (navigator.appVersion.includes("Win")) {
ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], cb.kGlobalClipboard), "The clipboard has application/x-moz-nativehtml");
}
}
function collapseSelectionToChildAndExtend(divElement) {
is(divElement.childNodes.length, 1, "Expected exactly one child node."); var textChildNode = divElement.childNodes[0];
getSelection().collapse(textChildNode);
getSelection().extend(textChildNode, divElement.textContent.length);
}
function selectDependingOnAttributes(divElement) {
if (divElement.hasAttribute("data-collapse-selection-to-child-and-extend")) {
// Selecting text as follow comes closest to user behaviour.
collapseSelectionToChildAndExtend(divElement);
} else {
getSelection().selectAllChildren(divElement);
}
}
function nextTest() { vardiv = document.querySelector("#content>div");
if (!div) {
SimpleTest.finish();
return;
}
selectDependingOnAttributes(div);
var expected = div.hasAttribute("data-result") ? div.getAttribute("data-result") : div.textContent;
SimpleTest.waitForClipboard(expected, function() {
synthesizeKey("C", {accelKey: true});
}, function() {
ok(true, div.getAttribute("style") + " passed");
hasExpectedFlavors(); div.remove();
nextTest();
}, function() {
ok(false, "failed to copy the expected content to the clipboard");
SimpleTest.finish();
});
}
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.