Chromium Code Reviews| Index: chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js |
| diff --git a/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js b/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js |
| index 93da9c6aa9b6ca3f653266007603aa855b2e4245..d52e3ffd538dd6c548ec323a910a169e61db65c4 100644 |
| --- a/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js |
| +++ b/chrome/browser/ui/webui/options/content_settings_exception_area_browsertest.js |
| @@ -12,9 +12,7 @@ function ContentSettingsExceptionAreaWebUITest() {} |
| ContentSettingsExceptionAreaWebUITest.prototype = { |
| __proto__: testing.Test.prototype, |
| - /** |
| - * Browse to the content settings exception area. |
| - */ |
| + /** @override */ |
| browsePreload: 'chrome://settings-frame/contentExceptions', |
| }; |
| @@ -27,7 +25,61 @@ GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' + |
| GEN('#endif // defined(OS_CHROMEOS)'); |
| // Test opening the content settings exception area has correct location. |
| TEST_F('ContentSettingsExceptionAreaWebUITest', |
| - 'MAYBE_testOpenContentSettingsExceptionArea', |
| - function() { |
| - assertEquals(this.browsePreload, document.location.href); |
| - }); |
| + 'MAYBE_testOpenContentSettingsExceptionArea', function() { |
| + assertEquals(this.browsePreload, document.location.href); |
| +}); |
| + |
| +/** |
| + * A class to asynchronously test the content settings exception area dialog. |
| + * @extends {testing.Test} |
| + * @constructor |
| + */ |
| +function ContentSettingsExceptionsAreaAsyncWebUITest() {} |
| + |
| +ContentSettingsExceptionsAreaAsyncWebUITest.prototype = { |
| + __proto__: testing.Test.prototype, |
| + |
| + /** @override */ |
| + browsePreload: 'chrome://settings-frame/contentExceptions', |
| + |
| + /** @override */ |
| + isAsync: true, |
| +}; |
| + |
| +// Adds and removes a location content setting exception. |
| +TEST_F('ContentSettingsExceptionsAreaAsyncWebUITest', |
| + 'testAddRemoveLocationExceptions', function() { |
| + assertEquals(this.browsePreload, document.location.href); |
| + |
| + /** @const */ var origin = 'http://google.com:80'; |
| + |
| + var list = ContentSettings.getExceptionsList('cookies', 'normal'); |
| + assertEquals(1, list.items.length); |
| + |
| + var setExceptionsCallback = function() { |
| + // The first item is now the exception (edit items are always last). |
| + expectEquals('block', list.dataModel.item(0).setting); |
| + expectEquals(origin, list.dataModel.item(0).origin); |
| + |
| + 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.
|
| + expectEquals(1, list.items.length); |
| + 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
|
| + testDone(); |
| + }; |
| + |
| + // Delete the item and verify it worked. |
| + list.deleteItemAtIndex(0); |
| + }; |
| + |
| + // NOTE: if this test doesn't succeed, |ContentSettings.setExceptions| may not |
| + // be restored to its original method. I know no easy way to fix this. |
| + var origSetExceptions = ContentSettings.setExceptions; |
| + ContentSettings.setExceptions = function() { |
| + origSetExceptions.apply(ContentSettings, arguments); |
| + setExceptionsCallback(); |
| + }; |
| + |
| + // Add an item to the location exception area to start the test. |
| + //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.
|
| + list.items[0].finishEdit(origin, 'block'); |
| +}); |
|
Dan Beam
2014/05/01 23:43:33
^ the test that took me 2 tries and 12h to write :
|