forked from mirrors/gecko-dev
This enables the editor directory to be linted, and fixes the remaining issues raised by ESLint. Various rules were fixed here including, no-shadow, no-undef, no-unused-vars and others. I've generally gone conservative, disabling rules where it doesn't make sense to fix them (e.g. sometimes suggests use-services for tests, but it is only used once, or within a Chrome script). Depends on D5585 Differential Revision: https://phabricator.services.mozilla.com/D5587 --HG-- extra : moz-landing-system : lando
46 lines
1.6 KiB
HTML
46 lines
1.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
add_task(async function() {
|
|
let seenPaste = false;
|
|
let seenCopy = false;
|
|
document.addEventListener("copy", function oncpy(e) {
|
|
e.clipboardData.setData("text/plain", "my text");
|
|
e.preventDefault();
|
|
seenCopy = true;
|
|
}, {once: true});
|
|
document.addEventListener("paste", function onpst(e) {
|
|
is(e.clipboardData.getData("text/plain"), "my text",
|
|
"The correct text was read from the clipboard");
|
|
e.preventDefault();
|
|
seenPaste = true;
|
|
}, {once: true});
|
|
|
|
ok(SpecialPowers.wrap(document).execCommand("copy"),
|
|
"Call should succeed");
|
|
ok(seenCopy, "Successfully copied the text to the clipboard");
|
|
ok(SpecialPowers.wrap(document).execCommand("paste"),
|
|
"Call should succeed");
|
|
ok(seenPaste, "Successfully read text from the clipboard");
|
|
|
|
// Check that reading text from the clipboard in non-privileged contexts
|
|
// still doesn't work.
|
|
function onpstfail(e) {
|
|
ok(false, "Should not see paste event triggered by non-privileged call");
|
|
}
|
|
document.addEventListener("paste", onpstfail);
|
|
ok(!document.execCommand("paste"), "Call should fail");
|
|
document.removeEventListener("paste", onpstfail);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|