<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>190807</bug_id>
          
          <creation_ts>2018-10-22 14:30:27 -0700</creation_ts>
          <short_desc>CSS variables with url() don&apos;t use correct base URL</short_desc>
          <delta_ts>2021-04-02 03:54:18 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.14</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>198512</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Craig Hockenberry">craig.hockenberry</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>chris.burgin</cc>
    
    <cc>dino</cc>
    
    <cc>gsnedders</cc>
    
    <cc>koivisto</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>timothy</cc>
    
    <cc>t.tom</cc>
    
    <cc>twilco.o</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1471350</commentid>
    <comment_count>0</comment_count>
    <who name="Craig Hockenberry">craig.hockenberry</who>
    <bug_when>2018-10-22 14:30:27 -0700</bug_when>
    <thetext>CSS variables for a url(), when placed in a subfolder of a website, do not work correctly.

To reproduce this problem, create a &quot;test.css&quot; file in /mysite/tests/stylesheets:

:root {
	
	--configuration-icon: url(&apos;../images/test.png&apos;);
}

section button {
	background-image: var(--configuration-icon);
}


Create an image called &quot;test.png&quot; in /mysite/tests/images/

In the latest Safari Technology Preview, the Network tab in the Web Inspector will show &quot;test.png&quot; highlighted in red. The 404 response is caused because the browser is trying to load &quot;/images/gear_light.png&quot; instead of &quot;/tests/images/gear_light.png&quot;. The CSS 3 documentation states:

&quot;For CSS style sheets, the base URL is that of the style sheet itself, not that of the styled source document.&quot;

I&apos;m assuming that this applies even though they&apos;re specified through CSS variables.

Additionally, if you do any CSS animation on the page, you&apos;ll see *many* of these failed requests (one for each frame of the animation.)

A live example can be found here: https://furbo.org/stuff/DarkModeCSS/ - there should be an icon next to &quot;Click to Switch Themes&quot;. If you click on the button, you&apos;ll see many failed &quot;gear_light.png&quot; requests during the transition.

Tested with STP: Release 67 (Safari 12.1, WebKit 14607.1.9.0.1).
Chrome Version 69.0.3497.100 (Official Build) (64-bit) handles the url() variables correctly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1471409</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-10-22 16:44:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/45470981&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1638534</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Burgin">chris.burgin</who>
    <bug_when>2020-04-07 07:50:59 -0700</bug_when>
    <thetext>I am also having this problem. It seems to be present if a `var` is present anywhere in `background`. Causing it to look at the document not the relative url as specified below.

&gt; https://www.w3.org/TR/CSS1/ 6.4 &quot;Partial URLs are interpreted relative to the source of the style sheet, not relative to the document&quot;.


background: url(../images/chevron-down-faded-0845b94284a0a5a42493e703d7ab4a8b.svg) no-repeat center,linear-gradient(to bottom, var(--color-white) 53%, #e2e2e2 98%)


If I replace `var(--color-white)` with `#fff` the image is loaded correctly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1694497</commentid>
    <comment_count>3</comment_count>
    <who name="Tyler Wilcock">twilco.o</who>
    <bug_when>2020-10-03 21:49:25 -0700</bug_when>
    <thetext>This is a duplicate of https://bugs.webkit.org/show_bug.cgi?id=198512 (technically the other way around, but other bugs are linking to 198512 so I think we should use that one).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1746450</commentid>
    <comment_count>4</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2021-04-02 03:54:18 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 198512 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>