Closed Bug 1664423 Opened 5 years ago Closed 4 years ago

menus API: OnClickData object of onShown event does not always include text selection (update docs)

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

defect

Tracking

(thunderbird_esr78 unaffected, thunderbird87? affected)

RESOLVED FIXED
83 Branch
Tracking Status
thunderbird_esr78 --- unaffected
thunderbird87 ? affected

People

(Reporter: TbSync, Assigned: TbSync)

Details

(Whiteboard: [fixed by bug 1670825])

Attachments

(2 obsolete files)

It should be possible to get the selected text from the OnClickData object in a menus.onShown event.

I was able to achieve this for a web page loaded in a Thunderbird tab by using the "<all_urls>" permission. The "activeTab" and the "tab" permission did not help.

For a message displayed in the 3-pane-view or in a tab, this did not work at all. I used "tabs", "activeTab" and "<all_urls>" permission.

I replicated this and by checking the source code I noticed there is only supposedly two ways in which the menu API exposes the selected text of a message:

  1. By having "activeTab" permissions (the issue here is that the function which check those permissions isn't implemented yet)
  2. By having permissions to the internal message URL (which is like "mailbox:///..." -- but the mailbox scheme isn't considered valid that's way it wasn't working even with the "<all_urls>" permission)

This issue affects the following "info" properties of the onShown event:

  • targetElementId
  • linkText
  • linkUrl
  • srcUrl
  • pageUrl
  • frameUrl
  • selectionText

I poked around a bit. The activeTab permission does have an effect.

  1. First of all the onClicked event returns all these information without (!) any special permission (menus of course is needed).

  2. The onShown event returns these these information, if the activeTab permission is given AND if an onClicked event has been triggered at least once in that tab. After that, I get linkText, linkUrl, pageUrl and selectionText. I have never seen targetElementId, srcUrl or frameUrl

This is the behavior I observe with TB 78.4.3.
@Joaquín Serna : Can you confirm this?

Is there a reason, why the two events behave differently?
What would the desired behavior be?

This bug is probably already covered by bug 1670825, which has just been added to 78.5. The messagesRead permission does what the URL permission does for web pages.

As for why the events behave differently, this also happens in Firefox with web pages. I don't understand why and in the end decided it wasn't really that big of a problem.

I'm not 100% sure that all of the properties work exactly as they do in Firefox, but the vast majority of them should.

Confirmed, this is fixed in TB78.5 build 3.

The activeTab permission is no longer needed. To get the selected text during onShown, the messagesRead permission is needed. Not so for onClicked. If that is the same behavior as in Firefox, we should stick with the same behavior.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Whiteboard: [fixed by bug 1670825]
Target Milestone: --- → 83 Branch

I need to update the doc to make clear what gives host permission to the message display tab.

Flags: needinfo?(john)
Flags: needinfo?(john)
Summary: menus API: OnClickData object of onShown event does not always include text selection → menus API: OnClickData object of onShown event does not always include text selection (update docs)
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: FIXED → ---
Assignee: nobody → john

Comment on attachment 9204384 [details] [diff] [review]
bug1664423_add_host_permission_info_to_menus_api.patch

Just a description update. Geoff is packed.

Attachment #9204384 - Flags: review?(mkmelin+mozilla)
Attachment #9204384 - Flags: review?(mkmelin+mozilla)
Attachment #9204384 - Attachment is obsolete: true

Comment on attachment 9204413 [details] [diff] [review]
bug1664423_add_host_permission_info_to_menus_api_v2.patch

Just a description update. Geoff is packed.

Attachment #9204413 - Flags: review?(mkmelin+mozilla)

Comment on attachment 9204413 [details] [diff] [review]
bug1664423_add_host_permission_info_to_menus_api_v2.patch

I change tactics here for the future. I find wrong documentation very often which are mostly just one line bugs but having them in queue (and sometimes in parallel) makes working with the code difficult. I will just keep a general documentation changeset locally and report all found issues in a single bug maybe once per month.

Attachment #9204413 - Flags: review?(mkmelin+mozilla)
Attachment #9204413 - Attachment is obsolete: true
Status: REOPENED → RESOLVED
Closed: 5 years ago4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: