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

Side by Side Diff: LayoutTests/dart/Window-postMessage.html

Issue 1532413002: Added Dartium changes onto 45.0.2454.104 (Closed) Base URL: http://src.chromium.org/blink/branches/chromium/2454
Patch Set: Created 5 years 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
« no previous file with comments | « LayoutTests/dart/Node-expected.txt ('k') | LayoutTests/dart/Window-postMessage-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <html>
2 <body>
3
4 <div id='status'></div>
5 <iframe src='resources/pong.html'></iframe>
6
7 <script type='application/dart'>
8 import 'dart:html';
9
10 class MessageQueue {
11 final WindowBase _main;
12 final WindowBase _target;
13 final List _messages;
14 int _pos = -1;
15
16 MessageQueue(this._main, this._target, this._messages);
17
18 void run() {
19 scheduleNext();
20 }
21
22 void scheduleNext() {
23 _pos++;
24 if (_pos == _messages.length) {
25 _notifyDone();
26 return;
27 }
28
29 if (_pos % 2 == 0) {
30 _target.postMessage(currentMessage, '*', []);
31 } else {
32 _target.postMessage(currentMessage, '*');
33 }
34 output('message sent: $currentMessage');
35 }
36
37 get currentMessage => _messages[_pos];
38
39 void _notifyDone() {
40 window.postMessage('test-done', '*');
41 }
42 }
43
44 void main() {
45 IFrameElement iframeElement = document.queryAll('iframe')[0];
46 iframeElement.onLoad.listen(test);
47 }
48
49 test(Event e) {
50 WindowBase other = document.queryAll('iframe')[0].contentWindow;
51
52 // FIXME: consider support for WebCore objects like File, FileList.
53 MessageQueue messageQueue = new MessageQueue(window, other, [null, 'I am a str ing']);
54
55 window.onMessage.listen(
56 (Event event) {
57 output('response received: ${event.data}');
58 output('event.source === other: ${event.source == other}');
59 messageQueue.scheduleNext();
60 });
61
62 try {
63 other.postMessage();
64 } catch(_) {
65 output('.postMessage() throws');
66 }
67
68 try {
69 other.postMessage(null);
70 } catch (_) {
71 output('.postMessage(null) throws');
72 }
73
74 messageQueue.run();
75 }
76
77 output(var object) {
78 final status = document.query('#status');
79 status.innerHtml = '${status.innerHtml}$object<br>';
80 }
81
82 </script>
83
84 <script>
85 if (window.testRunner) {
86 window.testRunner.dumpAsText();
87 window.testRunner.waitUntilDone();
88 }
89
90 window.addEventListener('message', function (e) {
91 if (e.data == 'test-done') {
92 window.testRunner.notifyDone();
93 }
94 });
95
96 </script>
97
98 </body>
99 </html>
OLDNEW
« no previous file with comments | « LayoutTests/dart/Node-expected.txt ('k') | LayoutTests/dart/Window-postMessage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698