OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Content settings API test | 5 // Content settings API test |
6 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettings | 6 // Run with browser_tests --gtest_filter=ExtensionApiTest.ContentSettings |
7 | 7 |
8 var cs = chrome.contentSettings; | 8 var cs = chrome.contentSettings; |
9 | 9 |
10 // The following type-value pairs indicate that the value should be supported | 10 // The following type-value pairs indicate that the value should be supported |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 function expectFalse(message) { | 31 function expectFalse(message) { |
32 return expect({ | 32 return expect({ |
33 "value": false, | 33 "value": false, |
34 "levelOfControl": "controllable_by_this_extension" | 34 "levelOfControl": "controllable_by_this_extension" |
35 }, message); | 35 }, message); |
36 } | 36 } |
37 | 37 |
38 chrome.test.runTests([ | 38 chrome.test.runTests([ |
39 function setDefaultContentSettings() { | 39 function setDefaultContentSettingsAllUrls() { |
40 settings.forEach(function(type, setting) { | 40 settings.forEach(function(type, setting) { |
41 cs[type].set({ | 41 cs[type].set({ |
42 'primaryPattern': '<all_urls>', | 42 'primaryPattern': '<all_urls>', |
43 'secondaryPattern': '<all_urls>', | 43 'secondaryPattern': '<all_urls>', |
44 'setting': setting | 44 'setting': setting |
45 }, | 45 }, |
46 chrome.test.callbackFail("'" + setting + | 46 chrome.test.callbackFail("'" + setting + |
47 "' is not supported as the default setting of " + type + ".")); | 47 "' is not supported as the default setting of " + type + ".")); |
48 }); | 48 }); |
49 }, | 49 }, |
| 50 |
| 51 // Patterns with scheme wildcards and extension IDs should not be added. |
| 52 function setDefaultContentSettingsExtensionUrlWildcard() { |
| 53 settings.forEach(function(type, setting) { |
| 54 cs[type].set({ |
| 55 'primaryPattern': '*://' + chrome.runtime.id + '/*', |
| 56 'secondaryPattern': '*://' + chrome.runtime.id + '/*', |
| 57 'setting': setting |
| 58 }, |
| 59 chrome.test.callbackFail("'" + setting + |
| 60 "' is not supported as the default setting of " + type + ".")); |
| 61 }); |
| 62 }, |
| 63 |
| 64 // Patterns with chrome-extension scheme and extension IDs should not be |
| 65 // added. |
| 66 function setDefaultContentSettingsExtensionUrlWildcard() { |
| 67 settings.forEach(function(type, setting) { |
| 68 cs[type].set({ |
| 69 'primaryPattern': 'chrome-extension://' + chrome.runtime.id + '/*', |
| 70 'secondaryPattern': 'chrome-extension://' + chrome.runtime.id + '/*', |
| 71 'setting': setting |
| 72 }, |
| 73 chrome.test.callbackFail("Invalid scheme.")); |
| 74 }); |
| 75 }, |
| 76 |
50 function setExceptions() { | 77 function setExceptions() { |
51 settings.forEach(function(type, setting) { | 78 settings.forEach(function(type, setting) { |
52 cs[type].set({ | 79 cs[type].set({ |
53 'primaryPattern': 'http://*.google.com/*', | 80 'primaryPattern': 'http://*.google.com/*', |
54 'secondaryPattern': 'http://*.google.com/*', | 81 'secondaryPattern': 'http://*.google.com/*', |
55 'setting': setting | 82 'setting': setting |
56 }, chrome.test.callbackPass()); | 83 }, chrome.test.callbackPass()); |
57 }); | 84 }); |
58 } | 85 } |
59 ]); | 86 ]); |
OLD | NEW |