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=ExtensionPreferenceApiTest.Standard |
7 | 7 |
| 8 var pn = chrome.privacy.network; |
8 var preferences_to_test = [ | 9 var preferences_to_test = [ |
9 { | 10 { |
10 root: chrome.privacy.network, | 11 root: chrome.privacy.network, |
11 preferences: [ | 12 preferences: [ |
12 'networkPredictionEnabled', | 13 'networkPredictionEnabled' |
13 'webRTCMultipleRoutesEnabled', | |
14 'webRTCNonProxiedUdpEnabled' | |
15 ] | 14 ] |
16 }, | 15 }, |
17 { | 16 { |
18 root: chrome.privacy.websites, | 17 root: chrome.privacy.websites, |
19 preferences: [ | 18 preferences: [ |
20 'thirdPartyCookiesAllowed', | 19 'thirdPartyCookiesAllowed', |
21 'hyperlinkAuditingEnabled', | 20 'hyperlinkAuditingEnabled', |
22 'referrersEnabled', | 21 'referrersEnabled', |
23 'protectedContentEnabled' | 22 'protectedContentEnabled' |
24 ] | 23 ] |
(...skipping 10 matching lines...) Expand all Loading... |
35 'searchSuggestEnabled', | 34 'searchSuggestEnabled', |
36 'spellingServiceEnabled', | 35 'spellingServiceEnabled', |
37 'translationServiceEnabled' | 36 'translationServiceEnabled' |
38 ] | 37 ] |
39 }, | 38 }, |
40 ]; | 39 ]; |
41 | 40 |
42 // Some preferences are only present on certain platforms or are hidden | 41 // Some preferences are only present on certain platforms or are hidden |
43 // behind flags and might not be present when this test runs. | 42 // behind flags and might not be present when this test runs. |
44 var possibly_missing_preferences = new Set([ | 43 var possibly_missing_preferences = new Set([ |
45 'protectedContentEnabled', // Windows/ChromeOS only | 44 'protectedContentEnabled' // Windows/ChromeOS only |
46 'webRTCMultipleRoutesEnabled', // requires ENABLE_WEBRTC=1 | |
47 'webRTCNonProxiedUdpEnabled' // requires ENABLE_WEBRTC=1 | |
48 ]); | 45 ]); |
49 | 46 |
50 function expect(expected, message) { | 47 function expect(expected, message) { |
51 return chrome.test.callbackPass(function(value) { | 48 return chrome.test.callbackPass(function(value) { |
52 chrome.test.assertEq(expected, value, message); | 49 chrome.test.assertEq(expected, value, message); |
53 }); | 50 }); |
54 } | 51 } |
55 | 52 |
56 function expectFalse(pref) { | 53 function expectFalse(pref) { |
57 return expect({ | 54 return expect({ |
(...skipping 21 matching lines...) Expand all Loading... |
79 for (var i = 0; i < preferences_to_test.length; i++) { | 76 for (var i = 0; i < preferences_to_test.length; i++) { |
80 preferences_to_test[i].preferences.forEach( | 77 preferences_to_test[i].preferences.forEach( |
81 prefGetter.bind(preferences_to_test[i].root)); | 78 prefGetter.bind(preferences_to_test[i].root)); |
82 } | 79 } |
83 }, | 80 }, |
84 function setGlobals() { | 81 function setGlobals() { |
85 for (var i = 0; i < preferences_to_test.length; i++) { | 82 for (var i = 0; i < preferences_to_test.length; i++) { |
86 preferences_to_test[i].preferences.forEach( | 83 preferences_to_test[i].preferences.forEach( |
87 prefSetter.bind(preferences_to_test[i].root)); | 84 prefSetter.bind(preferences_to_test[i].root)); |
88 } | 85 } |
| 86 }, |
| 87 function getWebRTCIPHandlingPolicy() { |
| 88 if (pn.webRTCIPHandlingPolicy == undefined) { |
| 89 chrome.test.callbackPass(); |
| 90 return; |
| 91 } |
| 92 pn.webRTCIPHandlingPolicy.get( |
| 93 {}, |
| 94 expect({ 'value': |
| 95 chrome.privacy.IPHandlingPolicy.DEFAULT_PUBLIC_INTERFACE_ONLY, |
| 96 'levelOfControl': "controllable_by_this_extension" }, |
| 97 "should receive default_public_interface_only.")); |
| 98 }, |
| 99 function setWebRTCIPHandlingPolicy() { |
| 100 if (pn.webRTCIPHandlingPolicy == undefined) { |
| 101 chrome.test.callbackPass(); |
| 102 return; |
| 103 } |
| 104 pn.webRTCIPHandlingPolicy.set( |
| 105 { 'value': |
| 106 chrome.privacy.IPHandlingPolicy.DISABLE_NON_PROXIED_UDP}, |
| 107 chrome.test.callbackPass()); |
89 } | 108 } |
90 ]); | 109 ]); |
OLD | NEW |