Closed Bug 331738 Opened 18 years ago Closed 2 years ago

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

Categories

(Core :: DOM: CSS Object Model, defect, P5)

x86
Windows XP
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: gomita, Unassigned)

Details

(Keywords: css2, testcase)

Attachments

(2 files, 1 obsolete file)

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)'.
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
Closed: 17 years ago
Resolution: --- → WORKSFORME
Attached file Testcase
Sorry, I attached the testcase and I still get the same result which I got before.
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 → ---
CONFIRMING
Status: UNCONFIRMED → NEW
Ever confirmed: true
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
Attached file More complete testcase (obsolete) —
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( )
Attached file 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
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
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
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5

Works on my machine

Status: NEW → RESOLVED
Closed: 17 years ago2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: