<?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>27436</bug_id>
          
          <creation_ts>2014-11-25 23:27:16 +0000</creation_ts>
          <short_desc>Document.charset</short_desc>
          <delta_ts>2015-09-22 07:56:19 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugzilla.mozilla.org/show_bug.cgi?id=647621</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=74819</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philip Jägenstedt">philipj</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bugs</cc>
    
    <cc>crimsteam</cc>
    
    <cc>ehsan</cc>
    
    <cc>hsivonen</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>VYV03354</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115485</commentid>
    <comment_count>0</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-25 23:27:16 +0000</bug_when>
    <thetext>This is supported by IE, Blink and WebKit, but not Gecko.

Usage in Chrome is around 4%:
https://www.chromestatus.com/metrics/feature/timeline/popularity/127

It&apos;s not readonly like characterSet, but we can probably remove the setter:
https://www.chromestatus.com/metrics/feature/timeline/popularity/427

So, make charset an alias of characterSet? It&apos;s very unlikely that it can be removed in Blink, since at this level of usage it&apos;s bound to show up on code paths that Gecko doesn&apos;t take for some reason or another.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115487</commentid>
    <comment_count>1</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-11-26 00:05:40 +0000</bug_when>
    <thetext>I would add one another thing if you have already started this bug.

Document.characterSet should retrun encoding&apos;s name but lowercase (what we have in table on encoding spec) or uppercase? Ask becasue I noticed different behavior in browsers.
https://encoding.spec.whatwg.org/#names-and-labels

Some results returned by various commands:

Document.characterSet
Firefox UTF-8
Chrome UTF-8
IE utf-8

Document.inputEncoding (DOM Level 3)
Firefox UTF-8
Chrome UTF-8
IE UTF-8

Document.charset (not standard)
Chrome UTF-8
IE utf-8

Document.characterSet (not standard)
Chrome ISO-8859-2
IE windows-1250

TextEncoder.encoding and TextDecoder.encoding
Firefox utf-8
Chrome utf-8</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115488</commentid>
    <comment_count>2</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-11-26 00:16:55 +0000</bug_when>
    <thetext>&gt; Document.characterSet (not standard)
&gt; Chrome ISO-8859-2
&gt; IE windows-1250
&gt; 

Here is Document.defaultCharset (not Document.characterSet).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115496</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-26 08:13:52 +0000</bug_when>
    <thetext>Adding some Mozillians who might have opinions on adding an alias.

They should return the names in lowercase per the Encoding Standard. If different casing needs to be considered (note that browsers do not consistently use uppercase or lowercase today) we&apos;d need to address that through a &quot;display name&quot; field in the Encoding Standard or some such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115509</commentid>
    <comment_count>4</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 13:34:51 +0000</bug_when>
    <thetext>I agree that we should try to return lowercase string, but that&apos;s orthogonal to this bug. charset is already an alias of characterSet in Blink, and any changes would apply to both.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115510</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-26 13:38:00 +0000</bug_when>
    <thetext>Well not completely right, or do both have a setter in Blink? Should we wait with adding an alias until the setter has been removed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115511</commentid>
    <comment_count>6</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-11-26 13:47:10 +0000</bug_when>
    <thetext>What does the setter do?

Is it known that if the property sniffs as existing, sites won&apos;t try to use the setter (i.e. having it as getter-only would be safe)?

