OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 GEN_INCLUDE(['options_browsertest_base.js']); | |
6 | |
7 /** | |
8 * TestFixture for content settings exception area WebUI testing. | |
9 * @extends {testing.Test} | |
10 * @constructor | |
11 */ | |
12 function ContentSettingsExceptionAreaWebUITest() {} | |
13 | |
14 ContentSettingsExceptionAreaWebUITest.prototype = { | |
15 __proto__: testing.Test.prototype, | |
16 | |
17 /** @override */ | |
18 browsePreload: 'chrome://settings-frame/contentExceptions', | |
19 }; | |
20 | |
21 // See crbug.com/579666 for OS_LINUX and crbug.com/588586 for Windows and | |
22 // crbug.com/718947 for Mac. | |
23 GEN('#if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_WIN) || ' + | |
24 'defined(OS_MACOSX)'); | |
25 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + | |
26 'DISABLED_testOpenContentSettingsExceptionArea'); | |
27 GEN('#else'); | |
28 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + | |
29 'testOpenContentSettingsExceptionArea'); | |
30 GEN('#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)'); | |
31 // Test opening the content settings exception area has correct location. | |
32 TEST_F('ContentSettingsExceptionAreaWebUITest', | |
33 'MAYBE_testOpenContentSettingsExceptionArea', function() { | |
34 assertEquals(this.browsePreload, document.location.href); | |
35 }); | |
36 | |
37 /** | |
38 * A class to asynchronously test the content settings exception area dialog. | |
39 * @extends {testing.Test} | |
40 * @constructor | |
41 */ | |
42 function ContentSettingsExceptionsAreaAsyncWebUITest() {} | |
43 | |
44 ContentSettingsExceptionsAreaAsyncWebUITest.prototype = { | |
45 __proto__: OptionsBrowsertestBase.prototype, | |
46 | |
47 /** @override */ | |
48 browsePreload: 'chrome://settings-frame/contentExceptions', | |
49 | |
50 /** @override */ | |
51 isAsync: true, | |
52 | |
53 /** @override */ | |
54 setUp: function() { | |
55 OptionsBrowsertestBase.prototype.setUp.call(this); | |
56 | |
57 // Enable when failure is resolved. | |
58 // AX_TEXT_01: http://crbug.com/570562 | |
59 this.accessibilityAuditConfig.ignoreSelectors( | |
60 'controlsWithoutLabel', | |
61 '#content-settings-exceptions-area > .content-area > *'); | |
62 | |
63 // Enable when failure is resolved. | |
64 // AX_TEXT_04: http://crbug.com/570563 | |
65 this.accessibilityAuditConfig.ignoreSelectors( | |
66 'linkWithUnclearPurpose', | |
67 '#content-settings-exceptions-area > .action-area > *'); | |
68 }, | |
69 }; | |
70 | |
71 // Adds and removes a location content setting exception. | |
72 TEST_F('ContentSettingsExceptionsAreaAsyncWebUITest', | |
73 'testAddRemoveLocationExceptions', function() { | |
74 assertEquals(this.browsePreload, document.location.href); | |
75 | |
76 /** @const */ var origin = 'http://google.com:80'; | |
77 /** @const */ var setExceptions = ContentSettings.setExceptions; | |
78 | |
79 var list = ContentSettings.getExceptionsList('cookies', 'normal'); | |
80 assertEquals(1, list.items.length); | |
81 | |
82 var setExceptionsCounter = 0; | |
83 var setExceptionsCallback = function() { | |
84 setExceptionsCounter++; | |
85 if (setExceptionsCounter == 1) { | |
86 // The first item is now the exception (edit items are always last). | |
87 expectEquals('block', list.dataModel.item(0).setting); | |
88 expectEquals(origin, list.dataModel.item(0).origin); | |
89 | |
90 // Delete the item and verify it worked. | |
91 list.deleteItemAtIndex(0); | |
92 } else if (setExceptionsCounter == 2) { | |
93 // Verify the item was deleted, restore the original method, and finish. | |
94 expectEquals(1, list.items.length); | |
95 ContentSettings.setExceptions = setExceptions; | |
96 testDone(); | |
97 } | |
98 }; | |
99 | |
100 // NOTE: if this test doesn't succeed, |ContentSettings.setExceptions| may not | |
101 // be restored to its original method. I know no easy way to fix this. | |
102 ContentSettings.setExceptions = function() { | |
103 setExceptions.apply(ContentSettings, arguments); | |
104 setExceptionsCallback(); | |
105 }; | |
106 | |
107 // Add an item to the location exception area to start the test. | |
108 list.items[0].finishEdit(origin, 'block'); | |
109 }); | |
OLD | NEW |