Skip to content

Commit

Permalink
html: Add a testcase for submit event reentrancy protection
Browse files Browse the repository at this point in the history
Specification: whatwg/html#4621
  • Loading branch information
tkent-google committed May 14, 2019
1 parent 7560720 commit 74df56e
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,33 @@
assert_equals(counter, 2);
}, 'If constructing entry list flag of form is true, then return');

let test10 = async_test('Cannot navigate (after constructing the entry list)');
test10.step(() => {

async_test(t => {
let form = populateForm('<input type=hidden name=n value=v0><input type=submit>');
let submitter = form.querySelector('[type=submit]');
let iframe = form.previousSibling;
form.onsubmit = () => {
let hidden = form.querySelector('[type=hidden]');
hidden.value = 'inner click()';
submitter.click();
hidden.value = 'v2';
};
submitter.click();
iframe.onload = t.step_func_done(() => {
assert_not_equals(iframe.contentWindow.location.search.indexOf('n=v2'), -1);
});
}, "If form's firing submit event is true, then return");

let test9 = async_test('Cannot navigate (after constructing the entry list)');
test9.step(() => {
let form = populateForm('<input name=n1 value=v1>');
form.onformdata = (e) => { e.target.remove(); };
let wasLoaded = false;
let iframe = form.previousSibling;
// Request to load '/common/dummy.xhtml', and immediately submit the form to
// the same frame. If the form submission is aborted, the first request
// will be completed.
iframe.onload = test10.step_func_done(() => {
iframe.onload = test9.step_func_done(() => {
wasLoaded = true;
assert_true(iframe.contentWindow.location.search.indexOf('n1=v1') == -1);
});
Expand Down

0 comments on commit 74df56e

Please sign in to comment.