зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270277, HasDataMatchingFlavors should only return true for text/unicode, r=snorp
This commit is contained in:
Родитель
a4ee9d8df2
Коммит
780d816c25
|
@ -52,15 +52,22 @@ const Cc = SpecialPowers.Cc;
|
|||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
function hasExpectedFlavors() {
|
||||
var flavors = [
|
||||
"text/plain",
|
||||
"text/html",
|
||||
"application/x-moz-nativehtml",
|
||||
];
|
||||
var cb = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
return cb.hasDataMatchingFlavors(flavors, flavors.length,
|
||||
cb.kGlobalClipboard);
|
||||
|
||||
ok(cb.hasDataMatchingFlavors(["text/unicode"], 1, cb.kGlobalClipboard),
|
||||
"The clipboard has text/unicode");
|
||||
|
||||
// Android only supports plain text
|
||||
if (navigator.appVersion.indexOf("Android") == -1) {
|
||||
ok(cb.hasDataMatchingFlavors(["text/html"], 1, cb.kGlobalClipboard),
|
||||
"The clipboard has text/html");
|
||||
}
|
||||
|
||||
if (navigator.appVersion.indexOf("Win") >= 0) {
|
||||
ok(cb.hasDataMatchingFlavors(["application/x-moz-nativehtml"], 1, cb.kGlobalClipboard),
|
||||
"The clipboard has application/x-moz-nativehtml");
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
|
@ -77,7 +84,7 @@ function nextTest() {
|
|||
synthesizeKey("C", {accelKey: true});
|
||||
}, function() {
|
||||
ok(true, div.getAttribute("style") + " passed");
|
||||
ok(hasExpectedFlavors(), "The clipboard has the expected flavors");
|
||||
hasExpectedFlavors();
|
||||
div.parentNode.removeChild(div);
|
||||
nextTest();
|
||||
}, function() {
|
||||
|
|
|
@ -97,7 +97,14 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
|
|||
*aHasText = false;
|
||||
if (aWhichClipboard != kGlobalClipboard)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*aHasText = widget::Clipboard::HasText();
|
||||
|
||||
for (uint32_t k = 0; k < aLength; k++) {
|
||||
if (strcmp(aFlavorList[k], kUnicodeMime) == 0) {
|
||||
*aHasText = widget::Clipboard::HasText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче