Bug 1689992: part 1) When copying an image, add the image data before other data...
commitde0f7846d5965bb72709ffbbcfa5892c620a9c01
authorMirko Brodesser <mbrodesser@mozilla.com>
Fri, 19 Feb 2021 09:04:35 +0000 (19 09:04 +0000)
committerMirko Brodesser <mbrodesser@mozilla.com>
Fri, 19 Feb 2021 09:04:35 +0000 (19 09:04 +0000)
tree28dc3e1087b088e3e6751ec98c4d5e185bd4db20
parent373e080995166cc280e58319e68d92b9122d5e1d
Bug 1689992: part 1) When copying an image, add the image data before other data to the transferable and macOS's pasteboard. r=masayuki

On macOS, the Pages app depends on the order of the pasteboard
flavors, although it shouldn't, according to Apple's Programming Guide
<https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbConcepts.html#//apple_ref/doc/uid/TP40008101-SW1>.

I don't know how to write an automated test for this. Exporting the
flavors to the clipboard can be triggered by a Mochitest, but it doesn't
allow reading from macOS's native pasteboard.

Checking the "paste" event doesn't cover this scenario either and the
order of its flavors is not affected by this change. So that's not
usable as an indirect test.

Writing a unit test for `nsCopySupport::ImageCopy` is also insufficient,
because the produced transferable still has to be propagated to the
pasteboard, which could alter the order.

In theory, one would have to run a mochitest which exports to the
clipboard and then run a separate executable which checks the
pasteboard's content. However, it seems Gecko's test-harness doesn't
provide this and extending it seems infeasible.

Differential Revision: https://phabricator.services.mozilla.com/D104704
widget/cocoa/nsClipboard.h
widget/cocoa/nsClipboard.mm