Closed Bug 1209192 Opened 9 years ago Closed 8 years ago

URLs in injected CSS files are relative to the CSS file rather than to the page

Categories

(WebExtensions :: Untriaged, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: callahad, Unassigned)

Details

(Keywords: DevAdvocacy, Whiteboard: triaged)

In Chrome, both background-image: url(//example/image.png) and url(https://example/image.png) work.

In Firefox, only the second example, explicitly specifying https://, works.

Test in https://github.com/callahad/webextension-tests/tree/master/background_image

From looking at commits to the Reddit Enhancement Suite, Safari has a similar issue: https://github.com/honestbleeps/Reddit-Enhancement-Suite/commit/58686c405f965f471d2bbbd0eb3348aa139d0ecb
Documented here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities#Relative_URLs

I'm inclined to mark this invalid. I think our behavior should be the preferred behavior.
Summary: protocol-relative URLs do not work in injected CSS, unlike in Chrome → URLs in injected CSS files are relative to the CSS file rather than to the page
Flags: blocking-webextensions-
Whiteboard: triaged
Re-reading this, I guess I'm fine with marking this as wontfix.

Restating the bug for clarity: referencing a resource as `//example.com/foo` will expand to `moz-extension://example.com/foo`, which is an invalid scheme for that URL. This happens because the injected CSS file's scheme is `moz-extension:`, rather than the more common `http:` or `https:`.
Status: NEW → RESOLVED
Closed: 8 years ago
Keywords: dev-doc-needed
Resolution: --- → WONTFIX
Do we have a solution for protocol-agnostic absolute paths then? The common way to reference a resource absolutely on a domain that's both http and https is //example.com/foo, which ensures that the protocol matches and avoids mixed content problems. Is there another solution for that if this is WONTFIX?
Just always load resources from HTTPS.
Product: Toolkit → WebExtensions

4 years later, not sure we need docs specifically for extensions, that's just how css url resolution works in all contexts.

Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.