URL section "Attaching content scripts to tabs" incorrect?

RESOLVED FIXED in 1.2

Status

P2
normal
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: Terry.F1Com, Assigned: KWierso)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [cherry-pick-1.2], URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

7 years ago
Reported from the webmaster email address:

At the example "Attaching content scripts to tabs", the Widget ID is missing and it doesn't work.
The right way would be:

var widgets = require("widget");
var tabs = require("tabs");
 
var widget = widgets.Widget({
  id: "Div-Show",
  label: "Show divs",
  contentURL: "http://www.mozilla.org/favicon.ico",
  onClick: function() {
    tabs.activeTab.attach({
      contentScript:
        'var divs = document.getElementsByTagName("div");' +
        'for (var i = 0; i < divs.length; ++i) {' +
          'divs[i].setAttribute("style", "border: solid red 1px;");' +
        '}'
    });
  }
});
(Assignee)

Comment 1

7 years ago
Created attachment 563254 [details] [diff] [review]
Add an id to the widget.

So this patch adds an ID attribute to the widget's constructor.

I'm open to a better ID, though. :)
Attachment #563254 - Flags: review?(wbamberg)
(Assignee)

Updated

7 years ago
Hardware: x86 → All
Comment on attachment 563254 [details] [diff] [review]
Add an id to the widget.

"Div-Show" would be a better ID, I think.

Thanks Terry R. for catching this, and KWierso for the patch! But this patch adds an attribute called "div" not one called "id" :(.
Attachment #563254 - Flags: review?(wbamberg) → review-
(Reporter)

Comment 3

7 years ago
I wasn't the one who caught it.  Just passed on what someone reported.
(Assignee)

Comment 4

7 years ago
Created attachment 563267 [details] [diff] [review]
Actually add an id to the widget constructor

Wow, can't believe I did that...
Attachment #563254 - Attachment is obsolete: true
Attachment #563267 - Flags: review?(wbamberg)
Comment on attachment 563267 [details] [diff] [review]
Actually add an id to the widget constructor

Thanks KWierso!
Attachment #563267 - Flags: review?(wbamberg) → review+
Keywords: checkin-needed
(Assignee)

Updated

7 years ago
Priority: -- → P2
Whiteboard: [cherry-pick-wanted]
https://github.com/mozilla/addon-sdk/commit/13228be19730cb7b57e3ee52edeeba47661cca2d
https://github.com/mozilla/addon-sdk/commit/4f2ec8936c4bab1ed23b4688ae829d0968f7b0c6
Assignee: nobody → kwierso
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [cherry-pick-wanted] → [cherry-pick-1.2]
Target Milestone: --- → 1.2
You need to log in before you can comment on or make changes to this bug.