- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / font_settings / incognito / launch.js
1 // Copyright (c) 2012 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 // Font settings API test for split mode (in incognito context)
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettingsIncognito
7
8 var fs = chrome.fontSettings;
9
10 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension';
11 var SET_FROM_INCOGNITO_ERROR =
12     "Can't modify regular settings from an incognito context.";
13
14 function expect(expected, message) {
15   return chrome.test.callbackPass(function(value) {
16     chrome.test.assertEq(expected, value, message);
17   });
18 }
19
20 chrome.test.runTests([
21   function setPerScriptFont() {
22     var script = 'Hang';
23     var genericFamily = 'standard';
24     var fontId = 'Verdana';
25
26     fs.setFont({
27       script: script,
28       genericFamily: genericFamily,
29       fontId: fontId
30     }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
31   },
32
33   function setGlobalFontName() {
34     var genericFamily = 'sansserif';
35     var fontId = 'Tahoma';
36
37     fs.setFont({
38       genericFamily: genericFamily,
39       fontId: fontId
40     }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
41   },
42
43   function setDefaultFontSize() {
44     var pixelSize = 22;
45
46     fs.setDefaultFontSize({
47       pixelSize: pixelSize
48     }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
49   },
50
51   function getFontList() {
52     var message = 'getFontList should return an array of objects with ' +
53         'fontId and displayName properties.';
54     fs.getFontList(chrome.test.callbackPass(function(value) {
55       chrome.test.assertTrue(value.length > 0,
56                              "Font list is not expected to be empty.");
57       chrome.test.assertEq('string', typeof(value[0].fontId), message);
58       chrome.test.assertEq('string', typeof(value[0].displayName), message);
59     }));
60   },
61
62   function getPerScriptFontName() {
63     fs.getFont({
64       script: 'Hang',
65       genericFamily: 'standard'
66     }, expect({
67       fontId: 'Tahoma',
68       levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
69     }));
70   },
71
72   function getGlobalFontName() {
73     fs.getFont({
74       genericFamily: 'sansserif'
75     }, expect({
76       fontId: 'Arial',
77       levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
78     }));
79   },
80
81   function getDefaultFontSize() {
82     fs.getDefaultFontSize({}, expect({
83       pixelSize: 16,
84       levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
85     }));
86   },
87
88   function clearPerScriptFont() {
89     var script = 'Hang';
90     var genericFamily = 'standard';
91
92     fs.clearFont({
93       script: script,
94       genericFamily: genericFamily,
95     }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
96   },
97
98   function clearGlobalFont() {
99     var genericFamily = 'sansserif';
100
101    fs.clearFont({
102       genericFamily: genericFamily,
103     }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
104   },
105
106   function clearDefaultFontSize() {
107     fs.clearDefaultFontSize({},
108                             chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
109   }
110 ]);
111