W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2011

[whatwg] Origin of a data: URL for an img

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 16 Nov 2011 22:39:20 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1111162235030.10585@ps20323.dreamhostps.com>
On Wed, 16 Nov 2011, Gavin Kistner wrote:
> Section 6.3 "Origin" of the HTML Living Standard has this text (excerpted):
> 
> > For images:
> >
> > If an image was generated from a data: URL found in another Document or in a script
> > The origin is the origin of the Document or script that loaded that image.
> >
> > If an image was obtained in some other manner (e.g. a data: URL typed in by the user)
> > The origin is a globally unique identifier assigned when the image is created.
> 
> I'm going to refer to the first case above as the "found specs" and the second case as the "other specs". (Aside: it would be convenient for discussion if items in this section would have unique identifying numbers.)
> 
> What does "found" mean?
> What is the difference between these two cases?
> When do we switch from one case to the other?
> 
> Here are some of my guesses:
> 
>     var img = new Image;
>     var iframe = document.querySelector('iframe#samedomain').contentWindow;
>     img.src = iframe.globalStringWithDataURI; // "other specs"?
>     img.src = iframe.document.querySelector('img#hasdatauri'); // "found specs"?
>     img.src = img.src.replace( '0', '1' ); // "other specs"?
> 
> Does a JavaScript String object carry an origin along with it, but any 
> mutation (and all new strings) switch to "other specs"?

In all three cases here, the image was generated from a URL found in the 
src="" content attribute of the <img> element created by the script. The 
image data is CORS-same-origin, and so the entry that applies in the 
origin section is:

 If an image is the image of an img element and its image data is 
 CORS-same-origin

 The origin is the origin of the img element's Document.

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 16 November 2011 14:39:20 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:09 UTC