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 // This test gets sent commands to execute, which it is sent by the
6 // controlling C++ code. This code then checks that the apps' active state
7 // is being tracked correctly.
10 function windowClosed() {
14 function processNextCommand() {
15 chrome.test.sendMessage("ready", function(response) {
16 if (response == 'exit')
19 if (response == 'closeLastWindow') {
20 windowToClose = windows.pop();
21 windowToClose.close();
25 // Otherwise we are creating a window.
28 if (response == 'createMinimized')
29 createOptions.state = 'minimized';
31 if (response == 'createHidden')
32 createOptions.hidden = true;
34 chrome.app.window.create('empty.html', createOptions,
35 function(createdWindow) {
36 handleWindowReady = function() {
37 createdWindow.onClosed.addListener(windowClosed);
38 windows.push(createdWindow);
42 if (createOptions.hidden)
45 createdWindow.handleWindowFirstShownForTests(handleWindowReady);