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

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

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

Powered by Google App Engine
This is Rietveld 408576698