On Mon, 03 Feb 2014 23:27:32 +0100, Yoav Weiss <
yo...@yoav.ws> wrote:
> You're right that "immediate" is wrong according to the spec, but it
> seems
> that this is the way that it's currently implemented in Blink. From
> testing
> the setting of src and crossorigin <
http://jsbin.com/OnOkuQE/1> in both
> orders, it seems that Blink, WebKit and IE send the request immediately,
> without waiting for stable state and as a result, images where src is set
> first are sent without an "origin" header. It's hard to tell for Gecko
> since it doesn't send an "origin" header even when crossorigin is set
> before src.
>
> So, I guess my question is "Who is wrong here?"
Yeah, everyone is wrong. :-(
> On the one hand, the specified behavior would be better for authors,
> enabling the setting of src, srcset and crossorigin in arbitrary order
> and
> receive the same results.
This is indeed the reason the spec is the way it is. I think it was
specified to await a stable state at the same time as the crossorigin
attribute was added to img, but it seems browsers implementing crossorigin
on img took shortcuts (Presto included).
> It'd also enable HTMLImageElement to be aware of
> its parent before triggering any resource requests, facilitating the
> implementation of picture's selection algorithm.
Indeed.
Note that the selection itself is sync, and if the selected image is in
cache, it is loaded immediately (e.g. getting .width in the same script
works). That is required for Web compat I think. This is step 7 in
http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#update-the-image-data
> On the other hand, no browser does that today.
>
> Should I open a bug regarding the current behavior in Blink?
I think that would be good.
--
Simon Pieters
Opera Software