<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26057</bug_id>
          
          <creation_ts>2014-06-11 11:36:23 +0000</creation_ts>
          <short_desc>&lt;img&gt; Fire error when image sniffs as an image but is broken</short_desc>
          <delta_ts>2015-09-16 12:44:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#img-load</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Simon Pieters">zcorpan</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>johns</cc>
    
    <cc>mike</cc>
    
    <cc>zcorpan</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>107647</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-06-11 11:36:23 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html
Multipage: http://www.whatwg.org/C#img-load
Complete: http://www.whatwg.org/c#img-load
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/

Comment:
&lt;img&gt; Fire error when image sniffs as an image but is broken
[[
If the resource type and data corresponds to a supported image format, as
described below
...
If the download was successful and the user agent was able to determine the
image&apos;s width and height
...
Otherwise
Set the img element to the broken state.
If the resource is CORS-same-origin: fire a progress event named load at the
img element.
...
]]

Why does this fire &apos;load&apos; rather than &apos;error&apos;? Firefox 26 fires &apos;error&apos; for
this case AFAICT:
http://w3c-test.org/submissions/996/html/semantics/embedded-content/the-img-el
ement/update-the-image-data/set-src-idl-same-value-broken-not-cacheable.html

Posted from: 2a00:801:e0:30:adfb:99b1:b970:b7ae by simonp@opera.com
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 OPR/22.0.1471.40 (Edition Next)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107678</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-11 19:37:55 +0000</bug_when>
    <thetext>What do other browsers do?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107692</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-12 06:17:57 +0000</bug_when>
    <thetext>http://w3c-test.org/submissions/996/html/semantics/embedded-content/the-img-element/update-the-image-data/set-src-idl-same-value-broken-fail-sniffing-not-cacheable.html

error event: IE9, IE10, Chrome 14 .. 27, Chrome canary, Safari 7, Firefox 7 .. nightly,
load event: IE11, Chrome 28 .. 31

http://w3c-test.org/submissions/996/html/semantics/embedded-content/the-img-element/update-the-image-data/set-src-idl-same-value-broken-not-cacheable.html

error event: IE9, IE10, Safari 7, Chrome 14 .. 27, Firefox 7 .. 26
load event: IE11, Chrome 28 .. canary, Firefox 27 .. nightly

It seems to me that the traditional browser behavior is to fire error event for both cases. Then some browsers started to fire load instead for one or both cases, maybe because the spec was changed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107693</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-12 06:24:31 +0000</bug_when>
    <thetext>The spec&apos;s source has a comment right before this part of the spec:

&lt;!-- http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1222 --&gt;

This demo seems like it sets .src every 2 seconds and the image takes about 1s to load. The image isn&apos;t broken (at least it seems to load fine for me), so I&apos;m not sure how it&apos;s relevant. If you tried setting .src before the first image had completed loading and assumed that it would abort the current load, I can see that it would be confusing since browsers do the parallel loading thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107736</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-06-12 16:47:16 +0000</bug_when>
    <thetext>I dunno. I guess do whatever most browsers do, unless it&apos;s crazy, in which case do whatever the sane browsers do, if there&apos;s a sane alternative that some browsers do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107845</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-16 10:47:11 +0000</bug_when>
    <thetext>Fire error event instead of load event when image sniffs as an image but is broken.
https://github.com/ResponsiveImagesCG/picture-element/commit/22efd4478d7714ac12fd128ca2c455d0f91f42a4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107870</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-06-16 20:24:49 +0000</bug_when>
    <thetext>&gt; http://w3c-test.org/submissions/996/html/semantics/embedded-content/the-img-element/update-the-image-data/set-src-idl-same-value-broken-not-cacheable.html

What is this test actually testing?  I get a load event on the initial load, and internally I&apos;m getting a &quot;size available&quot; notification, which means the image was non-broken enough for the image decoder to have found the size metadata.  Generally Gecko fires a load event for images which get that far, not an error event, so we show partially decoded images even if we ended up with an error partway through the decode....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107920</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-06-17 07:05:52 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #6)
&gt; &gt; http://w3c-test.org/submissions/996/html/semantics/embedded-content/the-img-element/update-the-image-data/set-src-idl-same-value-broken-not-cacheable.html
&gt; 
&gt; What is this test actually testing?  I get a load event on the initial load,
&gt; and internally I&apos;m getting a &quot;size available&quot; notification, which means the
&gt; image was non-broken enough for the image decoder to have found the size
&gt; metadata.  Generally Gecko fires a load event for images which get that far,
&gt; not an error event, so we show partially decoded images even if we ended up
&gt; with an error partway through the decode....

The request-response for the image in this test is as follows, running in Firefox 26:

GET /html/semantics/embedded-content/the-img-element/update-the-image-data/resources/stash-count-requests.py?id=18780ba7-f2ee-418c-b500-25fdec34bd81&amp;cached=no&amp;animated=no&amp;delay=no&amp;broken=yes&amp;action=put HTTP/1.1
Host: web-platform.test:8000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://web-platform.test:8000/html/semantics/embedded-content/the-img-element/update-the-image-data/set-src-idl-same-value-broken-not-cacheable.html
Connection: keep-alive

HTTP/1.1 200 OK
Content-Type: image/gif
Cache-Control: no-store, no-cache, must-revalidate
Expires: Tue, 19 Nov 1985 21:00:00 GMT
Content-Length: 17
Server: BaseHTTP/0.3 Python/2.7.5
Date: Tue, 17 Jun 2014 06:57:38 GMT

GIF89aBROKENIMAGE

(The response is not delayed.)

In http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3063 I use the same image as a data: URL, which fires an error event in Firefox Nightly, but I get a load event in the above test in Firefox Nightly. I don&apos;t know why that is.

(The &quot;fail-sniffing&quot; test has NOTGIFBROKENIMAGE as response body.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>