Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / content_settings / standard / test.js
blobd2acd683bf10c15c94c7b8cecaeef426c3372e84
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",
11   "images": "allow",
12   "javascript": "block",
13   "plugins": "allow",
14   "popups": "block",
15   "location": "ask",
16   "notifications": "ask",
17   "fullscreen": "ask",
18   "mouselock": "ask",
19   "unsandboxedPlugins": "ask",
20   "automaticDownloads": "ask"
23 var settings = {
24   "cookies": "block",
25   "images": "allow",
26   "javascript": "block",
27   "plugins": "detect_important_content",
28   "popups": "allow",
29   "location": "block",
30   "notifications": "block",
31   "fullscreen": "allow",
32   "mouselock": "block",
33   "unsandboxedPlugins": "block",
34   "automaticDownloads": "block"
37 Object.prototype.forEach = function(f) {
38   var k;
39   for (k in this) {
40     if (this.hasOwnProperty(k))
41       f(k, this[k]);
42   }
45 function expect(expected, message) {
46   return chrome.test.callbackPass(function(value) {
47     chrome.test.assertEq(expected, value, message);
48   });
51 function expectFalse(message) {
52   return expect({
53     "value": false,
54     "levelOfControl": "controllable_by_this_extension"
55   }, message);
58 chrome.test.runTests([
59   function setDefaultContentSettings() {
60     default_content_settings.forEach(function(type, setting) {
61       cs[type].set({
62         'primaryPattern': '<all_urls>',
63         'secondaryPattern': '<all_urls>',
64         'setting': setting
65       }, chrome.test.callbackPass());
66     });
67   },
68   function setContentSettings() {
69     settings.forEach(function(type, setting) {
70       cs[type].set({
71         'primaryPattern': 'http://*.google.com/*',
72         'secondaryPattern': 'http://*.google.com/*',
73         'setting': setting
74       }, chrome.test.callbackPass());
75     });
76   },
77   function getContentSettings() {
78     settings.forEach(function(type, setting) {
79       var message = "Setting for " + type + " should be " + setting;
80       cs[type].get({
81         'primaryUrl': 'http://www.google.com',
82         'secondaryUrl': 'http://www.google.com'
83       }, expect({'setting':setting}, message));
84     });
85   },
86   function invalidSettings() {
87     cs.cookies.get({
88       'primaryUrl': 'moo'
89     }, chrome.test.callbackFail("The URL \"moo\" is invalid."));
90     cs.plugins.set({
91       'primaryPattern': 'http://example.com/*',
92       'secondaryPattern': 'http://example.com/path',
93       'setting': 'block'
94     }, chrome.test.callbackFail("Specific paths are not allowed."));
95     cs.javascript.set({
96       'primaryPattern': 'http://example.com/*',
97       'secondaryPattern': 'file:///home/hansmoleman/*',
98       'setting': 'allow'
99     }, chrome.test.callbackFail(
100         "Path wildcards in file URL patterns are not allowed."));
101   }