Closed Bug 1059174 Opened 7 years ago Closed 7 years ago

Allow ServiceWorkers over http on localhost

Categories

(Core :: DOM: Workers, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla35

People

(Reporter: jaffathecake, Assigned: baku)

References

(Blocks 1 open bug, )

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36

Steps to reproduce:

navigator.serviceWorker.register(url) on a page hosted at http://localhost:3000/


Actual results:

SecurityError: The operation is insecure.


Expected results:

Registration allowed over http on localhost
Component: Untriaged → DOM: Workers
Product: Firefox → Core
This is similar to bug 1003991, but slightly different.  Its unclear to me if we want both of these or just one.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached patch localhost.patchSplinter Review
Talking with bagder from the necko team, we both agreed that using the DNS was too much for this issue. This patch gives a reasonable way to manage localhost: It covers localhost, ::1, and 127.0.0.1.
Attachment #8482652 - Flags: review?(nsm.nikhil)
Comment on attachment 8482652 [details] [diff] [review]
localhost.patch

Review of attachment 8482652 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/workers/ServiceWorkerManager.cpp
@@ +588,5 @@
> +    if (NS_WARN_IF(result.Failed())) {
> +      return result.ErrorCode();
> +    }
> +
> +    if (host == "127.0.0.1" || host == "localhost" || host == "::1") {

Could you use Equals()? == always stands out as 'oh this could be wrong' when literals are involved, and requires looking up to see that one of the operands is a nsAutoCString.
Attachment #8482652 - Flags: review?(nsm.nikhil) → review+
https://hg.mozilla.org/mozilla-central/rev/cea25477ad0f
Assignee: nobody → amarchesini
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in before you can comment on or make changes to this bug.