Index: chrome/test/data/extensions/api_test/preference/standard/test.html |
diff --git a/chrome/test/data/extensions/api_test/preference/standard/test.html b/chrome/test/data/extensions/api_test/preference/standard/test.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..95864413066dde37f32b04cda9e596e4231bed93 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/preference/standard/test.html |
@@ -0,0 +1,69 @@ |
+<script> |
+// Preferences API test |
+// Run with browser_tests --gtest_filter=ExtensionApiTest.PreferenceApi |
+ |
+var preferences_to_test = [ |
+ { |
+ root: chrome.experimental.privacy.network, |
+ preferences: [ |
+ 'networkPredictionEnabled' |
+ ] |
+ }, |
+ { |
+ root: chrome.experimental.privacy.websites, |
+ preferences: [ |
+ 'thirdPartyCookiesAllowed', |
+ 'hyperlinkAuditingEnabled', |
+ 'referrersEnabled' |
+ ] |
+ }, |
+ { |
+ root: chrome.experimental.privacy.services, |
+ preferences: [ |
+ 'alternateErrorPagesEnabled', |
+ 'autofillEnabled', |
+ 'instantEnabled', |
+ // TODO(mkwst): 'metricsReportingEnabled', |
+ 'safeBrowsingEnabled', |
+ 'searchSuggestEnabled', |
+ 'translationServiceEnabled' |
+ ] |
+ }, |
+]; |
+ |
+function expect(expected, message) { |
+ return chrome.test.callbackPass(function(value) { |
+ chrome.test.assertEq(expected, value, message); |
+ }); |
+} |
+ |
+function expectFalse(pref) { |
+ return expect({ |
+ value: false, |
+ levelOfControl: 'controllable_by_this_extension' |
+ }, '`' + pref + '` is expected to be false.'); |
+} |
+ |
+function prefGetter(pref) { |
+ this[pref].get({}, expectFalse(pref)); |
+} |
+ |
+function prefSetter(pref) { |
+ this[pref].set({value: true}, chrome.test.callbackPass()); |
+} |
+ |
+chrome.test.runTests([ |
+ function getPreferences() { |
+ for (var i = 0; i < preferences_to_test.length; i++) { |
+ preferences_to_test[i].preferences.forEach( |
+ prefGetter.bind(preferences_to_test[i].root)); |
+ } |
+ }, |
+ function setGlobals() { |
+ for (var i = 0; i < preferences_to_test.length; i++) { |
+ preferences_to_test[i].preferences.forEach( |
+ prefSetter.bind(preferences_to_test[i].root)); |
+ } |
+ } |
+]); |
+</script> |