Issue #2361 - Base implementation of Navigator.Clipboard

This hard-refuses any reads from clipboard with a promise rejection.
This commit is contained in:
Moonchild 2023-11-15 21:53:16 +01:00 committed by roytam1
commit 3478c01fc8
13 changed files with 327 additions and 11 deletions

View file

@ -1204,16 +1204,12 @@ DataTransfer::ConvertFromVariant(nsIVariant* aVariant,
return true;
}
char16_t* chrs;
uint32_t len = 0;
nsresult rv = aVariant->GetAsWStringWithSize(&len, &chrs);
nsAutoString str;
nsresult rv = aVariant->GetAsAString(str);
if (NS_FAILED(rv)) {
return false;
}
nsAutoString str;
str.Adopt(chrs, len);
nsCOMPtr<nsISupportsString>
strSupports(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
if (!strSupports) {
@ -1225,7 +1221,7 @@ DataTransfer::ConvertFromVariant(nsIVariant* aVariant,
strSupports.forget(aSupports);
// each character is two bytes
*aLength = str.Length() << 1;
*aLength = str.Length() * 2;
return true;
}
@ -1410,9 +1406,7 @@ DataTransfer::CacheExternalClipboardFormats()
return;
}
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
nsCOMPtr<nsIPrincipal> sysPrincipal;
ssm->GetSystemPrincipal(getter_AddRefs(sysPrincipal));
nsCOMPtr<nsIPrincipal> sysPrincipal = nsContentUtils::GetSystemPrincipal();
// Check if the clipboard has any files
bool hasFileData = false;