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

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

Issue 2634893003: Experiment with blocking resolution of HTTP URLs containing '\n' and '<'. (Closed)
Patch Set: Culling. 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/dangling-markup/src-attribute.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function assert_no_message_from_frame(test, frame) { 1 function assert_no_message_from_frame(test, frame) {
2 window.addEventListener("message", test.step_func(e => { 2 window.addEventListener("message", test.step_func(e => {
3 assert_not_equals(e.source, frame.contentWindow); 3 assert_not_equals(e.source, frame.contentWindow);
4 })); 4 }));
5 } 5 }
6 6
7 function appendFrameAndGetElement(test, frame) {
8 return new Promise((resolve, reject) => {
9 frame.onload = test.step_func(_ => {
10 frame.onload = null;
11 resolve(frame.contentDocument.querySelector('#dangling'));
12 });
13 document.body.appendChild(frame);
14 });
15 }
16
7 function appendAndSubmit(test, frame) { 17 function appendAndSubmit(test, frame) {
8 return new Promise((resolve, reject) => { 18 return new Promise((resolve, reject) => {
9 frame.onload = test.step_func(_ => { 19 frame.onload = test.step_func(_ => {
10 frame.onload = null; 20 frame.onload = null;
11 frame.contentDocument.querySelector('form').addEventListener("error", _ => { 21 frame.contentDocument.querySelector('form').addEventListener("error", _ => {
12 resolve("error"); 22 resolve("error");
13 }); 23 });
14 frame.contentDocument.querySelector('form').addEventListener("submit", _ = > { 24 frame.contentDocument.querySelector('form').addEventListener("submit", _ = > {
15 resolve("submit"); 25 resolve("submit");
16 }); 26 });
17 frame.contentDocument.querySelector('[type=submit]').click(); 27 frame.contentDocument.querySelector('[type=submit]').click();
18 }); 28 });
19 document.body.appendChild(frame); 29 document.body.appendChild(frame);
20 }); 30 });
21 } 31 }
22 32
23 function assert_no_submission(test, frame) { 33 function assert_no_submission(test, frame) {
24 assert_no_message_from_frame(test, frame); 34 assert_no_message_from_frame(test, frame);
25 35
26 appendAndSubmit(test, frame) 36 appendAndSubmit(test, frame)
27 .then(test.step_func_done(result => { 37 .then(test.step_func_done(result => {
28 assert_equals(result, "error"); 38 assert_equals(result, "error");
29 frame.remove(); 39 frame.remove();
30 })); 40 }));
31 } 41 }
32 42
43 function assert_img_loaded(test, frame) {
44 appendFrameAndGetElement(test, frame)
45 .then(test.step_func_done(img => {
46 assert_equals(img.naturalHeight, 103, "Height");
47 assert_equals(img.naturalWidth, 76, "Width");
48 }));
49 }
50
51 function assert_img_not_loaded(test, frame) {
52 appendFrameAndGetElement(test, frame)
53 .then(test.step_func_done(img => {
54 assert_equals(img.naturalHeight, 0, "Height");
55 assert_equals(img.naturalWidth, 0, "Width");
56 }));
57 }
58
33 function createFrame(markup) { 59 function createFrame(markup) {
34 var i = document.createElement('iframe'); 60 var i = document.createElement('iframe');
35 i.srcdoc = `${markup}sekrit`; 61 i.srcdoc = `${markup}sekrit`;
36 return i; 62 return i;
37 } 63 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/dangling-markup/src-attribute.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698