Bug 1340578 - Allow execCommand('paste') to be called from webextensions without a target, r=ehsan

This commit is contained in:
Michael Layzell
2017-09-07 13:41:13 -04:00
parent 3123b4340a
commit aac950f7c1
3 changed files with 53 additions and 4 deletions

View File

@@ -3242,9 +3242,10 @@ nsHTMLDocument::ExecCommand(const nsAString& commandID,
bool isCutCopy = (commandID.LowerCaseEqualsLiteral("cut") ||
commandID.LowerCaseEqualsLiteral("copy"));
bool isPaste = commandID.LowerCaseEqualsLiteral("paste");
// if editing is not on, bail
if (!isCutCopy && !IsEditingOnAfterFlush()) {
if (!isCutCopy && !isPaste && !IsEditingOnAfterFlush()) {
return false;
}
@@ -3285,9 +3286,8 @@ nsHTMLDocument::ExecCommand(const nsAString& commandID,
return false;
}
bool restricted = commandID.LowerCaseEqualsLiteral("paste");
if (restricted && !nsContentUtils::PrincipalHasPermission(&aSubjectPrincipal,
nsGkAtoms::clipboardRead)) {
if (isPaste && !nsContentUtils::PrincipalHasPermission(&aSubjectPrincipal,
nsGkAtoms::clipboardRead)) {
return false;
}