Open Bug 475088 Opened 16 years ago Updated 2 years ago

Can't copy to the native clipboard in xpcshell based tests

Categories

(Core :: Widget, defect)

x86
Windows Vista
defect

Tracking

()

People

(Reporter: ehsan.akhgari, Unassigned)

References

()

Details

(Keywords: testcase)

The following code, if run inside an xpcshell based test, would run without any exceptions, but will not copy anything to the native clipboard: function copy(str) { Cc["@mozilla.org/widget/clipboardhelper;1"]. getService(Ci.nsIClipboardHelper). copyString(str); } Neither does this code: function copy(str_to_copy) { let str = Cc["@mozilla.org/supports-string;1"]. createInstance(Ci.nsISupportsString); str.data = str_to_copy; let trans = Cc["@mozilla.org/widget/transferable;1"]. createInstance(Ci.nsITransferable); trans.addDataFlavor("text/unicode"); trans.setTransferData("text/unicode", str, str_to_copy.length * 2); let clip = Cc["@mozilla.org/widget/clipboard;1"]. getService(Ci.nsIClipboard); clip.setData(trans, null, Ci.nsIClipboard.kGlobalClipboard); } I faced this when I was trying to write the test for bug 462106 as an xpcshell test. Eventually I gave up. I tried debugging the clipboard implementation while running these two pieces of code, and I went on to make sure that OleSetClipboard is being called in both cases without error. I'm not sure what's going wrong here at all.
Probably unlikely, but I don't suppose you're relying on our APIs to detect whether it was copied? Marco's discovered some issues with that in bug 474081.
(In reply to comment #1) > Probably unlikely, but I don't suppose you're relying on our APIs to detect > whether it was copied? Marco's discovered some issues with that in bug 474081. Nope, I see this problem with good ol' Ctrl+V. :-) The contents of the clipboard do not change.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.