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 = {};
7 // This ID will be checked in the test.
8 var DUMMY_ITEM_ID = 'DUMMY_ITEM_ID_FOR_TEST';
14 cwsContainerMock.onMessage = function (message) {
16 source = message.source;
17 origin = message.origin;
19 switch (data['message']) {
21 cwsContainerMock.onInitialize();
23 case 'install_success':
24 cwsContainerMock.onInstallSuccess();
29 cwsContainerMock.onInitialize = function() {
31 source.postMessage({message: 'widget_loaded'}, origin);
34 cwsContainerMock.onInstallSuccess = function() {
37 message: 'after_install',
38 item_id: DUMMY_ITEM_ID
42 cwsContainerMock.onInstallButton = function() {
43 if (source && origin) {
45 {message: 'before_install', item_id:DUMMY_ITEM_ID}, origin);
51 function onInstallButton() {
52 cwsContainerMock.onInstallButton();
55 window.addEventListener('message', cwsContainerMock.onMessage);