Closed Bug 369376 Opened 19 years ago Closed 10 years ago

CurrentPage.copyCurrentSelectionToSystemClipboard() does not work.

Categories

(Core Graveyard :: Embedding: GRE Core, defect)

1.8 Branch
x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: edburns, Assigned: edburns)

Details

Attachments

(1 file)

In FIREFOX1_5_0_9_RELEASE, webclient built with appliction=browser does not have this problem, while webclient built with application=xulrunner does. Problem: currentPage.copyCurrentSelectionToSystemClipboard() does not work.
I have found that in the app=firefox case, where the problem does not exist, the nsDataObj::GetData() and nsDataObj::GetText() methods are called, while in the xulrunner case, they are not. This is with the same java code in both cases. The only difference is the OBJDIR. For info on this, look at widget/src/windows/nsDataObj.cpp and set breakpoints in ::GetData and ::GetText. Find out why they are not getting called in the xulrunner case.
Status: NEW → ASSIGNED
It turns out that ::OleSetClipboard is failing in the XulRunner case with error -21747221008. Mook on IRC pointed out the usefulness of errlook.exe. Mook on IRC pointed out the usefulness of errlook.exe in MSVC++ to find out that means "CoInitialize has not been called". However, I'm finding that it is indeed called, in nsToolkit::nsToolkit(). Perhaps it's getting initialized and un-initialized before my code takes place?
I have determined that ::OleSetClipboard is returning -2147221008, which, when plugged in to Error Lookup says "CoInitialize has not been called.". However, I made sure to place an extra call to ::CoInitialize(NULL) right before calling into mozilla code from my embedding code. This invocation returned S_FALSE, which means CoInitialize(NULL) has already been called on this thread.
Ok, I don't think the problem is that ::CoInitialize has not been called. I modified widget/src/windows/nsClipboard.cpp nsClipboard::SetNativeClipboardData() as in the attachment, but I still get the -2147221008 error from ::OleSetClipboard(). Note that the ::CoInitialize(NULL) call I added just before ::OleSetClipboard() returned S_FALSE, the meaning of which is mentioned above. The callstack for this call is: nsClipboard::SetNativeClipboardData(nsClipboard * const 0x04de4dd0, int 1) line 285 nsBaseClipboard::SetData(nsBaseClipboard * const 0x04de4dd0, nsITransferable * 0x04b357d0, nsIClipboardOwner * 0x00000000, int 1) line 108 + 16 bytes nsCopySupport::HTMLCopy(nsISelection * 0x04f45cf8, nsIDocument * 0x04f34870, short 1) line 237 PresShell::DoCopy(PresShell * const 0x04f43db8) line 4849 + 23 bytes DocumentViewerImpl::CopySelection(DocumentViewerImpl * const 0x04f3553c) line 2351 EmbedWindow::CopySelection() line 322 + 23 bytes Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard(JNIEnv_ * 0x02b5e4e8, _jobject * 0x04baf9d0, long 78659880) line 91 + 11 bytes
Assignee: edburns → nobody
Status: ASSIGNED → NEW
Component: Java APIs to WebShell → Embedding: GRE Core
QA Contact: webshell-apis → gre
Version: Trunk → 1.8 Branch
I found this link: http://www.nnseek.com/e/microsoft.public.dotnet.languages.csharp/clipboard_clear_problem_13222231t.html It says that ::OleSetClipboard will fail if someone else has the clipboard open at the same time. As far as I can tell, this is not the case.
0. Make sure JDK 1.5.0 or later is installed on your machine 1. Decide what sort of XULRunner you want to use. I recommend building from source with debug enabled using the FIREFOX_1_5_0_9_RELEASE CVS Tag. This is exactly what I am using. 1.a If building from source, build with an objdir. For the rest of this testcase, we'll call this directory OBJDIR. 1.b If you don't want to build from source, you can also use this nightly build of xulrunner: ftp://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/2006-12-06-08-mozilla1.8.0/xulrunner-1.8.0.9.en-US.win32.zip This binary is built without debugging enabled, so you won't be able to step into the offending mozilla code. However, you will see the problem. When using the nightly binary from 20061206, create a fresh directory. mkdir bug369367 mkdir bug369367/dist cd bug369367/dist unpack the xulrunner zip there. rename the xulrunner directory to be "bin" (without the quotes). This makes the directory structure similar to what you'd get when building from source with an objdir, which the testcase expects. We'll call the bug369367 directory OBJDIR for the rest of this testcase. 2. If you are using a debug xulrunner, download the win32_d binary attachment. Otherwise download the win32_o binary attachment. 3. Unpack the binary attachment in to OBJDIR 4. cd OBJDIR/dist/bin You will see this error: Testcase: testCopyCurrentSelectionToSystemClipboard took 8.047 sec FAILED expected:<HistoryTest0This is page 0 of the history test.nex...> but was:<bug369376.ba...> junit.framework.ComparisonFailure: expected:<HistoryTest0This is page 0 of the history test.nex...> but was:<bug369376.ba...> at org.mozilla.webclient.CurrentPageTest.testCopyCurrentSelectionToSyste mClipboard(CurrentPageTest.java:157) at org.mozilla.webclient.WebclientTestCase$1.run(WebclientTestCase.java: 146) If you set a breakpoint in nsClipboard::SetNativeClipboardData(nsClipboard * const 0x04de4dd0, int 1) line 285 You'll see the call to ::OleSetClipboard fails. If you unpack the same testcase into the objdir of a --disable-debug build of Firefox 1.5.0.9 you will see this testcase succeed.
The --enable-debug testcase may be downloaded from: http://mediacast.sun.com/share/edburns/369367-win32_d-testcase-bin.tar.gz The --disable-debug testcase may be downloaded from: http://mediacast.sun.com/share/edburns/369367-win32_o-testcase-bin.tar.gz
BTW, I tried this with the very latest nightly XULRUNNER from ftp://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/2007-02-05-08-mozilla1.8.0/ and the result is the same.
I'm continuing my workaround approach for this bug: Issue: 369376 Workaround M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java +void addStringToTransferable(String mimeType, String text) { This method is called from native code when a Transferable is being inspected for the DataFlavors it supports. M webclient/classes_spec/org/mozilla/webclient/test/WorkDialog.java - Whitespace M webclient/src_moz/EmbedWindow.cpp M webclient/src_moz/EmbedWindow.h - copy code from nsPrimitiveHelpers to aid in the extraction of text from the nsITransferable - Flesh out GetText(), SendTextToJava() methods. M webclient/src_moz/Makefile.in - Additional dependencies for nsPrimitiveHelpers copy.
Assignee: nobody → edburns
I've completed my workaround of this issue. M classes_spec/org/mozilla/webclient/CurrentPage2.java - Add new method copyCurrentSelectionHtmlToSystemClipboard(). M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java - Full support for text and html copy M test/automated/src/classes/org/mozilla/webclient/CurrentPageTest.java - Exercise HTML copy.
Mass change of bugs in the "Embedding: GRE Core" component in preparation for archiving it. I believe that these are no longer relevant; but if they are, they should be reopened and moved into a component relevant to the code in question.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INCOMPLETE
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: