Closed Bug 690163 Opened 13 years ago Closed 13 years ago

URL section "Attaching content scripts to tabs" incorrect?

Categories

(Add-on SDK Graveyard :: Documentation, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Terry.F1Com, Assigned: KWierso)

References

()

Details

(Whiteboard: [cherry-pick-1.2])

Attachments

(1 file, 1 obsolete file)

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;");' +
        '}'
    });
  }
});
Attached patch Add an id to the widget. (obsolete) — Splinter Review
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)
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-
I wasn't the one who caught it.  Just passed on what someone reported.
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+
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
Closed: 13 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.

Attachment

General

Created:
Updated:
Size: