Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / platform_apps / active_test / test.js
blobb2671c5661710277fd376016d12238d57dfb76be
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.
8 var windows = [];
10 function windowClosed() {
11   processNextCommand();
14 function processNextCommand() {
15   chrome.test.sendMessage("ready", function(response) {
16     if (response == 'exit')
17       return;
19     if (response == 'closeLastWindow') {
20       windowToClose = windows.pop();
21       windowToClose.close();
22       return;
23     }
25     // Otherwise we are creating a window.
26     createOptions = {};
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);
39         processNextCommand();
40       }
42       if (createOptions.hidden)
43         handleWindowReady();
44       else
45         createdWindow.handleWindowFirstShownForTests(handleWindowReady);
46     });
47   });
50 processNextCommand();