`tabs.attach` should provide an `onAttach` property in options like page-mod does.

RESOLVED DUPLICATE of bug 755963

Status

Add-on SDK
General
P3
enhancement
RESOLVED DUPLICATE of bug 755963
7 years ago
4 years ago

People

(Reporter: zer0, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
There isn't an elegant way to know when a contentScript is attached using tabs API. We should be able to do something like page-mode does, so:

    tabs.open({
      url: url,
      onReady: function onReady(tab) {
        tab.attach({
          contentScript: "doSomething();",
          onAttach: function() {
            console.log("script attached");
          }
        });
      }
    });

At the moment we have to use a workaround with `onMessage` to obtain a similar result:

    tabs.open({
      url: url,
      onReady: function onReady(tab) {
        tab.attach({
          contentScript: "doSomething();\
            self.postMessage(1)",
          onMessage: function(){
            console.log("script attached");
          }
        });
      }
    });

Updated

7 years ago
Severity: normal → enhancement
Priority: -- → P3

Updated

7 years ago
Assignee: nobody → erikvvold
Status: NEW → ASSIGNED
OS: Mac OS X → All
Hardware: x86 → All
Taking myself off things that I won't be able to get to for awhile.
Assignee: erikvvold → nobody
We plan to deprecate this api, so I don't think making it easier to use is worthwhile.  See bug 755963 for more information.
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 755963
You need to log in before you can comment on or make changes to this bug.