Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/dangling-markup/resources/helper.js

Issue 2628723004: Experiment with restricting form submission with open elements. (Closed)
Patch Set: Rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 function assert_no_message_from_frame(test, frame) {
2 window.addEventListener("message", test.step_func(e => {
3 assert_not_equals(e.source, frame.contentWindow);
4 }));
5 }
6
7 function appendAndSubmit(test, frame) {
8 return new Promise((resolve, reject) => {
9 frame.onload = test.step_func(_ => {
10 frame.onload = null;
11 frame.contentDocument.querySelector('form').addEventListener("error", _ => {
12 resolve("error");
13 });
14 frame.contentDocument.querySelector('form').addEventListener("submit", _ = > {
15 resolve("submit");
16 });
17 frame.contentDocument.querySelector('[type=submit]').click();
18 });
19 document.body.appendChild(frame);
20 });
21 }
22
23 function assert_no_submission(test, frame) {
24 assert_no_message_from_frame(test, frame);
25
26 appendAndSubmit(test, frame)
27 .then(test.step_func_done(result => {
28 assert_equals(result, "error");
29 frame.remove();
30 }));
31 }
32
33 function createFrame(markup) {
34 var i = document.createElement('iframe');
35 i.srcdoc = `${markup}sekrit`;
36 return i;
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698