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.
6 * TestFixture for content settings exception area WebUI testing.
7 * @extends {testing.Test}
10 function ContentSettingsExceptionAreaWebUITest() {}
12 ContentSettingsExceptionAreaWebUITest.prototype = {
13 __proto__: testing.Test.prototype,
16 browsePreload: 'chrome://settings-frame/contentExceptions',
19 GEN('#if defined(OS_CHROMEOS)');
20 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' +
21 'DISABLED_testOpenContentSettingsExceptionArea');
23 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' +
24 'testOpenContentSettingsExceptionArea');
25 GEN('#endif // defined(OS_CHROMEOS)');
26 // Test opening the content settings exception area has correct location.
27 TEST_F('ContentSettingsExceptionAreaWebUITest',
28 'MAYBE_testOpenContentSettingsExceptionArea', function() {
29 assertEquals(this.browsePreload, document.location.href);
33 * A class to asynchronously test the content settings exception area dialog.
34 * @extends {testing.Test}
37 function ContentSettingsExceptionsAreaAsyncWebUITest() {}
39 ContentSettingsExceptionsAreaAsyncWebUITest.prototype = {
40 __proto__: testing.Test.prototype,
43 browsePreload: 'chrome://settings-frame/contentExceptions',
49 // Adds and removes a location content setting exception.
50 TEST_F('ContentSettingsExceptionsAreaAsyncWebUITest',
51 'testAddRemoveLocationExceptions', function() {
52 assertEquals(this.browsePreload, document.location.href);
54 /** @const */ var origin = 'http://google.com:80';
55 /** @const */ var setExceptions = ContentSettings.setExceptions;
57 var list = ContentSettings.getExceptionsList('cookies', 'normal');
58 assertEquals(1, list.items.length);
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);
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;
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();
85 // Add an item to the location exception area to start the test.
86 list.items[0].finishEdit(origin, 'block');