OLD | NEW |
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 /** @const */ var setExceptions = ContentSettings.setExceptions; |
| 56 |
| 57 var list = ContentSettings.getExceptionsList('cookies', 'normal'); |
| 58 assertEquals(1, list.items.length); |
| 59 |
| 60 var setExceptionsCounter = 0; |
| 61 var setExceptionsCallback = function() { |
| 62 setExceptionsCounter++; |
| 63 if (setExceptionsCounter == 1) { |
| 64 // The first item is now the exception (edit items are always last). |
| 65 expectEquals('block', list.dataModel.item(0).setting); |
| 66 expectEquals(origin, list.dataModel.item(0).origin); |
| 67 |
| 68 // Delete the item and verify it worked. |
| 69 list.deleteItemAtIndex(0); |
| 70 } else if (setExceptionsCounter == 2) { |
| 71 // Verify the item was deleted, restore the original method, and finish. |
| 72 expectEquals(1, list.items.length); |
| 73 ContentSettings.setExceptions = setExceptions; |
| 74 testDone(); |
| 75 } |
| 76 }; |
| 77 |
| 78 // NOTE: if this test doesn't succeed, |ContentSettings.setExceptions| may not |
| 79 // be restored to its original method. I know no easy way to fix this. |
| 80 ContentSettings.setExceptions = function() { |
| 81 setExceptions.apply(ContentSettings, arguments); |
| 82 setExceptionsCallback(); |
| 83 }; |
| 84 |
| 85 // Add an item to the location exception area to start the test. |
| 86 list.items[0].finishEdit(origin, 'block'); |
| 87 }); |
OLD | NEW |