The default bug view has changed. See this FAQ.

style.background returns empty URL if a background-image is specified as url('example.png' )

NEW
Unassigned

Status

()

Core
DOM: CSS Object Model
11 years ago
7 years ago

People

(Reporter: Gomita, Unassigned)

Tracking

({css2, testcase})

Trunk
x86
Windows XP
css2, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

11 years ago
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

10 years ago
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
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → WORKSFORME
(Reporter)

Comment 2

10 years ago
Created attachment 262390 [details]
Testcase
(Reporter)

Comment 3

10 years ago
Sorry, I attached the testcase and I still get the same result which I got before.

Comment 4

10 years ago
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
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---

Comment 5

10 years ago
CONFIRMING
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 6

10 years ago
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

10 years ago
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

10 years ago
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( )
Attachment #262402 - Attachment is obsolete: true

Comment 9

10 years ago
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.
Keywords: css2, testcase

Comment 10

10 years ago
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...

Assignee: general → nobody
QA Contact: ian → general
QA Contact: general → style-system
You need to log in before you can comment on or make changes to this bug.