1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Content settings API test
6 // Run with browser_tests
7 // --gtest_filter=ExtensionPreferenceApiTest.DataReductionProxy
9 var dataReductionProxy
= chrome
.dataReductionProxy
;
10 var privatePreferences
= chrome
.preferencesPrivate
;
11 chrome
.test
.runTests([
12 function getDrpPrefs() {
13 dataReductionProxy
.spdyProxyEnabled
.get({}, chrome
.test
.callbackPass(
18 'levelOfControl': 'controllable_by_this_extension'
22 dataReductionProxy
.dataReductionDailyContentLength
.get({},
23 chrome
.test
.callbackPass(function(result
) {
27 'levelOfControl': 'controllable_by_this_extension'
31 dataReductionProxy
.dataReductionDailyReceivedLength
.get({},
32 chrome
.test
.callbackPass(function(result
) {
36 'levelOfControl': 'controllable_by_this_extension'
40 privatePreferences
.dataReductionUpdateDailyLengths
.get({},
41 chrome
.test
.callbackPass(function(result
) {
49 function updateDailyLengths() {
50 dataReductionProxy
.dataReductionDailyContentLength
.onChange
.addListener(
51 confirmDailyContentLength
);
52 dataReductionProxy
.dataReductionDailyReceivedLength
.onChange
.addListener(
53 confirmRecievedLength
);
55 // Trigger calls to confirmDailyContentLength.onChange and
56 // dataReductionDailyReceivedLength.onChange listeners.
57 dataReductionProxy
.spdyProxyEnabled
.set({ 'value': true });
58 privatePreferences
.dataReductionUpdateDailyLengths
.set({'value': true});
61 var expectedDailyLengths
= [];
62 for (var i
= 0; i
< 60; i
++) {
63 expectedDailyLengths
[i
] = '0';
65 function confirmRecievedLength() {
66 dataReductionProxy
.dataReductionDailyReceivedLength
.get({},
67 chrome
.test
.callbackPass(function(result
) {
70 'value': expectedDailyLengths
,
71 'levelOfControl': 'controllable_by_this_extension'
75 privatePreferences
.dataReductionUpdateDailyLengths
.get({},
76 chrome
.test
.callbackPass(function(result
) {
84 function confirmDailyContentLength() {
85 dataReductionProxy
.dataReductionDailyContentLength
.get({},
86 chrome
.test
.callbackPass(function(result
) {
89 'value': expectedDailyLengths
,
90 'levelOfControl': 'controllable_by_this_extension'
93 dataReductionProxy
.dataReductionDailyContentLength
.onChange
.
94 removeListener(confirmDailyContentLength
);
96 privatePreferences
.dataReductionUpdateDailyLengths
.get({},
97 chrome
.test
.callbackPass(function(result
) {
103 dataReductionProxy
.dataReductionDailyReceivedLength
.onChange
.
104 removeListener(confirmRecievedLength
);
108 function clearDataSavings() {
109 dataReductionProxy
.spdyProxyEnabled
.set({ 'value': true });
111 dataReductionProxy
.clearDataSavings(function() {
112 // Confirm that data is cleared
113 dataReductionProxy
.dataReductionDailyContentLength
.get({},
114 chrome
.test
.callbackPass(function(result
) {
115 chrome
.test
.assertEq(
118 'levelOfControl': 'controllable_by_this_extension'
122 dataReductionProxy
.dataReductionDailyReceivedLength
.get({},
123 chrome
.test
.callbackPass(function(result
) {
124 chrome
.test
.assertEq(
127 'levelOfControl': 'controllable_by_this_extension'