Closed Bug 1652478 Opened 11 months ago Closed 10 months ago

tabs.executeScript() does not work for a tab in a popup type window

Categories

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

defect

Tracking

(thunderbird_esr78 fixed, thunderbird80 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
thunderbird_esr78 --- fixed
thunderbird80 --- fixed

People

(Reporter: yuki, Assigned: darktrojan)

Details

Attachments

(2 files)

Attached file testcase.xpi

The API tabs.executeScript() does not execute given script for a tab in a popup type window. Popup type window is only one way to implement modal-like dialog by an addon, and this restriction makes it a little hard for me to control such dialogs.

Steps to reproduce

  1. Install the attached testcase addon.
  2. Switch to any mail tab, then you can see a new toolbar button named "testcase".
  3. Click the "testcase" toolbar button.
  4. A popup window is opened with no UI (except default window controls).
  5. Wait about 3 sec.

Actual result

Nothing happens in the popup window.

Expected result

After 3 sec it starts counting up in the popup window.

Environment

  • Windows 10 1909
  • Daily 80.0a1 Build ID: 20200712123207
  • Thunderbird 78.0b4 Build ID: 20200629202523

This problem doesn't happen on Firefox.

On my environment, tabs.executeScript raises an error in the debugger console for the testcase addon:

can't access property "innerWindowID", browser is null ext-tabs.js:70
    awaitTabReady chrome://messenger/content/parent/ext-tabs.js:70
    promiseTabWhenReady chrome://messenger/content/parent/ext-tabs.js:272
    executeScript chrome://messenger/content/parent/ext-tabs.js:538
    executeScript self-hosted:935
    result resource://gre/modules/ExtensionParent.jsm:930
    withPendingBrowser resource://gre/modules/ExtensionParent.jsm:485
    result resource://gre/modules/ExtensionParent.jsm:930
    callAndLog resource://gre/modules/ExtensionParent.jsm:892
    recvAPICall resource://gre/modules/ExtensionParent.jsm:929
    AsyncFunctionNext self-hosted:684

The error is raised from https://searchfox.org/comm-central/rev/1598a3b8368c0b823505889ddd1c57f398fded5f/mail/components/extensions/parent/ext-tabs.js#67

  awaitTabReady(nativeTabInfo) {
    let deferred = this.tabReadyPromises.get(nativeTabInfo);
    if (!deferred) {
      deferred = PromiseUtils.defer();
      let browser = getTabBrowser(nativeTabInfo); <= HERE!

The function getTabBrowser() looks to return null on Thunderbird.

Tb tabs do not behave like Fx tabs, see bug 1649035. For one, a <browser> is not guaranteed.

Assignee: nobody → geoff
Status: NEW → ASSIGNED

I have grand plans to expand this test to cover all of the valid tab types, but currently I'm too busy to do it. What I have done so far might as well land and get on the road to 78.2.

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/4d64ac57fa70
Fix execution of content scripts in external popup windows. r=mkmelin DONTBUILD

Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 80.0
Target Milestone: Thunderbird 80.0 → 81 Branch

(In reply to Geoff Lankow (:darktrojan) from comment #4)

I have grand plans to expand this test to cover all of the valid tab types, but currently I'm too busy to do it. What I have done so far might as well land and get on the road to 78.2.

And how do you intend this to happen without beta and ESR approval requests? This is one of currently 14 bugs lacking such request.

This just landed. We can take care of approvals once a bug has exposure on nightly. Did you notice there's a "Testing completed (on c-c, etc.): " question in the approval form?

Fact is that requests are just forgotten, see discussion on tb-drivers. You even missed things that ought to be on the way to TB 78.1.x which missed the current beta.

Comment on attachment 9166982 [details]
Bug 1652478 - Fix execution of content scripts in external popup windows. r?mkmelin

[Approval Request Comment]
Extensions will be hamstrung without this. Any risk is restricted to extensions.

Attachment #9166982 - Flags: approval-comm-beta?

Comment on attachment 9166982 [details]
Bug 1652478 - Fix execution of content scripts in external popup windows. r?mkmelin

[Triage Comment]
Approved for beta

Attachment #9166982 - Flags: approval-comm-beta? → approval-comm-beta+
Attachment #9166982 - Flags: approval-comm-esr78?

Comment on attachment 9166982 [details]
Bug 1652478 - Fix execution of content scripts in external popup windows. r?mkmelin

[Triage Comment]
Approved for esr78

Attachment #9166982 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.