Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / webmessaging / event.source.htm
blob365a5feb476592dd88eb7fa00f563ce556143e95
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title> Same-origin: event.source returns the WindowProxy of the source window </title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <div id=log></div>
11 <div style="display:none">
12 <iframe width="70%" onload="PostMessageTest()" src="./support/ChildWindowPostMessage.htm"></iframe>
13 </div>
15 <script>
18 var description = "Test Description: Same-origin: event.source returns the WindowProxy of the source window.";
20 var t = async_test(description);
22 var DATA = "foo";
23 var TARGET = document.querySelector("iframe");
24 var SORIGIN = location.protocol + "//" + location.host;
25 var ExpectedResult = [SORIGIN, "AccessCookieAllowed"];
26 var ActualResult = [];
28 function PostMessageTest()
30 TARGET.contentWindow.postMessage(DATA, SORIGIN);
33 window.onmessage = t.step_func(function(e)
35 try
37 var sdomainCookie = e.source.document.cookie;
38 ActualResult.push(e.origin, "AccessCookieAllowed");
40 catch(ex)
42 ActualResult.push(e.origin, "AccessCookieDenied");
45 assert_equals(e.source, TARGET.contentWindow);
46 assert_array_equals(ActualResult, ExpectedResult, "ActualResult");
47 t.done();
48 });
49 </script>
50 </body>
51 </html>