Skip to content

Commit

Permalink
Make clipboard-apis tests more robust to local variations in html (we…
Browse files Browse the repository at this point in the history
…b-platform-tests#49255)

This makes the test more robust to variation of markup resulting of clipboard operation. It really tests the script element has been removed and not that the full html is identical to a canonical form.
  • Loading branch information
karlcow authored Nov 20, 2024
1 parent b57af9a commit a9b5e57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions clipboard-apis/async-html-script-removal.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
const html_with_script =
'<title>Title of the document</title> <script>const a = 5;</scr'
+ 'ipt> <p>Hello World</p>';
const html_without_script =
'<title>Title of the document</title> <p>Hello World</p>';
const html_script =
'<script>const a = 5;</scr'
+ 'ipt>';
promise_test(async t => {
await tryGrantReadPermission();
await tryGrantWritePermission();
Expand All @@ -53,8 +54,7 @@
const blobText = await (new Response(blobOutput)).text();

const outputHtml = reformatHtml(blobText);
const inputHtml = reformatHtml(html_without_script);
assert_equals(outputHtml, inputHtml);
}, 'Verify write and read clipboard with scripts removed given text/html: '
+ html_with_script);
const html_script_no_spaces = reformatHtml(html_script);
assert_true(!outputHtml.includes(html_script_no_spaces));
}, 'Verify write and read clipboard with scripts removed given text/html. The string "' + html_script + '" has been removed.');
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const htmlBlob = await items[0].getType("text/html");
const html = await htmlBlob.text();

assert_equals(html, '<img src="https://example.com/oops">');
assert_true(html.includes('<img src="https://example.com/oops">'));

// Allow resource loading to start asynchronously
await new Promise(resolve => test.step_timeout(resolve, 100));
Expand Down

0 comments on commit a9b5e57

Please sign in to comment.