Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / windows_api_always_on_top / has_permissions_stable / background.js
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.
4
5 var callbackPass = chrome.test.callbackPass;
6
7 function testAlwaysOnTop(testId, value) {
8   var options = {
9     id: testId,
10     alwaysOnTop: value
11   };
12
13   chrome.app.window.create('index.html',
14                            options,
15                            callbackPass(function(win) {
16     // Check that isAlwaysOnTop() returns false because the feature is not
17     // permitted in Stable.
18     chrome.test.assertEq(false, win.isAlwaysOnTop());
19
20     // Attempt to use setAlwaysOnTop() to change the property. But this should
21     // also fail.
22     win.setAlwaysOnTop(value);
23
24     // setAlwaysOnTop is synchronous in the browser, so send an async request to
25     // ensure we get the updated value of isAlwaysOnTop.
26     chrome.runtime.getPlatformInfo(callbackPass(function(platformInfo) {
27       // Check that isAlwaysOnTop() returns false.
28       chrome.test.assertEq(false, win.isAlwaysOnTop());
29
30       win.contentWindow.close();
31     }));
32   }));
33 }
34
35 chrome.app.runtime.onLaunched.addListener(function() {
36   chrome.test.runTests([
37
38     // Try to enable alwaysOnTop on window creation and after window creation.
39     function testAlwaysOnTopEnable() {
40       testAlwaysOnTop('testAlwaysOnTopEnable', true);
41     },
42
43     // Try to disable alwaysOnTop on window creation and after window creation.
44     function testAlwaysOnTopDisable() {
45       testAlwaysOnTop('testAlwaysOnTopDisable', false);
46     }
47
48   ]);
49 });