Closed Bug 614894 Opened 15 years ago Closed 11 years ago

APIs that take a local file URL should be able to pass a string filename

Categories

(Add-on SDK Graveyard :: General, enhancement, P1)

enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 870677

People

(Reporter: dietrich, Unassigned)

Details

(Whiteboard: [papercuts])

The self module's facility for loading local files is proving to be continuously confusing to developers. I've seen confusion on the mailing list and IRC multiple times. The current approach seems unnecessarily verbose and convoluted. If an API takes a local file as an argument, the developer should be able to just pass the leaf filename, instead of generating a URL. So instead of: widget.Widget({ contentScriptFile: require("self").data.url("myfile.html") }); It would be: widget.Widget({ contentScriptFile: "myfile.html" }) And if that's not possible for whatever reason, we should ease things with something like: widget.Widget({ contentScriptFile: require("self").file("myfile.html") })
It should also accept relative paths for files in subdirs of the data dir.
I'm CC'ing warner on this because I believe he was the one who originally proposed the current paradigm for security reasons. I also wanted to note that there are some other potential ways of making life easier for developers if we still require a constructor (either self.data.url() or self.file()). I'm not sure if it's currently the case or not, but we could provide a really helpful exception or console message if contentScriptFile is given a string instead of a URL or file object, e.g. pointing the developer to a section of the SDK documentation that contains rationale and sample code snippets.
Then we should push the implementation details of those security requirements behind the APIs exposed to add-on devs.
OS: Linux → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → 1.0
Whiteboard: [papercuts]
(automatic reprioritization of 1.0 bugs)
Priority: P2 → P1
Target Milestone: 1.0 → 1.1
Assignee: nobody → myk
Severity: normal → enhancement
Re-prioritizing all 1.1-targeted feature requests to 1.2.
Target Milestone: 1.1 → 1.2
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: 1.2 → ---
Unassigning myself from bugs I am not actively working on.
Assignee: myk → nobody
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.