Last Comment Bug 331738 - style.background returns empty URL if a background-image is specified as url('example.png' )
: style.background returns empty URL if a background-image is specified as url(...
Status: NEW
: css2, testcase
Product: Core
Classification: Components
Component: DOM: CSS Object Model (show other bugs)
: Trunk
: x86 Windows XP
: -- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-25 21:12 PST by Gomita
Modified: 2010-10-13 19:35 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Testcase (214 bytes, text/html)
2007-04-21 23:09 PDT, Gomita
no flags Details
More complete testcase (2.14 KB, text/html)
2007-04-22 01:59 PDT, Gérard Talbot
no flags Details
More complete testcase (2.13 KB, text/html)
2007-04-22 02:06 PDT, Gérard Talbot
no flags Details

Description Gomita 2006-03-25 21:12:48 PST
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

Please note there is a white-space between ' and ).
If a background-image of an element is specified as below;
 background-image: url('example.png' );
style.background property of the element returns an empty URL like 'url( )'.

Reproducible: Always

Steps to Reproduce:
1. Open the testcase page which contains the following HTML.
---
<body style="background-image: url('http://www.example.com/icons/apache_pb2.gif' );"
      onload="alert(document.body.style.background);">
Actual Results:  
An alert says background is 'url( )'.

Expected Results:  
An alert says background is 'url(http://www.example.com/icons/apache_pb2.gif)'.
Comment 1 Gérard Talbot 2007-04-21 22:59:08 PDT
The URL is "404: Not Found!".
This bug has been fixed. I can upload a testcase based on the chunck of code in Description, if needed.

Resolving as WORKSFORME
Comment 2 Gomita 2007-04-21 23:09:06 PDT
Created attachment 262390 [details]
Testcase
Comment 3 Gomita 2007-04-21 23:10:03 PDT
Sorry, I attached the testcase and I still get the same result which I got before.
Comment 4 Gérard Talbot 2007-04-21 23:56:07 PDT
The difference between my testcase and yours is the blank space after the single quote.

Try your testcase with

style="background-image: url('http://www.example.com/icons/apache_pb2.gif');"

instead of

style="background-image: url('http://www.example.com/icons/apache_pb2.gif' );"

and you'll see that it works.

The W3C CSS validator will not report an error for such blank space nor will the  WDG CSSCheck service. So, it looks like you have a valid bug here.

DOM inspector reports
style="background-image: url( );" for the body element.

Reopening
Comment 5 Gérard Talbot 2007-04-21 23:58:17 PDT
CONFIRMING
Comment 6 Gérard Talbot 2007-04-22 01:52:38 PDT
The format of a URI value is 'url(' followed by optional whitespace followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional whitespace followed by ')'.

CSS 2.1, Section 4.3.4, URLs and URIs
http://www.w3.org/TR/2006/WD-CSS21-20061106/syndata.html#value-def-uri
and same thing with CSS 2.0
http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#uri

So, according to CSS 2.x, it is perfectly correct, valid to have a whitespace between the ' and the ).

Another testcase upcoming
Comment 7 Gérard Talbot 2007-04-22 01:59:58 PDT
Created attachment 262402 [details]
More complete testcase

Instructions: click each button

Expected results: An alert should return url('http://www.mozilla.org/images/key-point_back.gif' )
or
url('http://www.mozilla.org/images/feature-logos1.png' )

and not url( )
Comment 8 Gérard Talbot 2007-04-22 02:06:42 PDT
Created attachment 262404 [details]
More complete testcase

Corrected testcase (with utf-8 encoding)

Instructions: click each button

Expected results: An alert should return
url('http://www.mozilla.org/images/key-point_back.gif' )
or
url('http://www.mozilla.org/images/feature-logos1.png' )

and not url( )
Comment 9 Gérard Talbot 2007-04-22 02:15:52 PDT
Opera 9.20 and Safari 2.0.4 succeed in all 4 alerts; MSIE 7 succeeds in the last (involving querying style.backgroundImage) 2 alerts.
Comment 10 Gérard Talbot 2007-04-22 02:22:04 PDT
This bug may be more about parsing url('...' ) than about background-image. It would be revealing to test some node having cursor: url('...' ) as well. Hmm...


Note You need to log in before you can comment on or make changes to this bug.