Bug 1162952 - Return true from document.queryCommandEnabled('cut'/'copy') when in privileged or user-initiated code. r=ehsan

This commit is contained in:
Michael Layzell
2015-05-25 10:09:00 +02:00
parent 0f44ef05e2
commit 07d387cb7f
8 changed files with 89 additions and 4 deletions

View File

@@ -3353,6 +3353,19 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID, ErrorResult& rv)
return false;
}
// cut & copy are always allowed
bool isCutCopy = commandID.LowerCaseEqualsLiteral("cut") ||
commandID.LowerCaseEqualsLiteral("copy");
if (isCutCopy) {
return nsContentUtils::IsCutCopyAllowed();
}
// Report false for restricted commands
bool restricted = commandID.LowerCaseEqualsLiteral("paste");
if (restricted && !nsContentUtils::IsCallerChrome()) {
return false;
}
// if editing is not on, bail
if (!IsEditingOnAfterFlush()) {
rv.Throw(NS_ERROR_FAILURE);