| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Font settings API test for split mode (in incognito context) | 5 // Font settings API test for split mode (in incognito context) |
| 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettingsIncognito | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.FontSettingsIncognito |
| 7 | 7 |
| 8 var fs = chrome.experimental.fontSettings; | 8 var fs = chrome.experimental.fontSettings; |
| 9 | 9 |
| 10 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; | 10 var CONTROLLABLE_BY_THIS_EXTENSION = 'controllable_by_this_extension'; |
| 11 var SET_FROM_INCOGNITO_ERROR = | 11 var SET_FROM_INCOGNITO_ERROR = |
| 12 "Can't modify regular settings from an incognito context."; | 12 "Can't modify regular settings from an incognito context."; |
| 13 | 13 |
| 14 function expect(expected, message) { | 14 function expect(expected, message) { |
| 15 return chrome.test.callbackPass(function(value) { | 15 return chrome.test.callbackPass(function(value) { |
| 16 chrome.test.assertEq(expected, value, message); | 16 chrome.test.assertEq(expected, value, message); |
| 17 }); | 17 }); |
| 18 } | 18 } |
| 19 | 19 |
| 20 chrome.test.runTests([ | 20 chrome.test.runTests([ |
| 21 function setPerScriptFont() { | 21 function setPerScriptFont() { |
| 22 var script = 'Hang'; | 22 var script = 'Kore'; |
| 23 var genericFamily = 'standard'; | 23 var genericFamily = 'standard'; |
| 24 var fontName = 'Verdana'; | 24 var fontName = 'Verdana'; |
| 25 | 25 |
| 26 fs.setFont({ | 26 fs.setFont({ |
| 27 script: script, | 27 script: script, |
| 28 genericFamily: genericFamily, | 28 genericFamily: genericFamily, |
| 29 fontName: fontName | 29 fontName: fontName |
| 30 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); | 30 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); |
| 31 }, | 31 }, |
| 32 | 32 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 54 fs.getFontList(chrome.test.callbackPass(function(value) { | 54 fs.getFontList(chrome.test.callbackPass(function(value) { |
| 55 chrome.test.assertTrue(value.length > 0, | 55 chrome.test.assertTrue(value.length > 0, |
| 56 "Font list is not expected to be empty."); | 56 "Font list is not expected to be empty."); |
| 57 chrome.test.assertEq('string', typeof(value[0].fontName), message); | 57 chrome.test.assertEq('string', typeof(value[0].fontName), message); |
| 58 chrome.test.assertEq('string', typeof(value[0].localizedName), message); | 58 chrome.test.assertEq('string', typeof(value[0].localizedName), message); |
| 59 })); | 59 })); |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 function getPerScriptFontName() { | 62 function getPerScriptFontName() { |
| 63 fs.getFont({ | 63 fs.getFont({ |
| 64 script: 'Hang', | 64 script: 'Kore', |
| 65 genericFamily: 'standard' | 65 genericFamily: 'standard' |
| 66 }, expect({ | 66 }, expect({ |
| 67 fontName: 'Tahoma', | 67 fontName: 'Tahoma', |
| 68 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 68 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 69 })); | 69 })); |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 function getGlobalFontName() { | 72 function getGlobalFontName() { |
| 73 fs.getFont({ | 73 fs.getFont({ |
| 74 genericFamily: 'sansserif' | 74 genericFamily: 'sansserif' |
| 75 }, expect({ | 75 }, expect({ |
| 76 fontName: 'Arial', | 76 fontName: 'Arial', |
| 77 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 77 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 78 })); | 78 })); |
| 79 }, | 79 }, |
| 80 | 80 |
| 81 function getDefaultFontSize() { | 81 function getDefaultFontSize() { |
| 82 fs.getDefaultFontSize({}, expect({ | 82 fs.getDefaultFontSize({}, expect({ |
| 83 pixelSize: 16, | 83 pixelSize: 16, |
| 84 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION | 84 levelOfControl: CONTROLLABLE_BY_THIS_EXTENSION |
| 85 })); | 85 })); |
| 86 }, | 86 }, |
| 87 | 87 |
| 88 function clearPerScriptFont() { | 88 function clearPerScriptFont() { |
| 89 var script = 'Hang'; | 89 var script = 'Kore'; |
| 90 var genericFamily = 'standard'; | 90 var genericFamily = 'standard'; |
| 91 | 91 |
| 92 fs.clearFont({ | 92 fs.clearFont({ |
| 93 script: script, | 93 script: script, |
| 94 genericFamily: genericFamily, | 94 genericFamily: genericFamily, |
| 95 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); | 95 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); |
| 96 }, | 96 }, |
| 97 | 97 |
| 98 function clearGlobalFont() { | 98 function clearGlobalFont() { |
| 99 var genericFamily = 'sansserif'; | 99 var genericFamily = 'sansserif'; |
| 100 | 100 |
| 101 fs.clearFont({ | 101 fs.clearFont({ |
| 102 genericFamily: genericFamily, | 102 genericFamily: genericFamily, |
| 103 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); | 103 }, chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 function clearDefaultFontSize() { | 106 function clearDefaultFontSize() { |
| 107 fs.clearDefaultFontSize({}, | 107 fs.clearDefaultFontSize({}, |
| 108 chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); | 108 chrome.test.callbackFail(SET_FROM_INCOGNITO_ERROR)); |
| 109 } | 109 } |
| 110 ]); | 110 ]); |
| 111 | 111 |
| OLD | NEW |