Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / chromeos / file_manager / cws_container_mock / main.js
blobe4dd9f39e7015993d6509ee73acb4ef62ff2e474
1 // Copyright 2013 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 cwsContainerMock = {};
6 (function() {
7 // This ID will be checked in the test.
8 var DUMMY_ITEM_ID = 'DUMMY_ITEM_ID_FOR_TEST';
10 var origin = null;
11 var data = null;
12 var source = null;
14 cwsContainerMock.onMessage = function (message) {
15 data = message.data;
16 source = message.source;
17 origin = message.origin;
19 switch (data['message']) {
20 case 'initialize':
21 cwsContainerMock.onInitialize(source);
22 break;
26 cwsContainerMock.onInitialize = function() {
27 if (source && origin)
28 source.postMessage({message: 'widget_loaded'}, origin);
31 cwsContainerMock.onInstallButton = function() {
32 if (source && origin) {
33 source.postMessage(
34 {message: 'before_install', item_id:DUMMY_ITEM_ID}, origin);
38 })();
40 function onInstallButton() {
41 cwsContainerMock.onInstallButton();
44 window.addEventListener('message', cwsContainerMock.onMessage);