function selectArea()
{ var copyArea = document.getElementById("copy-area");
copyArea.focus();
copyArea.select();
synthesizeKey("x", { accelKey: true });
if (supportsSelectionClipboard) { var clipboardHelper = SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(SpecialPowers.Ci.nsIClipboardHelper);
clipboardHelper.copyStringToClipboard("COPY TEXT",
SpecialPowers.Ci.nsIClipboard.kSelectionClipboard);
}
setTimeout(checkSelectionClipboardText, 50, 0);
}
var selectionPasted = false; var globalPasted = false;
function pasteArea()
{ var pasteArea = document.getElementById("paste-selection-area"); var pasteAreaRect = pasteArea.getBoundingClientRect(); var pasteAreaCenterX = pasteAreaRect.left + pasteAreaRect.width/2; var pasteAreaCenterY = pasteAreaRect.top + pasteAreaRect.height/2; var util = SpecialPowers.getDOMWindowUtils(window);
var usesMouseButtonPaste = SpecialPowers.getBoolPref("middlemouse.paste");
if (usesMouseButtonPaste) {
// The data transfer should contain the selection data when the selection clipboard is supported,
// not the global clipboard data. var expectedText = supportsSelectionClipboard ? "COPY TEXT" : "CLIPBOARD";
is(document.getElementById("paste-selection-area").value, expectedText, "In pasteArea(): data pasted properly from selection");
ok(selectionPasted, "selection event fired");
}
else {
is(pasteArea.value, "", "data not pasted when middle click not supported");
}
var pasteArea = document.getElementById("paste-global-area");
pasteArea.focus();
synthesizeKey("v", { accelKey: true });
ok(globalPasted, "global event fired");
is(document.getElementById("paste-global-area").value, "CLIPBOARD", "data pasted properly from global clipboard");
SimpleTest.finish();
}
function pastedSelection(event)
{
ok(SpecialPowers.getBoolPref("middlemouse.paste"), "paste on middle click is valid");
// Mac and Windows shouldn't get here as the middle mouse preference is false by default
ok(!navigator.platform.includes("Mac") && !navigator.platform.includes("Win"), "middle click enabled on right platforms");
var expectedText = supportsSelectionClipboard ? "COPY TEXT" : "CLIPBOARD";
is(event.clipboardData.getData("text/plain"), expectedText, "In pastedSelection(): data pasted properly from selection");
selectionPasted = true;
}
function pastedGlobal(event)
{
// The data transfer should contain the global data.
is(event.clipboardData.getData("text/plain"), "CLIPBOARD", "data correct in global clipboard data transfer");
globalPasted = true;
}
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.