OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 /** | 5 /** |
6 * Every test needs: | 6 * Every test needs: |
7 * - a button in options.html | 7 * - a button in options.html |
8 * - a function that runs the test & calls setCompleted when done | 8 * - a function that runs the test & calls setCompleted when done |
9 * - a listener registered in setupEvents | 9 * - a listener registered in setupEvents |
10 **/ | 10 **/ |
(...skipping 30 matching lines...) Expand all Loading... |
41 // Makes an API call. | 41 // Makes an API call. |
42 function makeApiCall() { | 42 function makeApiCall() { |
43 chrome.cookies.set({ | 43 chrome.cookies.set({ |
44 'url': 'https://www.cnn.com', | 44 'url': 'https://www.cnn.com', |
45 'name': 'activity_log_test_cookie', | 45 'name': 'activity_log_test_cookie', |
46 'value': 'abcdefg' | 46 'value': 'abcdefg' |
47 }); | 47 }); |
48 setCompleted('makeApiCall'); | 48 setCompleted('makeApiCall'); |
49 } | 49 } |
50 | 50 |
| 51 // Makes an API call that has a custom binding. |
| 52 function makeSpecialApiCalls() { |
| 53 var url = chrome.extension.getURL("image/cat.jpg"); |
| 54 var noparam = chrome.extension.getViews(); |
| 55 setCompleted('makeSpecialApiCalls'); |
| 56 } |
| 57 |
| 58 // Checks that we don't double-log calls that go through setHandleRequest |
| 59 // *and* the ExtensionFunction machinery. |
| 60 function checkNoDoubleLogging() { |
| 61 chrome.omnibox.setDefaultSuggestion({description: 'hello world'}); |
| 62 setCompleted('checkNoDoubleLogging'); |
| 63 } |
| 64 |
51 // Makes an API call that the extension doesn't have permission for. | 65 // Makes an API call that the extension doesn't have permission for. |
52 function makeBlockedApiCall() { | 66 function makeBlockedApiCall() { |
53 try { | 67 try { |
54 var all_extensions = chrome.management.getAll(); | 68 var all_extensions = chrome.management.getAll(); |
55 } catch(err) { } | 69 } catch(err) { } |
56 setCompleted('makeBlockedApiCall'); | 70 setCompleted('makeBlockedApiCall'); |
57 } | 71 } |
58 | 72 |
59 // Injects a content script. | 73 // Injects a content script. |
60 function injectContentScript() { | 74 function injectContentScript() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 165 } |
152 } | 166 } |
153 ); | 167 ); |
154 window.open('http://www.google.co.uk'); | 168 window.open('http://www.google.co.uk'); |
155 } | 169 } |
156 | 170 |
157 // REGISTER YOUR TESTS HERE | 171 // REGISTER YOUR TESTS HERE |
158 // Attach the tests to buttons. | 172 // Attach the tests to buttons. |
159 function setupEvents() { | 173 function setupEvents() { |
160 $('api_call').addEventListener('click', makeApiCall); | 174 $('api_call').addEventListener('click', makeApiCall); |
| 175 $('special_call').addEventListener('click', makeSpecialApiCalls); |
161 $('blocked_call').addEventListener('click', makeBlockedApiCall); | 176 $('blocked_call').addEventListener('click', makeBlockedApiCall); |
162 $('inject_cs').addEventListener('click', injectContentScript); | 177 $('inject_cs').addEventListener('click', injectContentScript); |
163 $('inject_blob').addEventListener('click', injectScriptBlob); | 178 $('inject_blob').addEventListener('click', injectScriptBlob); |
164 $('background_xhr').addEventListener('click', doBackgroundXHR); | 179 $('background_xhr').addEventListener('click', doBackgroundXHR); |
165 $('cs_xhr').addEventListener('click', doContentScriptXHR); | 180 $('cs_xhr').addEventListener('click', doContentScriptXHR); |
166 $('webrequest').addEventListener('click', doWebRequestModifications); | 181 $('webrequest').addEventListener('click', doWebRequestModifications); |
| 182 $('double').addEventListener('click', checkNoDoubleLogging); |
167 | 183 |
168 completed = 0; | 184 completed = 0; |
169 total = document.getElementsByTagName('button').length; | 185 total = document.getElementsByTagName('button').length; |
170 } | 186 } |
171 | 187 |
172 document.addEventListener('DOMContentLoaded', setupEvents); | 188 document.addEventListener('DOMContentLoaded', setupEvents); |
173 | 189 |
OLD | NEW |