Skip to content

Commit

Permalink
Add a few missing post-insertion-step tests (web-platform-tests#44906)
Browse files Browse the repository at this point in the history
* Add insertion step for meta with referrer+script

* Added form association test

* Rename Node-appendChild-form-and-script-from-fragment.tentative.html to Node-append-form-and-script-from-fragment.tentative.html

* Rename Node-appendChild-meta-referrer-and-script-from-fragment.tentative.html to Node-append-meta-referrer-and-script-from-fragment.tentative.html
  • Loading branch information
noamr authored and BruceDai committed Mar 25, 2024
1 parent d18acb6 commit 2729f9f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and associated form</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<button id="someButton" form="someForm"></button>
<script>
test(() => {
const script = document.createElement("script");
const form = document.createElement("form");
form.id = "someForm";
const fragment = new DocumentFragment();
script.textContent = `
window.buttonAssociatedForm = document.querySelector("#someButton").form;
`;
fragment.append(script, form);
document.body.append(fragment);
assert_equals(window.buttonAssociatedForm, form);
}, "When adding a script+form in a fragment and the form matches an associated element, " +
"the script that checks whether the button is associated to the form should run after " +
"inserting the form");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype html>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and meta-referrer from a div</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
promise_test(async t => {
const script = document.createElement("script");
const meta = document.createElement("meta");
meta.name = "referrer";
meta.content = "no-referrer";
const fragment = new DocumentFragment();
const done = new Promise(resolve => {
window.didFetch = resolve;
});
script.textContent = `
(async function() {
const response = await fetch("/html/infrastructure/urls/terminology-0/resources/echo-referrer-text.py")
const text = await response.text();
window.didFetch(text);
})();
`;
fragment.append(script, meta);
document.head.append(fragment);
const result = await done;
assert_equals(result, "");
}, "<meta name=referrer> should apply before script, as it is an insertion step " +
"and not a post-insertion step");
</script>

0 comments on commit 2729f9f

Please sign in to comment.