Closed Bug 1470231 Opened 3 years ago Closed 3 years ago

[wpt-sync] Sync PR 11611 - Correctly resolve relative URLs for registered custom properties.


(Core :: CSS Parsing and Computation, enhancement, P4)




Tracking Status
firefox63 --- fixed


(Reporter:, Unassigned)




(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 11611 into mozilla-central (this bug is closed when the sync is complete).

Details from upstream follow.

Anders Hartvoll Ruud <> wrote:
>  Correctly resolve relative URLs for registered custom properties.
>  Relative URLs in registered custom properties must resolve against the
>  base URL of the originating stylesheet. For instance, consider a style-
>  sheet at /style/mystyle.css:
>    --foo: url("myimage.jpg");
>  And a document at /index.html:
>    <style>
>      background-image: var(--foo);
>    </style>
>  If the property --foo is registered with syntax <url>, then the background-
>  image should be /style/myimage.jpg.
>  This is contrary to non-registered properties, in which case the
>  background-image would be /myimage.jpg.
>  To implement this, this patch scans for URL tokens and 'url('-function
>  tokens after (var-)resolving the registered custom property
>  (see CSSVariableResolver::ResolveCustomProperty). The token containing
>  the relative URL is then rewritten (in-place) to contain an absolute URL
>  instead.
>  To avoid doing unnecessary work, we only scan the token stream if
>  CSSVariableData::needs_variable_resolution_ is set. This is set either
>  if needs_url_resolution_ is set (because var-references could produce
>  relative URLs), or if the token stream contains URL/function-tokens.
>  When a resolved CSSVariableData is created (::CreateResolved), it is
>  assumed that the incoming token stream contains no URLs that need to be
>  resolved.
>  Bug: 851490
>  Change-Id: I25b1e839fc92eb538f30670fe91fc92a1ad9d5ea
>  Reviewed-on:
>  WPT-Export-Revision: 6332d424c7fbc3e3f510e1d14db620e4869b641c
Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core
Ran 1 tests and 1 subtests
OK     : 1
FAIL   : 1

New tests that have failures or other problems:
    Untitled: FAIL
Pushed by
[wpt PR 11611] - Correctly resolve relative URLs for registered custom properties., a=testonly
[wpt PR 11611] - Update wpt metadata, a=testonly
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.