OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Setup the test cases. | 5 // Setup the test cases. |
6 var testCases = []; | 6 var testCases = []; |
7 testCases.push({ | 7 testCases.push({ |
8 func: function triggerApiCall() { | 8 func: function triggerApiCall() { |
9 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', | 9 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', |
10 'api_call', function response() { }); | 10 'api_call', function response() { }); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 'tabs.onUpdated', | 197 'tabs.onUpdated', |
198 'tabs.onUpdated', | 198 'tabs.onUpdated', |
199 'tabs.connect', | 199 'tabs.connect', |
200 'tabs.sendMessage', | 200 'tabs.sendMessage', |
201 'tabs.executeScript', | 201 'tabs.executeScript', |
202 'tabs.executeScript', | 202 'tabs.executeScript', |
203 'HTMLDocument.write', | 203 'HTMLDocument.write', |
204 'tabs.remove' | 204 'tabs.remove' |
205 ] | 205 ] |
206 }); | 206 }); |
207 testCases.push({ | 207 |
208 func: function triggerDOMChangesOnTabsUpdated() { | 208 |
209 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', | 209 domExpectedActivity = [ |
210 'dom_tab_updated', function response() { }); | |
211 }, | |
212 expected_activity: [ | |
213 'tabs.onUpdated', | 210 'tabs.onUpdated', |
214 'tabs.onUpdated', | 211 'tabs.onUpdated', |
215 'tabs.executeScript', | 212 'tabs.executeScript', |
216 // Location access | 213 // Location access |
217 'Window.location', | 214 'Window.location', |
218 'Document.location', | 215 'Document.location', |
219 'Window.location', | 216 'Window.location', |
220 'Location.assign', | 217 'Location.assign', |
221 'Location.replace', | 218 'Location.replace', |
222 // Dom mutations | 219 // Dom mutations |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // Cache access | 253 // Cache access |
257 'Window.applicationCache', | 254 'Window.applicationCache', |
258 // Web database access | 255 // Web database access |
259 'Window.openDatabase', | 256 'Window.openDatabase', |
260 // Canvas access | 257 // Canvas access |
261 'Document.createElement', | 258 'Document.createElement', |
262 'HTMLCanvasElement.getContext', | 259 'HTMLCanvasElement.getContext', |
263 // XHR from content script. | 260 // XHR from content script. |
264 'XMLHttpRequest.open', | 261 'XMLHttpRequest.open', |
265 'XMLHttpRequest.setRequestHeader', | 262 'XMLHttpRequest.setRequestHeader', |
266 'HTMLDocument.write', | 263 'HTMLDocument.write' |
267 // Close the tab. | 264 ]; |
268 'tabs.remove' | 265 |
269 ] | 266 // add the hook activity |
270 }); | 267 hookNames = ['onclick', 'ondblclick', 'ondrag', 'ondragend', 'ondragenter', |
| 268 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'oninput', |
| 269 'onkeydown', 'onkeypress', 'onkeyup', 'onmousedown', |
| 270 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', |
| 271 'onmouseover', 'onmouseup', 'onmousewheel']; |
| 272 |
| 273 for (var i = 0; i < hookNames.length; i++) { |
| 274 domExpectedActivity.push('Element.' + hookNames[i]); |
| 275 domExpectedActivity.push('Document.' + hookNames[i]); |
| 276 domExpectedActivity.push('Window.' + hookNames[i]); |
| 277 } |
| 278 |
| 279 // Close the tab. |
| 280 domExpectedActivity.push('tabs.remove'); |
271 | 281 |
272 testCases.push({ | 282 testCases.push({ |
273 func: function triggerDOMChangesOnTabsUpdated() { | 283 func: function triggerDOMChangesOnTabsUpdated() { |
274 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', | 284 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', |
| 285 'dom_tab_updated', function response() { }); |
| 286 }, |
| 287 expected_activity: domExpectedActivity |
| 288 }); |
| 289 |
| 290 // copy the array for the next test so we can modify it |
| 291 var domExpectedActivityIncognito = domExpectedActivity.slice(0); |
| 292 |
| 293 // put windows.create at the front of the expected values for the next test |
| 294 domExpectedActivityIncognito.unshift('windows.create'); |
| 295 |
| 296 testCases.push({ |
| 297 func: function triggerDOMChangesOnTabsUpdated() { |
| 298 chrome.runtime.sendMessage('pknkgggnfecklokoggaggchhaebkajji', |
275 'dom_tab_updated_incognito', | 299 'dom_tab_updated_incognito', |
276 function response() { }); | 300 function response() { }); |
277 }, | 301 }, |
278 // TODO(mvrable): set this back to true to test the URL values when incognito | 302 // TODO(mvrable): set this back to true to test the URL values when incognito |
279 // cleaning is working correctly for DOM logging (crbug.com/253368). | 303 // cleaning is working correctly for DOM logging (crbug.com/253368). |
280 is_incognito: false, | 304 is_incognito: false, |
281 expected_activity: [ | 305 expected_activity: domExpectedActivityIncognito |
282 'windows.create', | |
283 'tabs.onUpdated', | |
284 'tabs.onUpdated', | |
285 'tabs.executeScript', | |
286 // Location access | |
287 'Window.location', | |
288 'Document.location', | |
289 'Window.location', | |
290 'Location.assign', | |
291 'Location.replace', | |
292 // Dom mutations | |
293 'Document.createElement', | |
294 'Document.createElement', | |
295 'Document.location', | |
296 'Node.appendChild', | |
297 'Document.location', | |
298 'Document.location', | |
299 'Node.insertBefore', | |
300 'Document.location', | |
301 'Document.location', | |
302 'Node.replaceChild', | |
303 //'Document.location', | |
304 'HTMLDocument.write', | |
305 'HTMLDocument.writeln', | |
306 'HTMLElement.innerHTML', | |
307 // Navigator access | |
308 'Window.navigator', | |
309 'Geolocation.getCurrentPosition', | |
310 'Geolocation.watchPosition', | |
311 // Web store access - session storage | |
312 'Window.sessionStorage', | |
313 'Storage.setItem', | |
314 'Storage.getItem', | |
315 'Storage.removeItem', | |
316 'Storage.clear', | |
317 // Web store access - local storage | |
318 'Window.localStorage', | |
319 'Storage.setItem', | |
320 'Storage.getItem', | |
321 'Storage.removeItem', | |
322 'Storage.clear', | |
323 // Notification access | |
324 'Window.webkitNotifications', | |
325 'NotificationCenter.createNotification', | |
326 // Cache access | |
327 'Window.applicationCache', | |
328 // Web database access | |
329 'Window.openDatabase', | |
330 // Canvas access | |
331 'Document.createElement', | |
332 'HTMLCanvasElement.getContext', | |
333 // XHR from content script. | |
334 'XMLHttpRequest.open', | |
335 'XMLHttpRequest.setRequestHeader', | |
336 'HTMLDocument.write', | |
337 // Close the tab. | |
338 'tabs.remove' | |
339 ] | |
340 }); | 306 }); |
341 | 307 |
342 // Listener to check the expected logging is done in the test cases. | 308 // Listener to check the expected logging is done in the test cases. |
343 var testCaseIndx = 0; | 309 var testCaseIndx = 0; |
344 var callIndx = -1; | 310 var callIndx = -1; |
345 chrome.activityLogPrivate.onExtensionActivity.addListener( | 311 chrome.activityLogPrivate.onExtensionActivity.addListener( |
346 function(activity) { | 312 function(activity) { |
347 var activityId = activity['extensionId']; | 313 var activityId = activity['extensionId']; |
348 chrome.test.assertEq('pknkgggnfecklokoggaggchhaebkajji', activityId); | 314 chrome.test.assertEq('pknkgggnfecklokoggaggchhaebkajji', activityId); |
349 | 315 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 function getTestCasesToRun() { | 363 function getTestCasesToRun() { |
398 var tests = []; | 364 var tests = []; |
399 for (var i = 0; i < testCases.length; i++) { | 365 for (var i = 0; i < testCases.length; i++) { |
400 if (testCases[i].func != undefined) { | 366 if (testCases[i].func != undefined) { |
401 tests.push(testCases[i].func); | 367 tests.push(testCases[i].func); |
402 } | 368 } |
403 } | 369 } |
404 return tests; | 370 return tests; |
405 } | 371 } |
406 chrome.test.runTests(getTestCasesToRun()); | 372 chrome.test.runTests(getTestCasesToRun()); |
OLD | NEW |