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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html
index 3dae87e2e036ce13521e241be223c7552232795e..3867abd7cc824113d2962ed6817172075a5f5ac5 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html
@@ -1,36 +1,37 @@
<!DOCTYPE html>
<html>
<head>
+<meta charset="utf-8">
<title>Validate that unsafe-postmessage-send allows Suborigin to send messages as physical origin via postMessage.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
-var iframe_test = async_test("Validate serialization of event.origin and event.suborigin in postMessage from an iframe");
-var window_test = async_test("Validate serialization of event.origin and event.suborigin in postMessage from a window");
-
-window.onmessage = function(event) {
- if (event.data.type === 'iframe') {
- iframe_test.step(function() {
- assert_equals(event.origin, "http://127.0.0.1:8000");
- assert_equals(event.suborigin, "foobar1");
- assert_equals(event.data.suborigin, "foobar1");
- iframe_test.done();
- });
- } else if (event.data.type === 'window') {
- window_test.step(function() {
- assert_equals(event.origin, "http://127.0.0.1:8000");
- assert_equals(event.suborigin, "foobar2");
- assert_equals(event.data.suborigin, "foobar2");;
- window_test.done();
- });
- } else {
- assert_unreached();
- }
+async_test(t => {
+ window.addEventListener('message', make_test(t, 'iframe'));
+ },
+ 'Validate serialization of event.origin and event.suborigin in ' +
+ 'postMessage from an iframe using \'unsafe-postmessage-send\'');
+async_test(t => {
+ window.addEventListener('message', make_test(t, 'window'));
+ },
+ 'Validate serialization of event.origin and event.suborigin in ' +
+ 'postMessage from a window using \'unsafe-postmessage-send\'');
+function make_test(t, name) {
+ return t.step_func(function(event) {
+ if (event.data.type === name) {
+ assert_equals(event.origin, 'http://127.0.0.1:8000');
+ assert_equals(event.suborigin, name);
+ assert_equals(event.data.suborigin, name);
+ t.done();
+ }
+ });
}
-window.open("resources/post-document-to-parent.php?suborigin=foobar2&type=window&suboriginpolicy='unsafe-postmessage-send'");
+window.open(
+ 'resources/post-document-to-parent.php?suborigin=window&type=window&' +
+ 'suboriginpolicy=\'unsafe-postmessage-send\'');
</script>
-<iframe src="resources/post-document-to-parent.php?suborigin=foobar1&type=iframe&suboriginpolicy='unsafe-postmessage-send'"></iframe>
+<iframe src="resources/post-document-to-parent.php?suborigin=iframe&type=iframe&suboriginpolicy='unsafe-postmessage-send'"></iframe>
</html>

Powered by Google App Engine
This is Rietveld 408576698