-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For whatwg/html#4332.
- Loading branch information
Showing
7 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
html/semantics/forms/form-submission-target/rel-base-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<title><form rel> with <base target></title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=resources/reltester.js></script> | ||
<base target=_blank> | ||
<div id=log></div> | ||
<form action=resources/endpoint.html><input type=hidden name=channelname></form> | ||
<script> | ||
const submitter = document.querySelector("form"), | ||
channelInput = document.querySelector("input"); | ||
relTester(submitter, channelInput, "<base target>"); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
html/semantics/forms/form-submission-target/rel-button-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<title><form rel> with <button formtarget></title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=resources/reltester.js></script> | ||
<div id=log></div> | ||
<form action=resources/endpoint.html><input type=hidden name=channelname><button type=submit formtarget=_blank></form> | ||
<script> | ||
const submitter = document.querySelector("button"), | ||
channelInput = document.querySelector("input"); | ||
relTester(submitter, channelInput, "<button formtarget>"); | ||
</script> |
12 changes: 12 additions & 0 deletions
12
html/semantics/forms/form-submission-target/rel-form-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<title><form rel target></title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=resources/reltester.js></script> | ||
<div id=log></div> | ||
<form action=resources/endpoint.html target=_blank><input type=hidden name=channelname></form> | ||
<script> | ||
const submitter = document.querySelector("form"), | ||
channelInput = document.querySelector("input"); | ||
relTester(submitter, channelInput, "<form target>"); | ||
</script> |
13 changes: 13 additions & 0 deletions
13
html/semantics/forms/form-submission-target/rel-input-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<title><form rel> with <input formtarget></title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=resources/reltester.js></script> | ||
<base target=_blank> | ||
<div id=log></div> | ||
<form action=resources/endpoint.html><input type=hidden name=channelname><input type=submit formtarget=_blank></form> | ||
<script> | ||
const submitter = document.querySelector("input[type=submit]"), | ||
channelInput = document.querySelector("input"); | ||
relTester(submitter, channelInput, "<input formtarget>"); | ||
</script> |
11 changes: 11 additions & 0 deletions
11
html/semantics/forms/form-submission-target/resources/endpoint.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script> | ||
const channelName = new URL(location).searchParams.get("channelname"), | ||
channel = new BroadcastChannel(channelName); | ||
channel.postMessage({ haveOpener: window.opener !== null, | ||
referrer: document.referrer }); | ||
// Because messages are not delivered synchronously and because closing a | ||
// browsing context prompts the eventual clearing of all task sources, this | ||
// document should not be closed until the opener document has confirmed | ||
// receipt. | ||
channel.onmessage = () => window.close(); | ||
</script> |
65 changes: 65 additions & 0 deletions
65
html/semantics/forms/form-submission-target/resources/reltester.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function relTester(submitter, channelInput, title) { | ||
[ | ||
{ | ||
rel: "", | ||
exposed: "all" | ||
}, | ||
{ | ||
rel: "noopener", | ||
exposed: "noopener" | ||
}, | ||
{ | ||
rel: "noreferrer", | ||
exposed: "noreferrer" | ||
}, | ||
{ | ||
rel: "opener", | ||
exposed: "all" | ||
}, | ||
{ | ||
rel: "noopener noreferrer", | ||
exposed: "noreferrer" | ||
}, | ||
{ | ||
rel: "noreferrer opener", | ||
exposed: "noreferrer" | ||
}, | ||
{ | ||
rel: "opener noopener", | ||
exposed: "noopener" | ||
} | ||
].forEach(relTest => { | ||
// Use promise_test to submit only after one test concluded | ||
promise_test(t => { | ||
return new Promise(resolve => { | ||
const channelName = Date.now() + relTest.rel, | ||
channel = new BroadcastChannel(channelName); | ||
let form = submitter; | ||
if (submitter.localName !== "form") { | ||
form = submitter.form; | ||
} | ||
form.rel = relTest.rel; | ||
channelInput.value = channelName; | ||
if (submitter.localName !== "form") { | ||
submitter.click(); | ||
} else { | ||
submitter.submit(); | ||
} | ||
channel.onmessage = t.step_func(e => { | ||
if (relTest.exposed === "all" || relTest.exposed === "noopener") { | ||
assert_equals(e.data.referrer, window.location.href, "referrer"); | ||
} else { | ||
assert_equals(e.data.referrer, "", "referrer"); | ||
} | ||
if (relTest.exposed === "all") { | ||
assert_true(e.data.haveOpener, "opener"); | ||
} else { | ||
assert_false(e.data.haveOpener, "opener"); | ||
} | ||
resolve(); | ||
}); | ||
t.add_cleanup(() => channel.postMessage(null)); | ||
}); | ||
}, `<form rel="${relTest.rel}"> with ${title}`); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters