ActiveState Community

Problem with nsIClipboard

Posted by dafi on 2009-11-12 00:24
OS: OS X

I've a strange problem with Komodo 5.2.2 inside extensions and macros.

The following code verifies if the clipboard contains HTML, when executed from Firefox (3.5.x) and Thunderbid (2.x and 3.0b4) it works like expected but when executed from Komodo it returns always false.

Under Komodo for Linux (32/64bit) and Windows it works fine under OSX Snow Leopard doesn't work.

Any idea?

To execute the snippet from Firefox or Thunderbid you can copy directly on Error Console Evaluate input box (be sure to put all in one single line)

To test simply select and copy some text from a web page then execute the code

var hasHTML = Components.classes["@mozilla.org/widget/clipboard;1"]
  .getService(Components.interfaces.nsIClipboard)
  .hasDataMatchingFlavors(
      ["text/html"], 1,
      Components.interfaces.nsIClipboard.kGlobalClipboard);
alert(hasHTML);
var hasHTML = Components.classes["@mozilla.org/widget/clipboard;1"]
  .getService(Components.interfaces.nsIClipboard)
  .hasDataMatchingFlavors(
      ["text/html"], 1,
      Components.interfaces.nsIClipboard.kGlobalClipboard);
alert(hasHTML);

ericp | Thu, 2009-11-12 11:44

I've written a bug up at
http://bugs.activestate.com/show_bug.cgi?id=85274

Which versions of FF and TB did you run this on?
More specifically, when you do [Help|About] on
them, what's the "rv" value? e.g.: for TB, I
get
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4pre) Gecko/20090915 Thunderbird/3.0b4

so the "rv"[1] is 1.9.1.4pre.

- Eric

[1] Moz version, no clue what "rv" is supposed to stand for.

ericp | Thu, 2009-11-12 12:16

On OSX, all string flavors are matched only by the MIME type of "text/unicode".

There's an easy fix, but it requires re-compiling Komodo (as opposed to
updating a JS or Python file).

- Eric

dafi | Thu, 2009-11-12 23:35

Maybe gecko version information is no more important due to the fact Moz handles only text MIME

Firefox - rv:1.9.1.5
TB 3.0b4 - 1.9.1.4pre

Any plan to fix this bug in next Komodo release?

Obviously also copy/paste from/to HTML format doesn't work, a little feature present on MoreKomodo that I use very often :P

--
dafi
Enhance KomodoEdit with MoreKomodo

ericp | Fri, 2009-11-13 10:34

The next version of Komodo will be built on Moz 1.9.1,
and you can get an early build right now, at
http://downloads.activestate.com/Komodo/nightly/komodoide/latest-trunk/
(or komodoedit if you use that).

- Eric

dafi | Mon, 2009-11-16 02:40

Thanks Eric

PS

Version six dot zero?? WOW

--
dafi
Enhance KomodoEdit with MoreKomodo