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

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

Issue 264713008: options: fix content settings exceptions dialog regression. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months 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
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 content settings exception area WebUI testing. 6 * TestFixture for content settings exception area WebUI testing.
7 * @extends {testing.Test} 7 * @extends {testing.Test}
8 * @constructor 8 * @constructor
9 */ 9 */
10 function ContentSettingsExceptionAreaWebUITest() {} 10 function ContentSettingsExceptionAreaWebUITest() {}
11 11
12 ContentSettingsExceptionAreaWebUITest.prototype = { 12 ContentSettingsExceptionAreaWebUITest.prototype = {
13 __proto__: testing.Test.prototype, 13 __proto__: testing.Test.prototype,
14 14
15 /** 15 /** @override */
16 * Browse to the content settings exception area.
17 */
18 browsePreload: 'chrome://settings-frame/contentExceptions', 16 browsePreload: 'chrome://settings-frame/contentExceptions',
19 }; 17 };
20 18
21 GEN('#if defined(OS_CHROMEOS)'); 19 GEN('#if defined(OS_CHROMEOS)');
22 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + 20 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' +
23 'DISABLED_testOpenContentSettingsExceptionArea'); 21 'DISABLED_testOpenContentSettingsExceptionArea');
24 GEN('#else'); 22 GEN('#else');
25 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + 23 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' +
26 'testOpenContentSettingsExceptionArea'); 24 'testOpenContentSettingsExceptionArea');
27 GEN('#endif // defined(OS_CHROMEOS)'); 25 GEN('#endif // defined(OS_CHROMEOS)');
28 // Test opening the content settings exception area has correct location. 26 // Test opening the content settings exception area has correct location.
29 TEST_F('ContentSettingsExceptionAreaWebUITest', 27 TEST_F('ContentSettingsExceptionAreaWebUITest',
30 'MAYBE_testOpenContentSettingsExceptionArea', 28 'MAYBE_testOpenContentSettingsExceptionArea', function() {
31 function() { 29 assertEquals(this.browsePreload, document.location.href);
32 assertEquals(this.browsePreload, document.location.href); 30 });
33 }); 31
32 /**
33 * A class to asynchronously test the content settings exception area dialog.
34 * @extends {testing.Test}
35 * @constructor
36 */
37 function ContentSettingsExceptionsAreaAsyncWebUITest() {}
38
39 ContentSettingsExceptionsAreaAsyncWebUITest.prototype = {
40 __proto__: testing.Test.prototype,
41
42 /** @override */
43 browsePreload: 'chrome://settings-frame/contentExceptions',
44
45 /** @override */
46 isAsync: true,
47 };
48
49 // Adds and removes a location content setting exception.
50 TEST_F('ContentSettingsExceptionsAreaAsyncWebUITest',
51 'testAddRemoveLocationExceptions', function() {
52 assertEquals(this.browsePreload, document.location.href);
53
54 /** @const */ var origin = 'http://google.com:80';
55
56 var list = ContentSettings.getExceptionsList('cookies', 'normal');
57 assertEquals(1, list.items.length);
58
59 var setExceptionsCallback = function() {
60 // The first item is now the exception (edit items are always last).
61 expectEquals('block', list.dataModel.item(0).setting);
62 expectEquals(origin, list.dataModel.item(0).origin);
63
64 setExceptionsCallback = function() {
Evan Stade 2014/05/02 01:18:33 most confusing pattern ever. I think it would be e
Dan Beam 2014/05/02 18:28:05 Done.
65 expectEquals(1, list.items.length);
66 ContentSettings.setExceptions = origSetExceptions;
Evan Stade 2014/05/02 01:18:33 really surprising to me this works even though ori
Dan Beam 2014/05/02 18:28:05 it's defined when this is executed, which is all t
67 testDone();
68 };
69
70 // Delete the item and verify it worked.
71 list.deleteItemAtIndex(0);
72 };
73
74 // NOTE: if this test doesn't succeed, |ContentSettings.setExceptions| may not
75 // be restored to its original method. I know no easy way to fix this.
76 var origSetExceptions = ContentSettings.setExceptions;
77 ContentSettings.setExceptions = function() {
78 origSetExceptions.apply(ContentSettings, arguments);
79 setExceptionsCallback();
80 };
81
82 // Add an item to the location exception area to start the test.
83 //chrome.send('setException', ['cookies', 'normal', origin, origin]);
Evan Stade 2014/05/02 01:18:33 why is this line here?
Dan Beam 2014/05/02 18:28:05 Done.
84 list.items[0].finishEdit(origin, 'block');
85 });
Dan Beam 2014/05/01 23:43:33 ^ the test that took me 2 tries and 12h to write :
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698