-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1586978 [wpt PR 19562] - html: Add tests for SubmitEvent interfac…
…e, a=testonly Automatic update from web-platform-tests html: Add tests for SubmitEvent interface (#19562) Specification PR: whatwg/html#4984 -- wpt-commits: 61c2804bf27a7abc1b8bc406627f6bf3b3344f14 wpt-pr: 19562 Differential Revision: https://phabricator.services.mozilla.com/D53600 UltraBlame original commit: 8e52d11e8347d0a5573b9c349fa15722ef7448b1
- Loading branch information
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
testing/web-platform/tests/html/semantics/forms/form-submission-0/SubmitEvent.window.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,36 @@ | ||
|
||
|
||
test(() => { | ||
let button = document.createElement('button'); | ||
let typeError = new TypeError(); | ||
assert_throws(typeError, () => { new SubmitEvent() }, '0 arguments'); | ||
assert_throws(typeError, () => { new SubmitEvent('bar', button) }, '1 invalid arguments'); | ||
assert_throws(typeError, () => { new SubmitEvent(button, button) }, '2 invalid arguments'); | ||
assert_throws(typeError, () => { new SubmitEvent('foo', null) }, 'Null dictionary'); | ||
assert_throws(typeError, () => { new SubmitEvent('foo', undefined) }, 'Undefined dictionary'); | ||
assert_throws(typeError, () => { new SubmitEvent('foo', { submitter: null }) }, 'Null submitter'); | ||
assert_throws(typeError, () => { new SubmitEvent('foo', { submitter: undefined }) }, 'Undefined submitter'); | ||
assert_throws(typeError, () => { new SubmitEvent('foo', { submitter: 'bar' }) }, 'Wrong type of submitter'); | ||
}, 'Failing SubmitEvent constructor'); | ||
|
||
test(() => { | ||
let button = document.createElement('button'); | ||
let event = new SubmitEvent('bar', { submitter: button, bubbles: true }); | ||
assert_equals(event.submitter, button); | ||
assert_true(event.bubbles); | ||
}, 'Successful SubmitEvent constructor'); | ||
|
||
test(() => { | ||
let event = new SubmitEvent('bar', { submitter: null}); | ||
assert_equals(event.submitter, null); | ||
}, 'Successful SubmitEvent constructor; null submitter'); | ||
|
||
test(() => { | ||
let event = new SubmitEvent('baz', {}); | ||
assert_equals(event.submitter, null); | ||
}, 'Successful SubmitEvent constructor; empty dictionary'); | ||
|
||
test(() => { | ||
let event = new SubmitEvent('baz'); | ||
assert_equals(event.submitter, null); | ||
}, 'Successful SubmitEvent constructor; missing dictionary'); |
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
39 changes: 39 additions & 0 deletions
39
...b-platform/tests/html/semantics/forms/form-submission-0/implicit-submission.optional.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,39 @@ | ||
<!DOCTYPE html> | ||
<link rel="help" href="https://html.spec.whatwg.org/C/#implicit-submission"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="./resources/targetted-form.js"></script> | ||
<body> | ||
<script> | ||
// This test file is "optional" because triggering implicit submission by | ||
// "Enter" key is not standardized. | ||
|
||
const ENTER = '\uE007'; | ||
|
||
promise_test(async () => { | ||
let form = populateForm('<input name=text value=abc><input name=submiButton type=submit>'); | ||
let event; | ||
form.text.focus(); | ||
form.addEventListener('submit', e => { event = e; }); | ||
await test_driver.send_keys(form.text, ENTER); | ||
assert_true(event.bubbles); | ||
assert_true(event.cancelable); | ||
assert_equals(event.submitter, form.submitButton); | ||
assert_true(event instanceof SubmitEvent); | ||
}, 'Submit event with a submit button'); | ||
|
||
promise_test(async () => { | ||
let form = populateForm('<input name=text value=abc>'); | ||
let event; | ||
form.text.focus(); | ||
form.addEventListener('submit', e => { event = e; }); | ||
await test_driver.send_keys(form.text, ENTER); | ||
assert_true(event.bubbles); | ||
assert_true(event.cancelable); | ||
assert_equals(event.submitter, null); | ||
assert_true(event instanceof SubmitEvent); | ||
}, 'Submit event with no submit button'); | ||
</script> | ||
</body> |
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