Bug 3473

Summary: Preloaded Image objects .src field is not a fully resolved path
Product: WebKit Reporter: Stuart Morgan <stuartmorgan>
Component: JavaScriptCoreAssignee: Eric Seidel (no email) <eric>
Status: RESOLVED FIXED    
Severity: Normal CC: darwinbugs, vicki
Priority: P2    
Version: 412   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
Bug fix
darin: review-
test case that still fails with this patch
none
A patch to fix this matching WinIE's behavior.
ggaren: review+
separated test case none

Description Stuart Morgan 2005-06-12 13:04:11 PDT
* SUMMARY
Non-safari browser will replace the relative path value of an image.src with the
fully resolved path after the image is loaded.  safari appears to preload
however the path remains relative.

for example images preloaded via:
    var anImage = new image(x,y);
    anImage.src = "images/safari.jpg"

should have a fully resolved src value

alert(anImage.src); should display  "http://pathtome.com/images/safari.jpg"

* RESULTS
all non-safari browsers will update the image object src with the full path.
Safari leaves the src value unchanged

Apple Bug: rdar://3787988
Comment 1 Derek Poon 2005-06-20 02:35:16 PDT
All non-Safari browsers except Konqueror, that is.  =)
Konqueror 3.3.1 has the same bug.  It breaks image toggle scripts.
Comment 2 Derek Poon 2005-06-20 07:07:51 PDT
Created attachment 2501 [details]
Bug fix

This fix works for me.	Would somebody please double check the memory
management, and explain when doc would ever be NULL?
Comment 3 Darin Adler 2005-07-29 10:57:21 PDT
Comment on attachment 2501 [details]
Bug fix

In the future, please attach patches as unified format diffs (the "-u") option
to diff.

We want to use stick to our coding style guidelines for new code, which means
it should say "(str)" instead of "( str )".

The reason we have to null-check the document is that the image object might
outlast the document; you can hold a reference to the image forever even if the
window is closed.

We also need a layout test to check in along with the bug fix.

But the logic of the fix looks great, r=me on that.
Comment 4 Vicki Murley 2005-07-29 13:32:24 PDT
Created attachment 3149 [details]
test case that still fails with this patch
Comment 5 Vicki Murley 2005-07-29 13:34:10 PDT
This test case still fails with this patch (works in ffx):

<html>
<body>
<script type="text/javascript">
	var anImage = new Image(76,103);
    anImage.src = "editing/abe.jpg";
	document.write(anImage.src);
</script>
</body>
</html>

Derek, could you attach the test case that you used?
Comment 6 Darin Adler 2005-08-06 16:35:03 PDT
There's a good change that the fix for bug 3869 also fixes this bug.
Comment 7 Darin Adler 2005-08-06 16:35:28 PDT
(chance, not change)
Comment 8 Eric Seidel (no email) 2005-11-10 11:54:15 PST
Created attachment 4660 [details]
A patch to fix this matching WinIE's behavior.
Comment 9 Eric Seidel (no email) 2005-11-10 11:54:36 PST
Comment on attachment 4660 [details]
A patch to fix this matching WinIE's behavior.

Make sure you view this patch as source, otherwise Safari gets confused.
Comment 10 Eric Seidel (no email) 2005-11-10 12:52:18 PST
Created attachment 4661 [details]
separated test case
Comment 11 Geoffrey Garen 2005-11-10 14:41:49 PST
Comment on attachment 4660 [details]
A patch to fix this matching WinIE's behavior.

eric and i talked about this. r=me.