Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / font_settings / incognito / launch.js
blob7ae953bd739db9b338269ece4937e79a4450a776
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);
17 });
20 chrome.test.runTests([
21 function setPerScriptFont() {
22 var script = 'Hang';
23 var genericFamily = 'standard';
24 var fontId = 'Verdana';
26 fs.setFont({
27 script: script,
28 genericFamily: genericFamily,
29 fontId: fontId
30 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
33 function setGlobalFontName() {
34 var genericFamily = 'sansserif';
35 var fontId = 'Tahoma';
37 fs.setFont({
38 genericFamily: genericFamily,
39 fontId: fontId
40 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
43 function setDefaultFontSize() {
44 var pixelSize = 22;
46 fs.setDefaultFontSize({
47 pixelSize: pixelSize
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);
59 }));
62 function getPerScriptFontName() {
63 fs.getFont({
64 script: 'Hang',
65 genericFamily: 'standard'
66 }, expect({
67 fontId: 'Tahoma',
68 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
69 }));
72 function getGlobalFontName() {
73 fs.getFont({
74 genericFamily: 'sansserif'
75 }, expect({
76 fontId: 'Arial',
77 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
78 }));
81 function getDefaultFontSize() {
82 fs.getDefaultFontSize({}, expect({
83 pixelSize: 16,
84 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION
85 }));
88 function clearPerScriptFont() {
89 var script = 'Hang';
90 var genericFamily = 'standard';
92 fs.clearFont({
93 script: script,
94 genericFamily: genericFamily,
95 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR));
98 function clearGlobalFont() {
99 var genericFamily = 'sansserif';
101 fs.clearFont({
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));