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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html

Issue 2370843003: Suborigin LayoutTest formatting and refactoring (Closed)
Patch Set: Created 4 years, 2 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <meta charset="utf-8">
4 <title>Validate that unsafe-postmessage-send allows Suborigin to send messages a s physical origin via postMessage.</title> 5 <title>Validate that unsafe-postmessage-send allows Suborigin to send messages a s physical origin via postMessage.</title>
5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testharnessreport.js"></script>
7 </head> 8 </head>
8 <script> 9 <script>
9 var iframe_test = async_test("Validate serialization of event.origin and event.s uborigin in postMessage from an iframe"); 10 async_test(t => {
10 var window_test = async_test("Validate serialization of event.origin and event.s uborigin in postMessage from a window"); 11 window.addEventListener('message', make_test(t, 'iframe'));
12 },
13 'Validate serialization of event.origin and event.suborigin in ' +
14 'postMessage from an iframe using \'unsafe-postmessage-send\'');
15 async_test(t => {
16 window.addEventListener('message', make_test(t, 'window'));
17 },
18 'Validate serialization of event.origin and event.suborigin in ' +
19 'postMessage from a window using \'unsafe-postmessage-send\'');
11 20
12 window.onmessage = function(event) { 21 function make_test(t, name) {
13 if (event.data.type === 'iframe') { 22 return t.step_func(function(event) {
14 iframe_test.step(function() { 23 if (event.data.type === name) {
15 assert_equals(event.origin, "http://127.0.0.1:8000"); 24 assert_equals(event.origin, 'http://127.0.0.1:8000');
16 assert_equals(event.suborigin, "foobar1"); 25 assert_equals(event.suborigin, name);
17 assert_equals(event.data.suborigin, "foobar1"); 26 assert_equals(event.data.suborigin, name);
18 iframe_test.done(); 27 t.done();
19 }); 28 }
20 } else if (event.data.type === 'window') { 29 });
21 window_test.step(function() {
22 assert_equals(event.origin, "http://127.0.0.1:8000");
23 assert_equals(event.suborigin, "foobar2");
24 assert_equals(event.data.suborigin, "foobar2");;
25 window_test.done();
26 });
27 } else {
28 assert_unreached();
29 }
30
31 } 30 }
32 31
33 window.open("resources/post-document-to-parent.php?suborigin=foobar2&type=window &suboriginpolicy='unsafe-postmessage-send'"); 32 window.open(
33 'resources/post-document-to-parent.php?suborigin=window&type=window&' +
34 'suboriginpolicy=\'unsafe-postmessage-send\'');
34 </script> 35 </script>
35 <iframe src="resources/post-document-to-parent.php?suborigin=foobar1&type=iframe &suboriginpolicy='unsafe-postmessage-send'"></iframe> 36 <iframe src="resources/post-document-to-parent.php?suborigin=iframe&type=iframe& suboriginpolicy='unsafe-postmessage-send'"></iframe>
36 </html> 37 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698