(In reply to Anne from comment #3)
&gt; If
&gt; different casing needs to be considered (note that browsers do not
&gt; consistently use uppercase or lowercase today)

Didn&apos;t WebKit make a specific effort to be consistent with Gecko&apos;s (rather arbitrary) casing? Have you researched why the WebKit developers made the effort to be case-consistent with Gecko?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115512</commentid>
    <comment_count>7</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2014-11-26 13:49:37 +0000</bug_when>
    <thetext>About adding a getter alias, I&apos;m not sure what that will buy us for Gecko, since it is clearly not required for web compat for content that we&apos;re handling (at least I have never seen anyone ask for it, or any major website being broken in Gecko because we don&apos;t support it.)

About adding a setter, I&apos;m not sure if I understand what the semantics would be.  In fact, I can&apos;t think of a use case for dynamically changing the charset of a document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115513</commentid>
    <comment_count>8</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-26 14:23:41 +0000</bug_when>
    <thetext>(In reply to Henri Sivonen from comment #6)
&gt; Didn&apos;t WebKit make a specific effort to be consistent with Gecko&apos;s (rather
&gt; arbitrary) casing? Have you researched why the WebKit developers made the
&gt; effort to be case-consistent with Gecko?

WebKit did? I&apos;m not aware of that. I remember that what I found was inconsistent across user agents. From https://bugs.webkit.org/buglist.cgi?query_format=specific&amp;order=relevance+desc&amp;bug_status=__all__&amp;product=&amp;content=characterset I cannot find anything that supports what you suggest.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115515</commentid>
    <comment_count>9</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 14:40:08 +0000</bug_when>
    <thetext>(In reply to Anne from comment #5)
&gt; Well not completely right, or do both have a setter in Blink?

Only charset has a setter.

(In reply to Henri Sivonen from comment #6)
&gt; What does the setter do?

It&apos;s propagated to a TextResourceDecoder where it looks like it will prevent further checks for &lt;meta charset&gt;, but I&apos;ve been unable to produce a simple test case where it has any observable effect. I&apos;m betting on removal, in which case it doesn&apos;t matter.

&gt; Is it known that if the property sniffs as existing, sites won&apos;t try to use
&gt; the setter (i.e. having it as getter-only would be safe)?

All I know is that the usage of the setter is in the range where it&apos;s plausible that removal would work, currently ~0.01% of page views. In my experience, only actually attempting removal will tell you if it&apos;s safe or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115517</commentid>
    <comment_count>10</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-11-26 14:45:24 +0000</bug_when>
    <thetext>(In reply to Anne from comment #8)
&gt; (In reply to Henri Sivonen from comment #6)
&gt; &gt; Didn&apos;t WebKit make a specific effort to be consistent with Gecko&apos;s (rather
&gt; &gt; arbitrary) casing? Have you researched why the WebKit developers made the
&gt; &gt; effort to be case-consistent with Gecko?
&gt; 
&gt; WebKit did? I&apos;m not aware of that. I remember that what I found was
&gt; inconsistent across user agents.

Maybe they didn&apos;t. Still, the case is remarkably consistent across WebKit and Gecko. I quick look suggests that WebKit follows IANA casing and Gecko follows IANA casing except for gbk and gb18030 (which are upper case in IANA &amp; WebKit). So maybe WebKit didn&apos;t copy Gecko but both WebKit and Gecko used IANA casing, except Gecko somehow failed to do that for gbk and gb18030.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115518</commentid>
    <comment_count>11</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 14:49:37 +0000</bug_when>
    <thetext>As for incentives, the status quo for many years has been that Gecko has no incentive to add Document.charset, and IE/WebKit/Blink have no incentive to remove it. The result is a small but ever-present opportunity for writing non-portable code...

In this case, the quickest path to interop appears to be for Blink to remove the setter and for the spec and Gecko to add the getter. Other ideas welcome :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115519</commentid>
    <comment_count>12</comment_count>
    <who name="Masatoshi Kimura">VYV03354</who>
    <bug_when>2014-11-26 15:10:35 +0000</bug_when>
    <thetext>document.charset was once spec&apos;ed then removed. Why is it going to added once again? Because WebKit refused to remove it? Because everyone except Gecko has the support? (It is basically what I said in Gecko bug 647621 comment #0.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115525</commentid>
    <comment_count>13</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 15:32:05 +0000</bug_when>
    <thetext>Masatoshi, do you have another proposal for how to reach agreement between the spec and browsers?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115529</commentid>
    <comment_count>14</comment_count>
    <who name="Ehsan Akhgari [:ehsan]">ehsan</who>
    <bug_when>2014-11-26 15:59:19 +0000</bug_when>
    <thetext>I&apos;m not necessarily opposed to Gecko implementing the getter, but I would like to know what we will gain from that (in addition to comment 11, of course.)  Specifically, do we have any data on how this property is used on the 4% of pages viewed in Blink based browsers?  If we have a way to obtain more info on the actual usage of this property on the Web, that may help guide us to decide whether it makes more sense for Gecko to implement or for Blink/IE to drop.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115538</commentid>
    <comment_count>15</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-26 19:10:47 +0000</bug_when>
    <thetext>The 4% is any access to Document.charset, notably including code like (document.charset || document.characterSet) that would work without it, which is likely a large majority of cases.

Answering questions like these using Blink&apos;s UseCounter system is difficult, one would have to collect a representative sample of pages that access document.charset and analyze them manually.

If someone has access to a large corpus of Web content, a grep for pages that say &quot;document.charset&quot; without &quot;document.characterSet&quot; in the vicinity might be illuminating.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115604</commentid>
    <comment_count>16</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-27 09:38:03 +0000</bug_when>
    <thetext>I added compatibility names in https://github.com/whatwg/dom/commit/03e170351f095e4fe749e0259a3aafc0cbb49c91

I want to wait with adding .charset until at least the setter has disappeared. Removing that seems like a win for everyone. Then we can evaluate again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115606</commentid>
    <comment_count>17</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-27 09:52:36 +0000</bug_when>
    <thetext>OK, I&apos;ll try to get rid of the Document.charset setter and then report back here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120384</commentid>
    <comment_count>18</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-05-20 14:33:49 +0000</bug_when>
    <thetext>I&apos;ve now removed the setter from Blink, let&apos;s hope it sticks:
https://code.google.com/p/chromium/issues/detail?id=438392#c4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123263</commentid>
    <comment_count>19</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-09-21 09:27:25 +0000</bug_when>
    <thetext>The removal of the setter appears to have worked out. It was gone in M45, which reached Chrome stable on September 1. Now that Document.charset is an alias of Document.characterSet, can we spec it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123268</commentid>
    <comment_count>20</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-09-22 06:36:26 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/6941936bd06438f84ad91d131e2e89ab0f1f7a45</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123272</commentid>
    <comment_count>21</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2015-09-22 07:56:19 +0000</bug_when>
    <thetext>https://github.com/w3c/web-platform-tests/pull/2192</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>