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 // Preferences API test | 5 // Preferences API test |
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceApi | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceApi |
7 | 7 |
8 var preferences_to_test = [ | 8 var preferences_to_test = [ |
9 { | 9 { |
10 root: chrome.privacy.network, | 10 root: chrome.privacy.network, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 function expectFalse(pref) { | 44 function expectFalse(pref) { |
45 return expect({ | 45 return expect({ |
46 value: false, | 46 value: false, |
47 levelOfControl: 'controllable_by_this_extension' | 47 levelOfControl: 'controllable_by_this_extension' |
48 }, '`' + pref + '` is expected to be false.'); | 48 }, '`' + pref + '` is expected to be false.'); |
49 } | 49 } |
50 | 50 |
51 function prefGetter(pref) { | 51 function prefGetter(pref) { |
52 if (pref === 'protectedContentEnabled' && !this[pref]) { | 52 if (pref === 'protectedContentEnabled' && !this[pref]) { |
53 // `protectedContentEnabled` is ChromeOS only, so it might not exist when | 53 // `protectedContentEnabled` is Windows/ChromeOS only, so it might not exist |
54 // this test runs, and that's pretty much OK. | 54 // when this test runs, and that's pretty much OK. |
55 return true; | 55 return true; |
56 } | 56 } |
57 this[pref].get({}, expectFalse(pref)); | 57 this[pref].get({}, expectFalse(pref)); |
58 } | 58 } |
59 | 59 |
60 function prefSetter(pref) { | 60 function prefSetter(pref) { |
61 if (pref === 'protectedContentEnabled' && !this[pref]) { | 61 if (pref === 'protectedContentEnabled' && !this[pref]) { |
62 // `protectedContentEnabled` is ChromeOS only, so it might not exist when | 62 // `protectedContentEnabled` is Windows/ChromeOS only, so it might not exist |
63 // this test runs, and that's pretty much OK. | 63 // when this test runs, and that's pretty much OK. |
64 return true; | 64 return true; |
65 } | 65 } |
66 this[pref].set({value: true}, chrome.test.callbackPass()); | 66 this[pref].set({value: true}, chrome.test.callbackPass()); |
67 } | 67 } |
68 | 68 |
69 chrome.test.runTests([ | 69 chrome.test.runTests([ |
70 function getPreferences() { | 70 function getPreferences() { |
71 for (var i = 0; i < preferences_to_test.length; i++) { | 71 for (var i = 0; i < preferences_to_test.length; i++) { |
72 preferences_to_test[i].preferences.forEach( | 72 preferences_to_test[i].preferences.forEach( |
73 prefGetter.bind(preferences_to_test[i].root)); | 73 prefGetter.bind(preferences_to_test[i].root)); |
74 } | 74 } |
75 }, | 75 }, |
76 function setGlobals() { | 76 function setGlobals() { |
77 for (var i = 0; i < preferences_to_test.length; i++) { | 77 for (var i = 0; i < preferences_to_test.length; i++) { |
78 preferences_to_test[i].preferences.forEach( | 78 preferences_to_test[i].preferences.forEach( |
79 prefSetter.bind(preferences_to_test[i].root)); | 79 prefSetter.bind(preferences_to_test[i].root)); |
80 } | 80 } |
81 } | 81 } |
82 ]); | 82 ]); |
OLD | NEW |