Closed Bug 995806 Opened 8 years ago Closed 7 years ago

test_DirectoryLinksProvider.js xpcshell test makes tcp connection to


(Firefox :: New Tab Page, defect)

Windows 7
Not set



Firefox 32
Tracking Status
firefox31 --- fixed
firefox32 --- fixed


(Reporter: mcmanus, Assigned: mzhilyaev)




(2 files)

The test infrastrucutre is meant to be self contained - so xpcshell, mochitests, and crashtests need to be self hosted.

toolkit/modules/tests/xpcshell/test_DirectoryLinksProvider.js actually makes a connection via nsichannel to every time the test is executed.

this should be fixed to be localhost only.
Drew, your name is on this file as the primary reviewer.

Can the test just request things from the local http server that gets set up for the test?  Can you find someone to make that change or other necessary changes?
Flags: needinfo?(adw)
Olivier, Maxim, Marina, would you be able to look at this?  The URLs in the test are all tile/site sources, not links metadata sources, so I don't see how they end up getting loaded.
Flags: needinfo?(adw)
Drew, I think URLs are never loaded, they are always a part of the data section of the data url constructed by the test as in:

  let data = {
    "en-US": [{url: "", title: "US"}],
    "zh-CN": [
              {url: "", title: "CN"},
              {url:"", title: "CN2"}
  let dataURI = 'data:application/json,' + JSON.stringify(data);

Let me know if understood your concern correctly and addressed it
Yes, that's what it looks like to me, too, but apparently something in the test is actually loading  I thought I might have overlooked something that one of you might see.
Finally took at closer look at this and got:

 0:03.92 [31042] WARNING: Non-local hostname nosuchhost resolved: 2218907459:0: file /home/froydnj/src/gecko-dev.git/netwerk/dns/nsHostResolver.cpp, line 1193
 0:03.92 BAD CONNECT: connecting to nosuchhost 0
 0:03.92 Hit MOZ_CRASH(Attempting to connect to non-local address!) at /home/froydnj/src/gecko-dev.git/netwerk/base/src/nsSocketTransport2.cpp:1190

which is coming from here:

This is one of the annoying things about disabling non-local connections: xpcshell has somewhat different behavior than the browser in this case.  (The browser returns nice errors back to the HTML page that spawned the request...sometimes.)

Patrick, do you have any networking insight into what we can do here?
Flags: needinfo?(mcmanus)
And we hit it here, too:

I'm assuming that we'd rather not disable these bits of the test if we can help it.
These are negative tests that ensure that bad urls and unresolved hosts are handled correctly.
Patric, what would you suggest for an appropriate URL and hostname for such tests (a non-existent IP, perhaps)?
(In reply to maxim zhilyaev from comment #7)
> These are negative tests that ensure that bad urls and unresolved hosts are
> handled correctly.
> Patric, what would you suggest for an appropriate URL and hostname for such
> tests (a non-existent IP, perhaps)?

yes - if you use a hostname that doesn't resolve at all then I wouldn't expect a problem as I remember the enforcement patch. (iirc it asserts when trying to connect to a non-localhost IP and only warns on trying to look up names other than localhost).

something like nosuchhost.localhost. ought to be pretty safe
Flags: needinfo?(mcmanus)
Assignee: nobody → mzhilyaev
maksik, are you able to test this locally to see if a change would fix this problem?
Component: Tabbed Browser → New Tab Page
Tested with tcpdump on local machine whiel running the test

>> tcpdump -vvv -s 0 -l -n port 53

10:16:11.132372 IP (tos 0x0, ttl 255, id 52101, offset 0, flags [none], proto UDP (17), length 66) > [udp sum ok] 19606+ A? nosuchhost.localhost. (38)
10:16:11.135500 IP (tos 0x0, ttl 63, id 34130, offset 0, flags [none], proto UDP (17), length 107) > [udp sum ok] 19606 NXDomain* q: A? nosuchhost.localhost. 0/1/0 ns: localhost. [1d] SOA localhost. root.localhost. 42 10800 900 604800 86400 (79)

network utility show local IP as

So, the fix appears to work.
Attachment #8435913 - Flags: review?(mcmanus)
Attachment #8435913 - Flags: review?(mcmanus) → review+
Closed: 7 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → Firefox 32
maxim, we'd like to backport bug 995417 to mozilla-beta but are running into this bug in the process. However, this patch doesn't apply cleanly to that branch. Can you please post a branch patch when you get a chance? :)

Flags: needinfo?(mzhilyaev)
Rayn, the original patch is not applicable to mozilla-beta since mozilla-beta does not have functionality that the patched test cases are testing.  However, there's an offending line that issues a non-local http request found here:

I am attaching a patch that fixes this issue.
Please note that this code will is removed in master
Flags: needinfo?(mzhilyaev)
You need to log in before you can comment on or make changes to this bug.