Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / content_settings_exception_area_browsertest.js
blobf9fc3dfeca3b0271e49de244f2fb75f5a79e5b0d
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.
5 /**
6 * TestFixture for content settings exception area WebUI testing.
7 * @extends {testing.Test}
8 * @constructor
9 */
10 function ContentSettingsExceptionAreaWebUITest() {}
12 ContentSettingsExceptionAreaWebUITest.prototype = {
13 __proto__: testing.Test.prototype,
15 /** @override */
16 browsePreload: 'chrome://settings-frame/contentExceptions',
19 GEN('#if defined(OS_CHROMEOS)');
20 GEN('#define MAYBE_testOpenContentSettingsExceptionArea ' +
21 'DISABLED_testOpenContentSettingsExceptionArea');
22 GEN('#else');
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);
30 });
32 /**
33 * A class to asynchronously test the content settings exception area dialog.
34 * @extends {testing.Test}
35 * @constructor
37 function ContentSettingsExceptionsAreaAsyncWebUITest() {}
39 ContentSettingsExceptionsAreaAsyncWebUITest.prototype = {
40 __proto__: testing.Test.prototype,
42 /** @override */
43 browsePreload: 'chrome://settings-frame/contentExceptions',
45 /** @override */
46 isAsync: true,
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;
74 testDone();
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');
87 });