1 // Copyright (c) 2011 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 // Content settings API test
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettings
8 var cs
= chrome
.contentSettings
;
9 var default_content_settings
= {
10 "cookies": "session_only",
12 "javascript": "block",
16 "notifications": "ask",
21 "unsandboxedPlugins": "ask",
22 "automaticDownloads": "ask"
28 "javascript": "block",
29 "plugins": "detect_important_content",
32 "notifications": "block",
33 "fullscreen": "allow",
35 "microphone": "block",
37 "unsandboxedPlugins": "block",
38 "automaticDownloads": "block"
41 Object
.prototype.forEach = function(f
) {
44 if (this.hasOwnProperty(k
))
49 function expect(expected
, message
) {
50 return chrome
.test
.callbackPass(function(value
) {
51 chrome
.test
.assertEq(expected
, value
, message
);
55 function expectFalse(message
) {
58 "levelOfControl": "controllable_by_this_extension"
62 chrome
.test
.runTests([
63 function setDefaultContentSettings() {
64 default_content_settings
.forEach(function(type
, setting
) {
66 'primaryPattern': '<all_urls>',
67 'secondaryPattern': '<all_urls>',
69 }, chrome
.test
.callbackPass());
72 function setContentSettings() {
73 settings
.forEach(function(type
, setting
) {
75 'primaryPattern': 'http://*.google.com/*',
76 'secondaryPattern': 'http://*.google.com/*',
78 }, chrome
.test
.callbackPass());
81 function getContentSettings() {
82 settings
.forEach(function(type
, setting
) {
83 var message
= "Setting for " + type
+ " should be " + setting
;
85 'primaryUrl': 'http://www.google.com',
86 'secondaryUrl': 'http://www.google.com'
87 }, expect({'setting':setting
}, message
));
90 function invalidSettings() {
93 }, chrome
.test
.callbackFail("The URL \"moo\" is invalid."));
95 'primaryPattern': 'http://example.com/*',
96 'secondaryPattern': 'http://example.com/path',
98 }, chrome
.test
.callbackFail("Specific paths are not allowed."));
100 'primaryPattern': 'http://example.com/*',
101 'secondaryPattern': 'file:///home/hansmoleman/*',
103 }, chrome
.test
.callbackFail(
104 "Path wildcards in file URL patterns are not allowed."));