| 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 |
| 51 // Makes an API call that the extension doesn't have permission for. | 58 // Makes an API call that the extension doesn't have permission for. |
| 52 function makeBlockedApiCall() { | 59 function makeBlockedApiCall() { |
| 53 try { | 60 try { |
| 54 var all_extensions = chrome.management.getAll(); | 61 var all_extensions = chrome.management.getAll(); |
| 55 } catch(err) { } | 62 } catch(err) { } |
| 56 setCompleted('makeBlockedApiCall'); | 63 setCompleted('makeBlockedApiCall'); |
| 57 } | 64 } |
| 58 | 65 |
| 59 // Injects a content script. | 66 // Injects a content script. |
| 60 function injectContentScript() { | 67 function injectContentScript() { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 158 } |
| 152 } | 159 } |
| 153 ); | 160 ); |
| 154 window.open('http://www.google.co.uk'); | 161 window.open('http://www.google.co.uk'); |
| 155 } | 162 } |
| 156 | 163 |
| 157 // REGISTER YOUR TESTS HERE | 164 // REGISTER YOUR TESTS HERE |
| 158 // Attach the tests to buttons. | 165 // Attach the tests to buttons. |
| 159 function setupEvents() { | 166 function setupEvents() { |
| 160 $('api_call').addEventListener('click', makeApiCall); | 167 $('api_call').addEventListener('click', makeApiCall); |
| 168 $('special_call').addEventListener('click', makeSpecialApiCalls); |
| 161 $('blocked_call').addEventListener('click', makeBlockedApiCall); | 169 $('blocked_call').addEventListener('click', makeBlockedApiCall); |
| 162 $('inject_cs').addEventListener('click', injectContentScript); | 170 $('inject_cs').addEventListener('click', injectContentScript); |
| 163 $('inject_blob').addEventListener('click', injectScriptBlob); | 171 $('inject_blob').addEventListener('click', injectScriptBlob); |
| 164 $('background_xhr').addEventListener('click', doBackgroundXHR); | 172 $('background_xhr').addEventListener('click', doBackgroundXHR); |
| 165 $('cs_xhr').addEventListener('click', doContentScriptXHR); | 173 $('cs_xhr').addEventListener('click', doContentScriptXHR); |
| 166 $('webrequest').addEventListener('click', doWebRequestModifications); | 174 $('webrequest').addEventListener('click', doWebRequestModifications); |
| 167 | 175 |
| 168 completed = 0; | 176 completed = 0; |
| 169 total = document.getElementsByTagName('button').length; | 177 total = document.getElementsByTagName('button').length; |
| 170 } | 178 } |
| 171 | 179 |
| 172 document.addEventListener('DOMContentLoaded', setupEvents); | 180 document.addEventListener('DOMContentLoaded', setupEvents); |
| 173 | 181 |
| OLD | NEW |