Closed Bug 1579059 Opened 5 months ago Closed 2 months ago

SelectionText of info object become undefined given the existence of host permissions

Categories

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

Desktop
Windows 10
defect
Not set

Tracking

(thunderbird_esr68 fixed, thunderbird72 fixed, thunderbird73 fixed)

VERIFIED FIXED
Thunderbird 73.0
Tracking Status
thunderbird_esr68 --- fixed
thunderbird72 --- fixed
thunderbird73 --- fixed

People

(Reporter: bprasannakumar, Assigned: darktrojan)

References

Details

(Keywords: regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0

Steps to reproduce:

I had developed an Addon for Thunderbird to list custom ContextMenu entries to quickly access work related links with the text selected in the mail content. Till Thunderbird 60 the XUL based addon worked flawlessly.

Since, from Thunderbird 68 XUL based addons are deprecated/discouraged, i tried to port my XUL based addon to webextension for Thunderbird. Though i was able to successfully port my addon, the selected text in mail content is not getting listed in info object.

  1. Created menu using browser.menus
    browser.menus.create({
    id:"open_customlink",
    title: "Open CL",
    type: "normal",
    contexts: ["all"],
    parentId: "context_mycl"
    }, onCreated);

  2. Had function to handle the menu click event
    browser.menus.onClicked.addListener((info, tab) => {
    switch (info.menuItemId) {
    case "open_customlink":
    console.log(info.selectionText);
    openCL(info,tab);
    break;
    });

  3. Had a function to do actual action on the selected text
    function openCL(info, tab) {
    console.log("Custom Link item " + info.menuItemId + " was clicked");
    console.log("Custom Link info: " + JSON.stringify(info));
    console.log("Custom Link tab: " + JSON.stringify(tab));
    // Other code here
    }

  4. Had permissions for tab and menus in manifest.json
    "permissions": [
    "notifications",
    "menus",
    "activeTab",
    "tabs",
    "<all_urls>"
    ],
    "content_scripts": [
    {
    "matches": ["<all_urls>"]
    }
    ]

Actual results:

When we try to select a text in the mail content and click on the custom context menu entry, the info object is missing the SelectionText.

console.log(info.selectionText); -> undefined

JSON.stringify(info) -> {"menuItemId":"open_customlink","parentMenuItemId":"context_mycl","editable":false,"modifiers":[],"button":0}

Expected results:

Since, the required permissions have been acquired while installing the addon the SelectionText property of info object should have contained the selected text from mail content.

Note: I have asked a question on Stackoverflow (https://stackoverflow.com/questions/57743754/host-permissions-required-for-selectiontext-of-info-object-in-thunderbird-68) to see if anyone could help me quickly.

OS: Unspecified → Windows 10
Hardware: Unspecified → Desktop
Summary: SelectionText of info object become undefined given existence host permissions → SelectionText of info object become undefined given the existence of host permissions
Component: Message Reader UI → Add-Ons: Extensions API

Marking this as a duplicate of bug 1504475, as the cause is exactly the same, and fixing one will fix the other. I just don't know how, yet.

Status: UNCONFIRMED → RESOLVED
Closed: 4 months ago
Flags: needinfo?(geoff)
Resolution: --- → DUPLICATE
Duplicate of bug: 1504475

Reopening this. The cause isn't bug 1504475, the cause is our context menu code needing a major update to bring it into line with Firefox's.

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Assignee: nobody → geoff
Status: REOPENED → ASSIGNED
Attachment #9113102 - Flags: review?(mkmelin+mozilla)
Duplicate of this bug: 1567459
Attachment #9113102 - Flags: approval-comm-beta?
Attachment #9113103 - Flags: approval-comm-esr68?
Comment on attachment 9113102 [details] [diff] [review]
1579059-context-selection-1.diff

Review of attachment 9113102 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM, r=mkmelin
Attachment #9113102 - Flags: review?(mkmelin+mozilla) → review+

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/247abc27cb52
Update nsContextMenu to fix selection text properties; r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 4 months ago2 months ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 73.0
Keywords: regression
Attachment #9113102 - Flags: approval-comm-beta? → approval-comm-beta+
Attachment #9113103 - Flags: approval-comm-esr68? → approval-comm-esr68+

Thank you very much for fixing this issue. Now info object returns value for selectionText in Thunderbird 72.0 BETA version and my contextmenu addon is working. Eagerly waiting for Thunderbird 72 or ESR 68.3.1 so my addon can become functional for the users who are using it.

Status: RESOLVED → VERIFIED
Target Milestone: Thunderbird 72.0 → Thunderbird 73.0
You need to log in before you can comment on or make changes to this bug.