aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/clipboard.js25
-rw-r--r--tests/test-clipboard.js10
2 files changed, 25 insertions, 10 deletions
diff --git a/lib/clipboard.js b/lib/clipboard.js
index b87c477..ea14903 100644
--- a/lib/clipboard.js
+++ b/lib/clipboard.js
@@ -108,7 +108,7 @@ function createSupportsWString() {
createInstance(Ci.nsISupportsWString);
}
-var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod() {
+var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod(test) {
// currently the only possible flavors in Jetpack-prototype are "plain" and
// "html", i.e., "text/plain" (or text/unicode?) and "text/html" (or
// application/xml+xhtml?)
@@ -117,13 +117,18 @@ var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod() {
"text/plain": "plain",
"text/html": "html"
};
- var flavourArray = [];
-
- for (mime in possibleTypes) {
- var kSuppString = createSupportsWString();
- kSuppString.data = mime;
- // FIXME Missing some kind of if (mime in flavors) ...
- flavourArray.add(possibleTypes[mime]);
+ var flavorArray = [];
+ var clip = getClipboard();
+
+ for (var flavor in possibleTypes) {
+ var presentFlavor = clip.hasDataMatchingFlavors(
+ [flavor],
+ 1,
+ clip.kGlobalClipboard
+ );
+ if (presentFlavor) {
+ flavorArray.push(possibleTypes[flavor])
+ }
}
- return flavourArray;
-};
+ return flavorArray;
+}; \ No newline at end of file
diff --git a/tests/test-clipboard.js b/tests/test-clipboard.js
index 56cfeb8..07ff026 100644
--- a/tests/test-clipboard.js
+++ b/tests/test-clipboard.js
@@ -40,3 +40,13 @@ exports.ensureClipboardUnicode = function ensureClipboard(test) {
test.assertEqual(text, pushkinTestString,
"checking set and get clipboard methods (Unicode)");
};
+
+exports.ensureClipboardGetFlavors = function ensureClipboardGetFlavors(test) {
+ clip.set(pushkinTestString);
+ var available = clip.getCurrentFlavors();
+ console.log("available = " + available);
+ test.assertEqual(JSON.stringify(available),'["plain"]',
+ "checking getFlavors method");
+};
+
+// TODO: some weird mimeType which is not supported