RESOLVED FIXED280749
serialization/deserialization during read/write operation of Clipboard APIs is different from other browsers
https://bugs.webkit.org/show_bug.cgi?id=280749
Summary serialization/deserialization during read/write operation of Clipboard APIs i...
Karl Dubost
Reported 2024-10-02 02:28:11 PDT
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: "<title>Title of the document</title> <script>const a = 5;</script> <p>Hello World</p>" EXPECTED: "<head> <title>Title of the document</title> </head> <body> <p>Hello World</p> </body>" ACTUAL: "<head> </head> <body> <p style=\"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;\">Hello World</p> </body> The script element has been correctly removed but: 1. <title> has not been preserved 2. The <head> and <body> 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: 'text/html'}) ? 2. new ClipboardItem({'text/html': blobInput}) ? 3. navigator.clipboard.write([clipboardItem]) ? 4. await navigator.clipboard.read() ? 5. await (new Response(blobOutput)).text() ?
Attachments
Karl Dubost
Comment 1 2024-10-02 05:06:27 PDT
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't seem to mandate a way to write the HTML.
Karl Dubost
Comment 2 2024-10-02 05:20:30 PDT
Radar WebKit Bug Importer
Comment 3 2024-10-09 02:29:17 PDT
Karl Dubost
Comment 4 2024-11-18 01:01:03 PST
EWS
Comment 5 2024-11-18 16:01:22 PST
Committed 286766@main (f37595518038): <https://commits.webkit.org/286766@main> Reviewed commits have been landed. Closing PR #36789 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.