Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / preference / data_reduction_proxy / test.js
blob4cf1c196a7539f1d427e21039d212dd17d23721b
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(
14 function(result) {
15 chrome.test.assertEq(
17 'value': false,
18 'levelOfControl': 'controllable_by_this_extension'
20 result);
21 }));
22 dataReductionProxy.dataReductionDailyContentLength.get({},
23 chrome.test.callbackPass(function(result) {
24 chrome.test.assertEq(
26 'value': [],
27 'levelOfControl': 'controllable_by_this_extension'
29 result);
30 }));
31 dataReductionProxy.dataReductionDailyReceivedLength.get({},
32 chrome.test.callbackPass(function(result) {
33 chrome.test.assertEq(
35 'value': [],
36 'levelOfControl': 'controllable_by_this_extension'
38 result);
39 }));
40 privatePreferences.dataReductionUpdateDailyLengths.get({},
41 chrome.test.callbackPass(function(result) {
42 chrome.test.assertEq(
44 'value': false
46 result);
47 }));
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});
60 // Helper methods.
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) {
68 chrome.test.assertEq(
70 'value': expectedDailyLengths ,
71 'levelOfControl': 'controllable_by_this_extension'
73 result);
74 }));
75 privatePreferences.dataReductionUpdateDailyLengths.get({},
76 chrome.test.callbackPass(function(result) {
77 chrome.test.assertEq(
79 'value': false
81 result);
82 }));
84 function confirmDailyContentLength() {
85 dataReductionProxy.dataReductionDailyContentLength.get({},
86 chrome.test.callbackPass(function(result) {
87 chrome.test.assertEq(
89 'value': expectedDailyLengths ,
90 'levelOfControl': 'controllable_by_this_extension'
92 result);
93 dataReductionProxy.dataReductionDailyContentLength.onChange.
94 removeListener(confirmDailyContentLength);
95 }));
96 privatePreferences.dataReductionUpdateDailyLengths.get({},
97 chrome.test.callbackPass(function(result) {
98 chrome.test.assertEq(
100 'value': false
102 result);
103 dataReductionProxy.dataReductionDailyReceivedLength.onChange.
104 removeListener(confirmRecievedLength);
105 }));
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(
117 'value': [],
118 'levelOfControl': 'controllable_by_this_extension'
120 result);
121 }));
122 dataReductionProxy.dataReductionDailyReceivedLength.get({},
123 chrome.test.callbackPass(function(result) {
124 chrome.test.assertEq(
126 'value': [],
127 'levelOfControl': 'controllable_by_this_extension'
129 result);
130 }));