Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /navigation-api/navigate-event/navigate-form-requestSubmit.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<form id="form" method="post" action="">
<input type="submit" id="submit1">
<input type="image" id="submit2">
<button type="submit" id="submit3">
</form>
<script>
promise_test(async () => {
await new Promise(r => window.onload = r);
let sourceElement;
navigation.onnavigate = e => {
e.preventDefault();
sourceElement = e.sourceElement;
};
form.requestSubmit(submit1);
await new Promise(r => navigation.onnavigateerror = r);
assert_equals(sourceElement, submit1);
form.requestSubmit(submit2);
await new Promise(r => navigation.onnavigateerror = r);
assert_equals(sourceElement, submit2);
form.requestSubmit(submit3);
await new Promise(r => navigation.onnavigateerror = r);
assert_equals(sourceElement, submit3);
form.requestSubmit();
await new Promise(r => navigation.onnavigateerror = r);
assert_equals(sourceElement, form);
}, "<form> requestSubmit() sets sourceElement");
</script>