OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 // Preferences API test |
| 3 // Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceApi |
| 4 |
| 5 var preferences_to_test = [ |
| 6 { |
| 7 root: chrome.experimental.privacy.network, |
| 8 preferences: [ |
| 9 'networkPredictionEnabled' |
| 10 ] |
| 11 }, |
| 12 { |
| 13 root: chrome.experimental.privacy.websites, |
| 14 preferences: [ |
| 15 'thirdPartyCookiesAllowed', |
| 16 'hyperlinkAuditingEnabled', |
| 17 'referrersEnabled' |
| 18 ] |
| 19 }, |
| 20 { |
| 21 root: chrome.experimental.privacy.services, |
| 22 preferences: [ |
| 23 'alternateErrorPagesEnabled', |
| 24 'autofillEnabled', |
| 25 'instantEnabled', |
| 26 // TODO(mkwst): 'metricsReportingEnabled', |
| 27 'safeBrowsingEnabled', |
| 28 'searchSuggestEnabled', |
| 29 'translationServiceEnabled' |
| 30 ] |
| 31 }, |
| 32 ]; |
| 33 |
| 34 function expect(expected, message) { |
| 35 return chrome.test.callbackPass(function(value) { |
| 36 chrome.test.assertEq(expected, value, message); |
| 37 }); |
| 38 } |
| 39 |
| 40 function expectFalse(pref) { |
| 41 return expect({ |
| 42 value: false, |
| 43 levelOfControl: 'controllable_by_this_extension' |
| 44 }, '`' + pref + '` is expected to be false.'); |
| 45 } |
| 46 |
| 47 function prefGetter(pref) { |
| 48 this[pref].get({}, expectFalse(pref)); |
| 49 } |
| 50 |
| 51 function prefSetter(pref) { |
| 52 this[pref].set({value: true}, chrome.test.callbackPass()); |
| 53 } |
| 54 |
| 55 chrome.test.runTests([ |
| 56 function getPreferences() { |
| 57 for (var i = 0; i < preferences_to_test.length; i++) { |
| 58 preferences_to_test[i].preferences.forEach( |
| 59 prefGetter.bind(preferences_to_test[i].root)); |
| 60 } |
| 61 }, |
| 62 function setGlobals() { |
| 63 for (var i = 0; i < preferences_to_test.length; i++) { |
| 64 preferences_to_test[i].preferences.forEach( |
| 65 prefSetter.bind(preferences_to_test[i].root)); |
| 66 } |
| 67 } |
| 68 ]); |
| 69 </script> |
OLD | NEW |