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.
5 // Font settings API test for split mode (in incognito context)
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettingsIncognito
8 var fs
= chrome
.fontSettings
;
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.";
14 function expect(expected
, message
) {
15 return chrome
.test
.callbackPass(function(value
) {
16 chrome
.test
.assertEq(expected
, value
, message
);
20 chrome
.test
.runTests([
21 function setPerScriptFont() {
23 var genericFamily
= 'standard';
24 var fontId
= 'Verdana';
28 genericFamily
: genericFamily
,
30 }, chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));
33 function setGlobalFontName() {
34 var genericFamily
= 'sansserif';
35 var fontId
= 'Tahoma';
38 genericFamily
: genericFamily
,
40 }, chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));
43 function setDefaultFontSize() {
46 fs
.setDefaultFontSize({
48 }, chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));
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
);
62 function getPerScriptFontName() {
65 genericFamily
: 'standard'
68 levelOfControl
: CONTROLLABLE_BY_THIS_EXTENSION
72 function getGlobalFontName() {
74 genericFamily
: 'sansserif'
77 levelOfControl
: CONTROLLABLE_BY_THIS_EXTENSION
81 function getDefaultFontSize() {
82 fs
.getDefaultFontSize({}, expect({
84 levelOfControl
: CONTROLLABLE_BY_THIS_EXTENSION
88 function clearPerScriptFont() {
90 var genericFamily
= 'standard';
94 genericFamily
: genericFamily
,
95 }, chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));
98 function clearGlobalFont() {
99 var genericFamily
= 'sansserif';
102 genericFamily
: genericFamily
,
103 }, chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));
106 function clearDefaultFontSize() {
107 fs
.clearDefaultFontSize({},
108 chrome
.test
.callbackFail(SET_FROM_INCOGNITO_ERROR
));