Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / windows_api_ime / has_permissions_platform_app / background.js
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.
4
5 var error = "The \"ime\" option is not supported for platform app.";
6
7 function testImeEnabled(setOption, opt_setValue) {
8   var createOptions = { frame: 'none' };
9   if (setOption) {
10     createOptions.ime = opt_setValue;
11     chrome.app.window.create('index.html',
12                              createOptions,
13                              chrome.test.callbackFail(error));
14   } else {
15     chrome.app.window.create('index.html',
16                              createOptions,
17                              chrome.test.callbackPass(function(win){
18     }));
19   }
20 }
21
22 // All these tests are run with app.window.ime permission set and on a system
23 // with ime window support.
24 chrome.app.runtime.onLaunched.addListener(function() {
25   chrome.test.runTests([
26     // Window is created with ime explicitly set by platform app.
27     // Expect fail.
28     function testImeEnabledPermissionWithPlatformApp() {
29       testImeEnabled(true, true);
30       testImeEnabled(true, false);
31     },
32
33     // Window is created with ime not explicitly set.
34     // Expect pass.
35     function testImeEnabledPermissionImeNoInit() {
36       testImeEnabled(false);
37     }
38   ]);
39 });