Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: chrome/test/data/extensions/activity_log/options.js

Issue 13726026: Added ActivityLog tests and associated bugfixes/extra logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wrapped line Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 setCompleted('makeSpecialApiCalls'); 61 setCompleted('makeSpecialApiCalls');
62 } 62 }
63 63
64 // Checks that we don't double-log calls that go through setHandleRequest 64 // Checks that we don't double-log calls that go through setHandleRequest
65 // *and* the ExtensionFunction machinery. 65 // *and* the ExtensionFunction machinery.
66 function checkNoDoubleLogging() { 66 function checkNoDoubleLogging() {
67 chrome.omnibox.setDefaultSuggestion({description: 'hello world'}); 67 chrome.omnibox.setDefaultSuggestion({description: 'hello world'});
68 setCompleted('checkNoDoubleLogging'); 68 setCompleted('checkNoDoubleLogging');
69 } 69 }
70 70
71 // Check whether we log calls to chrome.app.*;
72 function checkAppCalls() {
73 chrome.app.getDetails();
74 setCompleted('chrome.app.getDetails()');
75 var b = chrome.app.isInstalled;
76 setCompleted('chrome.app.isInstalled');
77 var c = chrome.app.installState();
78 setCompleted('chrome.app.installState()');
79 }
80
71 // Makes an API call that the extension doesn't have permission for. 81 // Makes an API call that the extension doesn't have permission for.
82 // Don't add the management permission or this test won't test the code path.
72 function makeBlockedApiCall() { 83 function makeBlockedApiCall() {
73 try { 84 try {
74 var all_extensions = chrome.management.getAll(); 85 var all_extensions = chrome.management.getAll();
75 } catch(err) { } 86 } catch(err) { }
76 setCompleted('makeBlockedApiCall'); 87 setCompleted('makeBlockedApiCall');
77 } 88 }
78 89
79 // Injects a content script. 90 // Injects a content script.
80 function injectContentScript() { 91 function injectContentScript() {
81 chrome.tabs.onUpdated.addListener( 92 chrome.tabs.onUpdated.addListener(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 chrome.webRequest.onBeforeSendHeaders.removeListener(doModifyHeaders); 178 chrome.webRequest.onBeforeSendHeaders.removeListener(doModifyHeaders);
168 chrome.tabs.onUpdated.removeListener(closeTab); 179 chrome.tabs.onUpdated.removeListener(closeTab);
169 chrome.tabs.remove(tabId); 180 chrome.tabs.remove(tabId);
170 setCompleted('doWebRequestModifications'); 181 setCompleted('doWebRequestModifications');
171 } 182 }
172 } 183 }
173 ); 184 );
174 window.open('http://www.google.co.uk'); 185 window.open('http://www.google.co.uk');
175 } 186 }
176 187
188 function getSetObjectProperties() {
189 chrome.tabs.onUpdated.addListener(
190 function getTabProperties(tabId, changeInfo, tab) {
191 if (changeInfo['status'] === "complete"
192 && tab.url.match(/google\.dk/g)) {
193 console.log(tab.id + " " + tab.index + " " + tab.url);
194 tab.index = 3333333333333333333;
195 chrome.tabs.remove(tabId);
196 chrome.tabs.onUpdated.removeListener(getTabProperties);
197 setCompleted('getSetObjectProperties');
198 }
199 }
200 );
201 window.open('http://www.google.dk');
202 }
203
204 function callObjectMethod() {
205 var storageArea = chrome.storage.sync;
206 storageArea.clear();
207 setCompleted('callObjectMethod()');
208 }
209
210 function sendMessageToCS() {
211 chrome.tabs.onUpdated.addListener(
212 function messageCS(tabId, changeInfo, tab) {
213 if (changeInfo['status'] === "complete"
214 && tab.url.match(/google\.com\.bo/g)) {
215 chrome.tabs.sendMessage(tabId, "hellooooo!");
216 chrome.tabs.remove(tabId);
217 chrome.tabs.onUpdated.removeListener(messageCS);
218 setCompleted('sendMessageToCS');
219 }
220 }
221 );
222 window.open('http://www.google.com.bo');
223 }
224
225 function sendMessageToSelf() {
226 chrome.runtime.sendMessage("hello hello");
227 setCompleted('sendMessageToSelf');
228 }
229
230 function sendMessageToOther() {
231 chrome.runtime.sendMessage("ocacnieaapoflmkebkeaidpgfngocapl",
232 "knock knock",
233 function response() {
234 console.log("who's there?");
235 });
236 setCompleted('sendMessageToOther');
237 }
238
239 function connectToOther() {
240 chrome.runtime.connect("ocacnieaapoflmkebkeaidpgfngocapl");
241 setCompleted('connectToOther');
242 }
243
177 // REGISTER YOUR TESTS HERE 244 // REGISTER YOUR TESTS HERE
178 // Attach the tests to buttons. 245 // Attach the tests to buttons.
179 function setupEvents() { 246 function setupEvents() {
180 $('api_call').addEventListener('click', makeApiCall); 247 $('api_call').addEventListener('click', makeApiCall);
181 $('special_call').addEventListener('click', makeSpecialApiCalls); 248 $('special_call').addEventListener('click', makeSpecialApiCalls);
182 $('blocked_call').addEventListener('click', makeBlockedApiCall); 249 $('blocked_call').addEventListener('click', makeBlockedApiCall);
183 $('inject_cs').addEventListener('click', injectContentScript); 250 $('inject_cs').addEventListener('click', injectContentScript);
184 $('inject_blob').addEventListener('click', injectScriptBlob); 251 $('inject_blob').addEventListener('click', injectScriptBlob);
185 $('background_xhr').addEventListener('click', doBackgroundXHR); 252 $('background_xhr').addEventListener('click', doBackgroundXHR);
186 $('cs_xhr').addEventListener('click', doContentScriptXHR); 253 $('cs_xhr').addEventListener('click', doContentScriptXHR);
187 $('webrequest').addEventListener('click', doWebRequestModifications); 254 $('webrequest').addEventListener('click', doWebRequestModifications);
188 $('double').addEventListener('click', checkNoDoubleLogging); 255 $('double').addEventListener('click', checkNoDoubleLogging);
256 $('app_bindings').addEventListener('click', checkAppCalls);
257 $('object_properties').addEventListener('click', getSetObjectProperties);
258 $('object_methods').addEventListener('click', callObjectMethod);
259 $('message_cs').addEventListener('click', sendMessageToCS);
260 $('message_self').addEventListener('click', sendMessageToSelf);
261 $('message_other').addEventListener('click', sendMessageToOther);
262 $('connect_other').addEventListener('click', connectToOther);
189 263
190 completed = 0; 264 completed = 0;
191 total = document.getElementsByTagName('button').length; 265 total = document.getElementsByTagName('button').length;
192 } 266 }
193 267
194 document.addEventListener('DOMContentLoaded', setupEvents); 268 document.addEventListener('DOMContentLoaded', setupEvents);
195 269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698