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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/dart/Window-postMessage.html
diff --git a/LayoutTests/dart/Window-postMessage.html b/LayoutTests/dart/Window-postMessage.html
new file mode 100644
index 0000000000000000000000000000000000000000..b2df36d07de96f608f10d40eff96cab799313c4b
--- /dev/null
+++ b/LayoutTests/dart/Window-postMessage.html
@@ -0,0 +1,99 @@
+<html>
+<body>
+
+<div id='status'></div>
+<iframe src='resources/pong.html'></iframe>
+
+<script type='application/dart'>
+import 'dart:html';
+
+class MessageQueue {
+ final WindowBase _main;
+ final WindowBase _target;
+ final List _messages;
+ int _pos = -1;
+
+ MessageQueue(this._main, this._target, this._messages);
+
+ void run() {
+ scheduleNext();
+ }
+
+ void scheduleNext() {
+ _pos++;
+ if (_pos == _messages.length) {
+ _notifyDone();
+ return;
+ }
+
+ if (_pos % 2 == 0) {
+ _target.postMessage(currentMessage, '*', []);
+ } else {
+ _target.postMessage(currentMessage, '*');
+ }
+ output('message sent: $currentMessage');
+ }
+
+ get currentMessage => _messages[_pos];
+
+ void _notifyDone() {
+ window.postMessage('test-done', '*');
+ }
+}
+
+void main() {
+ IFrameElement iframeElement = document.queryAll('iframe')[0];
+ iframeElement.onLoad.listen(test);
+}
+
+test(Event e) {
+ WindowBase other = document.queryAll('iframe')[0].contentWindow;
+
+ // FIXME: consider support for WebCore objects like File, FileList.
+ MessageQueue messageQueue = new MessageQueue(window, other, [null, 'I am a string']);
+
+ window.onMessage.listen(
+ (Event event) {
+ output('response received: ${event.data}');
+ output('event.source === other: ${event.source == other}');
+ messageQueue.scheduleNext();
+ });
+
+ try {
+ other.postMessage();
+ } catch(_) {
+ output('.postMessage() throws');
+ }
+
+ try {
+ other.postMessage(null);
+ } catch (_) {
+ output('.postMessage(null) throws');
+ }
+
+ messageQueue.run();
+}
+
+output(var object) {
+ final status = document.query('#status');
+ status.innerHtml = '${status.innerHtml}$object<br>';
+}
+
+</script>
+
+<script>
+ if (window.testRunner) {
+ window.testRunner.dumpAsText();
+ window.testRunner.waitUntilDone();
+ }
+
+ window.addEventListener('message', function (e) {
+ if (e.data == 'test-done') {
+ window.testRunner.notifyDone();
+ }
+ });
+
+</script>
+
+</body>
+</html>
« 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