Bug 1892976 - Stop throwing error on nsIClipboard::GetData() when the type isn't available on android; r=geckoview-reviewers,m_kato

Other platforms don't throw error; this patch makes android behave consistently
with other platforms.

Differential Revision: https://phabricator.services.mozilla.com/D208470
This commit is contained in:
Edgar Chen 2024-05-01 20:49:08 +00:00
parent 03fe5e116a
commit 01c5a3987a
2 changed files with 16 additions and 1 deletions

View file

@ -164,7 +164,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable,
} }
} }
return NS_ERROR_FAILURE; return NS_OK;
} }
nsresult nsClipboard::EmptyNativeClipboardData(int32_t aWhichClipboard) { nsresult nsClipboard::EmptyNativeClipboardData(int32_t aWhichClipboard) {

View file

@ -149,5 +149,20 @@ clipboardTypes.forEach(function (clipboardType) {
// Clear all clipboard data. // Clear all clipboard data.
cleanupAllClipboard(); cleanupAllClipboard();
}); });
add_task(function test_unsupport_flavor() {
try {
is(
getClipboardData("foo/bar", clipboardType),
null,
`Test getData for clipboard type ${clipboardType}`
);
} catch (e) {
ok(
false,
`getData should not throw error for clipboard type ${clipboardType}`
);
}
});
} }
}); });