Bug 3473 - Preloaded Image objects .src field is not a fully resolved path
Summary: Preloaded Image objects .src field is not a fully resolved path
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Eric Seidel (no email)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-12 13:04 PDT by Stuart Morgan
Modified: 2011-12-01 10:12 PST (History)
2 users (show)

See Also:


Attachments
Bug fix (588 bytes, patch)
2005-06-20 07:07 PDT, Derek Poon
darin: review-
Details | Formatted Diff | Diff
test case that still fails with this patch (172 bytes, text/html)
2005-07-29 13:32 PDT, Vicki Murley
no flags Details
A patch to fix this matching WinIE's behavior. (2.79 KB, patch)
2005-11-10 11:54 PST, Eric Seidel (no email)
ggaren: review+
Details | Formatted Diff | Diff
separated test case (1.71 KB, text/html)
2005-11-10 12:52 PST, Eric Seidel (no email)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.