Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/ui/webui/options/options_browsertest.js

Issue 11232059: Clean up copy&paste in confirmation dialogs for prefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit addressed. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options/spelling_confirm_overlay.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * TestFixture for OptionsPage WebUI testing. 6 * TestFixture for OptionsPage WebUI testing.
7 * @extends {testing.Test} 7 * @extends {testing.Test}
8 * @constructor 8 * @constructor
9 */ 9 */
10 function OptionsWebUITest() {} 10 function OptionsWebUITest() {}
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 defaultZoomFactor.selectedIndex = defaultZoomFactor.options.length - 1; 107 defaultZoomFactor.selectedIndex = defaultZoomFactor.options.length - 1;
108 var event = { target: defaultZoomFactor }; 108 var event = { target: defaultZoomFactor };
109 if (defaultZoomFactor.onchange) defaultZoomFactor.onchange(event); 109 if (defaultZoomFactor.onchange) defaultZoomFactor.onchange(event);
110 testDone(); 110 testDone();
111 }); 111 });
112 112
113 // If |confirmInterstitial| is true, the OK button of the Do Not Track 113 // If |confirmInterstitial| is true, the OK button of the Do Not Track
114 // interstitial is pressed, otherwise the abort button is pressed. 114 // interstitial is pressed, otherwise the abort button is pressed.
115 OptionsWebUITest.prototype.testDoNotTrackInterstitial = 115 OptionsWebUITest.prototype.testDoNotTrackInterstitial =
116 function(confirmInterstitial) { 116 function(confirmInterstitial) {
117 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false } });
117 var buttonToClick = confirmInterstitial ? $('do-not-track-confirm-ok') 118 var buttonToClick = confirmInterstitial ? $('do-not-track-confirm-ok')
118 : $('do-not-track-confirm-cancel'); 119 : $('do-not-track-confirm-cancel');
119 var dntCheckbox = $('do-not-track-enabled'); 120 var dntCheckbox = $('do-not-track-enabled');
120 var dntOverlay = DoNotTrackConfirmOverlay.getInstance(); 121 var dntOverlay = OptionsPage.registeredOverlayPages['donottrackconfirm'];
121 assertFalse(dntCheckbox.checked); 122 assertFalse(dntCheckbox.checked);
122 123
123 var visibleChangeCounter = 0; 124 var visibleChangeCounter = 0;
124 var visibleChangeHandler = function() { 125 var visibleChangeHandler = function() {
125 ++visibleChangeCounter; 126 ++visibleChangeCounter;
126 switch (visibleChangeCounter) { 127 switch (visibleChangeCounter) {
127 case 1: 128 case 1:
128 window.setTimeout(function() { 129 window.setTimeout(function() {
129 assertTrue(dntOverlay.visible); 130 assertTrue(dntOverlay.visible);
130 buttonToClick.click(); 131 buttonToClick.click();
131 }, 0); 132 }, 0);
132 break; 133 break;
133 case 2: 134 case 2:
134 window.setTimeout(function() { 135 window.setTimeout(function() {
135 assertFalse(dntOverlay.visible); 136 assertFalse(dntOverlay.visible);
136 assertEquals(confirmInterstitial, dntCheckbox.checked); 137 assertEquals(confirmInterstitial, dntCheckbox.checked);
137 DoNotTrackConfirmOverlay.getInstance().removeEventListener( 138 dntOverlay.removeEventListener(visibleChangeHandler);
138 visibleChangeHandler);
139 testDone(); 139 testDone();
140 }, 0); 140 }, 0);
141 break; 141 break;
142 default: 142 default:
143 assertTrue(false); 143 assertTrue(false);
144 } 144 }
145 } 145 }
146 DoNotTrackConfirmOverlay.getInstance().addEventListener('visibleChange', 146 dntOverlay.addEventListener('visibleChange', visibleChangeHandler);
147 visibleChangeHandler);
148 147
149 if (confirmInterstitial) { 148 if (confirmInterstitial) {
150 this.mockHandler.expects(once()).setBooleanPref( 149 this.mockHandler.expects(once()).setBooleanPref(
151 ["enable_do_not_track", true]); 150 ['enable_do_not_track', true, 'Options_DoNotTrackCheckbox']);
152 } else { 151 } else {
153 // The mock handler complains if setBooleanPref is called even though 152 // The mock handler complains if setBooleanPref is called even though
154 // it should not be. 153 // it should not be.
155 } 154 }
156 155
157 dntCheckbox.click(); 156 dntCheckbox.click();
158 } 157 }
159 158
160 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndConfirmInterstitial', 159 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndConfirmInterstitial',
161 function() { 160 function() {
162 this.testDoNotTrackInterstitial(true); 161 this.testDoNotTrackInterstitial(true);
163 }); 162 });
164 163
165 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndCancelInterstitial', 164 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndCancelInterstitial',
166 function() { 165 function() {
167 this.testDoNotTrackInterstitial(false); 166 this.testDoNotTrackInterstitial(false);
168 }); 167 });
169 168
170 // Check that the "Do not Track" preference can be correctly disabled. 169 // Check that the "Do not Track" preference can be correctly disabled.
171 // In order to do that, we need to enable it first. 170 // In order to do that, we need to enable it first.
172 TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() { 171 TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() {
172 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false } });
173 var dntCheckbox = $('do-not-track-enabled'); 173 var dntCheckbox = $('do-not-track-enabled');
174 var dntOverlay = DoNotTrackConfirmOverlay.getInstance(); 174 var dntOverlay = OptionsPage.registeredOverlayPages['donottrackconfirm'];
175 assertFalse(dntCheckbox.checked); 175 assertFalse(dntCheckbox.checked);
176 176
177 var visibleChangeCounter = 0; 177 var visibleChangeCounter = 0;
178 var visibleChangeHandler = function() { 178 var visibleChangeHandler = function() {
179 ++visibleChangeCounter; 179 ++visibleChangeCounter;
180 switch (visibleChangeCounter) { 180 switch (visibleChangeCounter) {
181 case 1: 181 case 1:
182 window.setTimeout(function() { 182 window.setTimeout(function() {
183 assertTrue(dntOverlay.visible); 183 assertTrue(dntOverlay.visible);
184 $('do-not-track-confirm-ok').click(); 184 $('do-not-track-confirm-ok').click();
185 }, 0); 185 }, 0);
186 break; 186 break;
187 case 2: 187 case 2:
188 window.setTimeout(function() { 188 window.setTimeout(function() {
189 assertFalse(dntOverlay.visible); 189 assertFalse(dntOverlay.visible);
190 assertTrue(dntCheckbox.checked); 190 assertTrue(dntCheckbox.checked);
191 DoNotTrackConfirmOverlay.getInstance().removeEventListener( 191 dntOverlay.removeEventListener(visibleChangeHandler);
192 visibleChangeHandler);
193 dntCheckbox.click(); 192 dntCheckbox.click();
194 }, 0); 193 }, 0);
195 break; 194 break;
196 default: 195 default:
197 assertNotReached(); 196 assertNotReached();
198 } 197 }
199 } 198 }
200 DoNotTrackConfirmOverlay.getInstance().addEventListener('visibleChange', 199 dntOverlay.addEventListener('visibleChange', visibleChangeHandler);
201 visibleChangeHandler);
202 200
203 this.mockHandler.expects(once()).setBooleanPref( 201 this.mockHandler.expects(once()).setBooleanPref(
204 eq(["enable_do_not_track", true])); 202 eq(["enable_do_not_track", true, 'Options_DoNotTrackCheckbox']));
205 203
206 var verifyCorrectEndState = function() { 204 var verifyCorrectEndState = function() {
207 window.setTimeout(function() { 205 window.setTimeout(function() {
208 assertFalse(dntOverlay.visible); 206 assertFalse(dntOverlay.visible);
209 assertFalse(dntCheckbox.checked); 207 assertFalse(dntCheckbox.checked);
210 testDone(); 208 testDone();
211 }, 0) 209 }, 0)
212 } 210 }
213 this.mockHandler.expects(once()).setBooleanPref( 211 this.mockHandler.expects(once()).setBooleanPref(
214 eq(["enable_do_not_track", false, 'Options_DoNotTrackCheckbox'])).will( 212 eq(["enable_do_not_track", false, 'Options_DoNotTrackCheckbox'])).will(
215 callFunction(verifyCorrectEndState)); 213 callFunction(verifyCorrectEndState));
216 214
217 dntCheckbox.click(); 215 dntCheckbox.click();
218 }); 216 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/spelling_confirm_overlay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698