Bug 280749
| Summary: | serialization/deserialization during read/write operation of Clipboard APIs is different from other browsers | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Karl Dubost <karlcow> |
| Component: | HTML Editing | Assignee: | Karl Dubost <karlcow> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | rniwa, webkit-bug-importer, wenson_hsieh |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar, WPTImpact |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | https://wpt.live/clipboard-apis/async-html-script-removal.https.html | ||
Karl Dubost
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Karl Dubost
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
Similar serialization failure for
https://wpt.fyi/results/clipboard-apis/async-write-html-read-html.https.html
Radar WebKit Bug Importer
<rdar://problem/137577746>
Karl Dubost
Pull request: https://github.com/WebKit/WebKit/pull/36789
EWS
Committed 286766@main (f37595518038): <https://commits.webkit.org/286766@main>
Reviewed commits have been landed. Closing PR #36789 and removing active labels.