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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>149911</bug_id>
          
          <creation_ts>2015-10-07 20:29:06 -0700</creation_ts>
          <short_desc>document.execCommand() should not count as a &quot;user edit&quot; for the purposes of ValidityState.tooLong</short_desc>
          <delta_ts>2015-10-08 02:47:09 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Forms</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc>http://jsfiddle.net/cvrebert/vdy3emx2/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Rebert">webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>enrica</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1131524</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Rebert">webkit</who>
    <bug_when>2015-10-07 20:29:06 -0700</bug_when>
    <thetext>Steps to reproduce the problem:
1. Open http://jsfiddle.net/cvrebert/vdy3emx2/ in WebKit Nightly
2. Look at the console output.

What is the expected behavior?
The console output should be:
&gt; Before script edit: false
&gt; After script edit: false

Quoting from https://html.spec.whatwg.org/multipage/forms.html#attr-fe-maxlength

&gt; Constraint validation: If an element has a maximum allowed value length, its dirty value flag is true, its value was last changed by a user edit (as opposed to a change made by a script), and the code-unit length of the element&apos;s value is greater than the element&apos;s maximum allowed value length, then the element is suffering from being too long.

Since the &lt;input&gt;&apos;s value was last changed by script unbiddenly invoking document.execCommand(), which should count as a script edit, not a user edit, the &lt;input&gt;&apos;s validity.tooLong boolean should remain false because the &quot;its value was last changed by a user edit (as opposed to a change made by a script)&quot; condition has not been satisfied.

What went wrong?
The actual console output is:
&gt; Before script edit: false
&gt; After script edit: true

Which indicates that document.execCommand() is being treated as a &quot;user edit&quot;, thus causing input.validity.tooLong to become true.


This bug is causing some test failures in
http://w3c-test.org/html/semantics/forms/constraints/form-validation-validity-tooLong.html
(AKA https://github.com/w3c/web-platform-tests/blob/master/html/semantics/forms/constraints/form-validation-validity-tooLong.html )

Analogous Chrome bug: https://code.google.com/p/chromium/issues/detail?id=540978</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1131578</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-10-08 02:39:30 -0700</bug_when>
    <thetext>The test is broken.

execCommand is an unspec&apos;ed feature, and only Blink and WebKit allows deletion inside input and textarea elements.

All other browsers are passing the test case because execCommand doesn&apos;t do anything in those browsers.

We need to fix the W3C test instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1131583</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2015-10-08 02:46:48 -0700</bug_when>
    <thetext>See https://github.com/w3c/web-platform-tests/issues/923</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>