Skip to content

Commit

Permalink
basic sd test
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed Nov 11, 2020
1 parent 3302033 commit bf24e23
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions suite.js
Expand Up @@ -753,6 +753,45 @@ void function() {
assert.equal(dialog2.returnValue, 'dialog2 default close value',
'second dialog shouldn\'t reuse formSubmitter');
});
test('form submit inside SD', function(done) {
if (!window.ShadowRoot) {
return;
}

var holder = document.createElement('div');
document.body.append(holder);
cleanup(holder);

var root = holder.attachShadow({mode: 'open'});
var rootHolder = document.createElement('div');
root.append(rootHolder);
rootHolder.append(dialog);

var iframe = document.createElement('iframe');
iframe.setAttribute('name', 'blah');
document.body.append(iframe);
cleanup(iframe);

var form = document.createElement('form');
form.setAttribute('method', 'dialog');
form.setAttribute('target', 'blah');
form.setAttribute('action', '/test-invalid.html');
dialog.append(form);

var button = document.createElement('button');
button.value = 'from form1: first value';
form.append(button);
dialog.showModal();

console.warn('before button pressed', iframe.contentWindow.location.href);
button.click();

// TODO(samthor): this is a bit gross as this will pass if the button is not pressed at all.
window.setTimeout(() => {
assert.notStrictEqual(iframe.contentWindow.location.pathname, '/test-invalid.html');
done();
}, 500);
});
});

suite('order', function() {
Expand Down
1 change: 1 addition & 0 deletions test-invalid.html
@@ -0,0 +1 @@
This page should not load.

0 comments on commit bf24e23

Please sign in to comment.