Closed Bug 1165753 Opened 9 years ago Closed 9 years ago

Tabs module sometimes prefixes add-on's resource directory url when calling .open

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: u538344, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150513174244

Steps to reproduce:

Real example
Code: http://i.imgur.com/HXJeapr.png
URL used: http://i.imgur.com/0wabi7x.png
Debug output: http://i.imgur.com/ji8GCA4.png (confirming the string contains a perfect URL)
Opened tab: http://i.imgur.com/qtsuuV1.png
The prefixed resource:// url belongs to the addon that made the call.

---

1) var url = "<some valid url here>"; // e.g. www.maxpayne2.com/mods/
2) call require("sdk/tabs").open(url);


Actual results:

A new tab opened, but the loaded url was transformed from
<target url>
to
<addon's resource:// url>/<target url>


Expected results:

A new tab should have opened with the given url loaded into it
This happens in Firefox 38 (addon compiled with cfx), 39 (cfx), and updated developer edition (compiled with jpm). Users of my addon confirm this happens regualrly but not always.
(In reply to marnick.leau from comment #1)
> This happens in Firefox 38 (addon compiled with cfx), 39 (cfx), and updated
> developer edition (compiled with jpm). Users of my addon confirm this
> happens regualrly but not always.

I meant Firefox 37 and 38, not 38 and 39
(In reply to marnick.leau from comment #0)
> 1) var url = "<some valid url here>"; // e.g. www.maxpayne2.com/mods/

This isn't actually a valid url unless prefixed with a protocol like http or https. Is it only cases with no protocol that aren't working?
(In reply to Dave Townsend [:mossop] from comment #3)
> (In reply to marnick.leau from comment #0)
> > 1) var url = "<some valid url here>"; // e.g. www.maxpayne2.com/mods/
> 
> This isn't actually a valid url unless prefixed with a protocol like http or
> https. Is it only cases with no protocol that aren't working?

I couldn't wrap my head around why some links do and some don't work. I think you just pinpointed it, like it was nothing. :D Dang.

I just wrote some test code and indeed, www.google.com fails but http://www.google.com works!

Can the tabs module be modified to try to resolve incomplete urls (without protocol and anything I'm not thinking of) the same way the location bar does? I.e. try http, if that fails try https, whatever it does? Users can just enter "youtube.com" and Firefox eventually finds https://www.youtube.com/, so can the tabs module do the same thing?
(In reply to marnick.leau from comment #4)
> (In reply to Dave Townsend [:mossop] from comment #3)
> > (In reply to marnick.leau from comment #0)
> > > 1) var url = "<some valid url here>"; // e.g. www.maxpayne2.com/mods/
> > 
> > This isn't actually a valid url unless prefixed with a protocol like http or
> > https. Is it only cases with no protocol that aren't working?
> 
> I couldn't wrap my head around why some links do and some don't work. I
> think you just pinpointed it, like it was nothing. :D Dang.
> 
> I just wrote some test code and indeed, www.google.com fails but
> http://www.google.com works!
> 
> Can the tabs module be modified to try to resolve incomplete urls (without
> protocol and anything I'm not thinking of) the same way the location bar
> does? I.e. try http, if that fails try https, whatever it does? Users can
> just enter "youtube.com" and Firefox eventually finds
> https://www.youtube.com/, so can the tabs module do the same thing?

We might break a bunch of add-ons if we make that change, and I think it's better to use a strict format in this case.  It wouldn't be hard to implement

    function url(str) {
      return "https://" + str;
    }

then use `url("google.com")`.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.