<?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>280749</bug_id>
          
          <creation_ts>2024-10-02 02:28:11 -0700</creation_ts>
          <short_desc>serialization/deserialization during read/write operation of Clipboard APIs is different from other browsers</short_desc>
          <delta_ts>2024-11-18 16:01:24 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://wpt.live/clipboard-apis/async-html-script-removal.https.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar, WPTImpact</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2064816</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-10-02 02:28:11 -0700</bug_when>
    <thetext>The test at https://wpt.live/clipboard-apis/async-html-script-removal.https.html
is supposed to check the script tag removal while doing a clipboard write and read operation

INPUT:    &quot;&lt;title&gt;Title of the document&lt;/title&gt; &lt;script&gt;const a = 5;&lt;/script&gt; &lt;p&gt;Hello World&lt;/p&gt;&quot;

EXPECTED: &quot;&lt;head&gt; &lt;title&gt;Title of the document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Hello World&lt;/p&gt; &lt;/body&gt;&quot; 

ACTUAL:   &quot;&lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p style=\&quot;caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;\&quot;&gt;Hello World&lt;/p&gt; &lt;/body&gt;

The script element has been correctly removed but:

1. &lt;title&gt; has not been preserved
2. The &lt;head&gt; and &lt;body&gt; elements have not been added
3. the style attribute has been added with some values. 


At this stage in the test, the content is already wrong.
const blobText = await (new Response(blobOutput)).text();

The issue is happening in between these
https://github.com/web-platform-tests/wpt/blob/b40c843d18efb71ab2f1343ce53e82d06cdf7702/clipboard-apis/async-html-script-removal.https.html#L39-L53


Something is not normalizing the same way, but which steps of the process. 

1. new Blob([html_with_script], {type: &apos;text/html&apos;}) ?
2. new ClipboardItem({&apos;text/html&apos;: blobInput}) ?
3. navigator.clipboard.write([clipboardItem]) ?
4. await navigator.clipboard.read() ?
5. await (new Response(blobOutput)).text() ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2064824</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-10-02 05:06:27 -0700</bug_when>
    <thetext>On the other hand I wonder if there is a specific required serialization apart of the sanitized version of html, aka removing the script element. 

Maybe the test could be adjusted to check that the script has been removed instead of checking the full html. 

https://w3c.github.io/clipboard-apis/#dom-clipboard-read
https://w3c.github.io/clipboard-apis/#dom-clipboard-write

yes the spec doesn&apos;t seem to mandate a way to write the HTML.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2064827</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-10-02 05:20:30 -0700</bug_when>
    <thetext>Similar serialization failure for 
https://wpt.fyi/results/clipboard-apis/async-write-html-read-html.https.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2066456</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-10-09 02:29:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/137577746&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075763</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-11-18 01:01:03 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/36789</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075983</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-11-18 16:01:22 -0800</bug_when>
    <thetext>Committed 286766@main (f37595518038): &lt;https://commits.webkit.org/286766@main&gt;

Reviewed commits have been landed. Closing PR #36789 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>