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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/webmessaging/event.origin.sub.htm

Issue 2558423002: Import wpt/webmessaging tests (Closed)
Patch Set: rebase again 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title> event.origin returns the origin of the message </title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <div id=log></div>
10
11 <div style="display:none">
12 <iframe width="70%" onload="PostMessageTest()" src="{{location[scheme]}}://{ {domains[www]}}:{{location[port]}}/webmessaging/support/ChildWindowPostMessage.h tm"></iframe>
13 <iframe width="70%" onload="PostMessageTest()" src="./support/ChildWindowPos tMessage.htm"></iframe>
14 </div>
15
16 <script>
17
18
19 var description = "Test Description: event.origin returns the origin of the message.";
20
21 var t = async_test(description);
22
23 var PORT = location.port !== "" ? ":" + location.port : "";
24 var TARGET1 = document.querySelectorAll("iframe")[0];
25 var TARGET2 = document.querySelectorAll("iframe")[1];
26 var XORIGIN = "{{location[scheme]}}://{{domains[www]}}" + PORT;
27 var SORIGIN = "{{location[scheme]}}://{{host}}" + PORT;
28 var ExpectedResult = ["#1", XORIGIN, "#2", SORIGIN];
29 var ActualResult = [];
30 var loaded = 0;
31
32 function PostMessageTest()
33 {
34 loaded++;
35
36 if (loaded == 2)
37 {
38 TARGET1.contentWindow.postMessage("#1", XORIGIN);
39 TARGET2.contentWindow.postMessage("#2", SORIGIN);
40 }
41 }
42
43 window.onmessage = t.step_func(function(e)
44 {
45 // testharness.js uses postMessage so we must check what data we want to receive
46 if (e.data.toString() === "#1" || e.data.toString() === "#2") {
47 ActualResult.push(e.data, e.origin);
48 if (ActualResult.length === ExpectedResult.length) {
49 assert_array_equals(ActualResult, ExpectedResult, "ActualResult" );
50 t.done();
51 }
52 }
53 });
54 </script>
55 </body>
56 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698