Closed Bug 960360 Opened 10 years ago Closed 9 years ago

IMG complete attribute not changing to false after changing IMG SRC

Categories

(Core :: DOM: Core & HTML, defect)

26 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 608261

People

(Reporter: thomas.chung, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20131205075310

Steps to reproduce:

After changing the src attribute on an <img>, I expect the complete attribute to be false, until the image has completely loaded.

From the w3 spec:

The IDL attribute complete must return true if any of the following conditions is true:
    Both the src attribute and the srcset attribute are omitted.
    The srcset attribute is omitted and the src attribute's value is the empty string.
    The final task that is queued by the networking task source once the resource has been fetched has been queued.
    The img element is completely available.
    The img element is broken.

Immediately after changing the img.src to a valid value, all the above (except point 3, which I don't fully understand) are not satisfied, and so img.complete should be false

The attached test file writes img.complete immediately before and after changing img.src to console. I expect the write after the change to be false


Actual results:

Console output:
true
true


Expected results:

Console output:
true
false
It's not clear to me that the spec is correct here.

What we do is keep showing the old image until the new one loads (and if the new one fails to load will continue showing the old image, period).  That prevents very undesirable behavior like the image changing size while the new image is loading, flashes of broken image icons, etc.

Furthermore, in many cases a .src set will synchronously complete an image load, depending on cache settings.

That said, it's entirely possible we have a bug here too.  Note bug 694839 and bug 513541.
There is a net gain of functionality if .complete is set to track the status of the new image: We can now know whether the new image has been loaded. AFAIK, this is not currently possible.

If the old image is fully loaded before we change .src, .complete will remain true forever with the current behaviour. If the old image is not fully loaded when we change .src, the old image stops loading and .complete will be false until the new image is loaded. In either case, the value of .complete after changing .src is determined at the time .src is changed, and we do not lose information by modifying the behaviour.

IMO it makes more sense for .complete to track the status of the new image
I think this can be closed, now (see https://bugzilla.mozilla.org/show_bug.cgi?id=608261)
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: