Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / mime_handler_view / test_postmessage.js
blob709bbb426048242468c1d98d51db27034f5e2c0e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var messages = ['hey', 100, 25.0];
6 var messagesSent = 0;
7 var messagesReceived = 0;
9 window.addEventListener('message', function(event) {
10 if (event.data == messages[messagesReceived]) {
11 messagesReceived++;
12 if (messagesReceived == messages.length)
13 // Instruct the extension to call chrome.test.succeed().
14 plugin.postMessage('succeed');
15 } else {
16 // Instruct the extension to call chrome.test.fail().
17 plugin.postMessage('fail');
19 }, false);
21 var plugin = document.getElementById('plugin');
22 function postNextMessage() {
23 plugin.postMessage(messages[messagesSent]);
24 messagesSent++;
25 if (messagesSent < messages.length)
26 setTimeout(postNextMessage, 0);
28 postNextMessage();