diff options
author | felt@chromium.org <felt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-12 22:56:43 +0000 |
---|---|---|
committer | felt@chromium.org <felt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-12 22:56:43 +0000 |
commit | 302e4ad04fe3f6ef7a81d7e904d99bbb85b77e98 (patch) | |
tree | 34785ff6c8ae07aef2ebb9bd641f54b0134cdeb4 /chrome/test | |
parent | 554afc898cd158333155e1db18705650a22e9123 (diff) | |
download | chromium_src-302e4ad04fe3f6ef7a81d7e904d99bbb85b77e98.zip chromium_src-302e4ad04fe3f6ef7a81d7e904d99bbb85b77e98.tar.gz chromium_src-302e4ad04fe3f6ef7a81d7e904d99bbb85b77e98.tar.bz2 |
This tackles a number of ActivityLog-related corner cases. I wrote tests and then added fixes as needed.
1) Added test for chrome.app.* API calls
2) Added missing logging for chrome.app.* API calls
3) Removed event listener registration logging; added TODO
4) Added test for operations on objects returned from API calls
5) Added message passing tests
6) Added missing logging for message passing
BUG=229703
Review URL: https://chromiumcodereview.appspot.com/13726026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
4 files changed, 99 insertions, 3 deletions
diff --git a/chrome/test/data/extensions/activity_log/manifest.json b/chrome/test/data/extensions/activity_log/manifest.json index b22648d..b93f112 100644 --- a/chrome/test/data/extensions/activity_log/manifest.json +++ b/chrome/test/data/extensions/activity_log/manifest.json @@ -3,8 +3,14 @@ "version": "0.1", "description": "Testing the Activity Log", "permissions": [ "cookies", "tabs", "webRequest", "webRequestBlocking", - "http://*/*", "https://*/*" ], + "http://*/*", "https://*/*", "storage" ], "options_page": "options.html", "manifest_version": 2, - "omnibox": { "keyword" : "hello" } + "omnibox": { "keyword" : "hello" }, + "content_scripts": [ + { + "matches": ["http://www.google.com.bo/*"], + "js": ["google_cs.js"] + } + ] } diff --git a/chrome/test/data/extensions/activity_log/options.html b/chrome/test/data/extensions/activity_log/options.html index 415f8ad..6a4a404 100644 --- a/chrome/test/data/extensions/activity_log/options.html +++ b/chrome/test/data/extensions/activity_log/options.html @@ -7,12 +7,20 @@ <button id="api_call">Make a successful API call</button><br /> <button id="special_call">Make a special API call</button><br /> <button id="double">Check we don't double log API calls</button><br /> + <button id="app_bindings">Make a chrome.app.* API call</button><br /> <button id="blocked_call">Make a blocked API call</button><br /> <button id="inject_cs">Inject a content script</button><br /> <button id="inject_blob">Inject a blob of code</button><br /> <button id="background_xhr">Do a background XHR</button><br /> <button id="cs_xhr">Do a content script XHR</button><br /> <button id="webrequest">Modify HTTP headers with webRequest</button><br /> + <button id="object_properties">Read and change an object's + properties</button><br /> + <button id="object_methods">Invoke an object's methods</button><br /> + <button id="message_cs">Send a message to a content script</button><br /> + <button id="message_self">Send a message within the ext</button><br /> + <button id="message_other">Send a message to another ext</button><br /> + <button id="connect_other">Connect to another ext</button><br /> <br /> <b>Status:</b> <div id="status"></div> </body> diff --git a/chrome/test/data/extensions/activity_log/options.js b/chrome/test/data/extensions/activity_log/options.js index d7d290d..1298b30 100644 --- a/chrome/test/data/extensions/activity_log/options.js +++ b/chrome/test/data/extensions/activity_log/options.js @@ -68,7 +68,18 @@ function checkNoDoubleLogging() { setCompleted('checkNoDoubleLogging'); } +// Check whether we log calls to chrome.app.*; +function checkAppCalls() { + chrome.app.getDetails(); + setCompleted('chrome.app.getDetails()'); + var b = chrome.app.isInstalled; + setCompleted('chrome.app.isInstalled'); + var c = chrome.app.installState(); + setCompleted('chrome.app.installState()'); +} + // Makes an API call that the extension doesn't have permission for. +// Don't add the management permission or this test won't test the code path. function makeBlockedApiCall() { try { var all_extensions = chrome.management.getAll(); @@ -174,6 +185,62 @@ function doWebRequestModifications() { window.open('http://www.google.co.uk'); } +function getSetObjectProperties() { + chrome.tabs.onUpdated.addListener( + function getTabProperties(tabId, changeInfo, tab) { + if (changeInfo['status'] === "complete" + && tab.url.match(/google\.dk/g)) { + console.log(tab.id + " " + tab.index + " " + tab.url); + tab.index = 3333333333333333333; + chrome.tabs.remove(tabId); + chrome.tabs.onUpdated.removeListener(getTabProperties); + setCompleted('getSetObjectProperties'); + } + } + ); + window.open('http://www.google.dk'); +} + +function callObjectMethod() { + var storageArea = chrome.storage.sync; + storageArea.clear(); + setCompleted('callObjectMethod()'); +} + +function sendMessageToCS() { + chrome.tabs.onUpdated.addListener( + function messageCS(tabId, changeInfo, tab) { + if (changeInfo['status'] === "complete" + && tab.url.match(/google\.com\.bo/g)) { + chrome.tabs.sendMessage(tabId, "hellooooo!"); + chrome.tabs.remove(tabId); + chrome.tabs.onUpdated.removeListener(messageCS); + setCompleted('sendMessageToCS'); + } + } + ); + window.open('http://www.google.com.bo'); +} + +function sendMessageToSelf() { + chrome.runtime.sendMessage("hello hello"); + setCompleted('sendMessageToSelf'); +} + +function sendMessageToOther() { + chrome.runtime.sendMessage("ocacnieaapoflmkebkeaidpgfngocapl", + "knock knock", + function response() { + console.log("who's there?"); + }); + setCompleted('sendMessageToOther'); +} + +function connectToOther() { + chrome.runtime.connect("ocacnieaapoflmkebkeaidpgfngocapl"); + setCompleted('connectToOther'); +} + // REGISTER YOUR TESTS HERE // Attach the tests to buttons. function setupEvents() { @@ -186,6 +253,13 @@ function setupEvents() { $('cs_xhr').addEventListener('click', doContentScriptXHR); $('webrequest').addEventListener('click', doWebRequestModifications); $('double').addEventListener('click', checkNoDoubleLogging); + $('app_bindings').addEventListener('click', checkAppCalls); + $('object_properties').addEventListener('click', getSetObjectProperties); + $('object_methods').addEventListener('click', callObjectMethod); + $('message_cs').addEventListener('click', sendMessageToCS); + $('message_self').addEventListener('click', sendMessageToSelf); + $('message_other').addEventListener('click', sendMessageToOther); + $('connect_other').addEventListener('click', connectToOther); completed = 0; total = document.getElementsByTagName('button').length; diff --git a/chrome/test/data/extensions/activity_log_app/background.js b/chrome/test/data/extensions/activity_log_app/background.js index 34f67fc..add0e8f 100644 --- a/chrome/test/data/extensions/activity_log_app/background.js +++ b/chrome/test/data/extensions/activity_log_app/background.js @@ -1,7 +1,6 @@ // Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - function recordDevice(device) { console.log("recordDevice"); } @@ -11,3 +10,12 @@ chrome.app.runtime.onLaunched.addListener(function() { chrome.bluetooth.startDiscovery({deviceCallback: recordDevice}); chrome.bluetooth.stopDiscovery(); }); + +chrome.runtime.onMessageExternal.addListener( + function(message, sender, response) { + response(); +}); + +chrome.runtime.onConnectExternal.addListener(function(port) { + console.log("connected"); +});
\ No newline at end of file |