diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 05:59:06 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 05:59:06 +0000 |
commit | 0c9f326176095aacc0de142746bc485d62082407 (patch) | |
tree | c12fbd1a2b4a32fa1d64282c62cd8d44b86e5380 /chrome/test | |
parent | 61161fdc716423ae44471cb08893977a8ed995ae (diff) | |
download | chromium_src-0c9f326176095aacc0de142746bc485d62082407.zip chromium_src-0c9f326176095aacc0de142746bc485d62082407.tar.gz chromium_src-0c9f326176095aacc0de142746bc485d62082407.tar.bz2 |
Always send the full tab object in ExtensionAction click event.
Along the way, decompose a few swiss army knife functions to
simplify and generalize code.
BUG=149020
Review URL: https://codereview.chromium.org/10909256
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
3 files changed, 14 insertions, 3 deletions
diff --git a/chrome/test/data/extensions/api_test/browser_action/basics/background.js b/chrome/test/data/extensions/api_test/browser_action/basics/background.js index 4160911..db07f43 100644 --- a/chrome/test/data/extensions/api_test/browser_action/basics/background.js +++ b/chrome/test/data/extensions/api_test/browser_action/basics/background.js @@ -3,8 +3,16 @@ // found in the LICENSE file. // Called when the user clicks on the browser action. -chrome.browserAction.onClicked.addListener(function(windowId) { - chrome.tabs.executeScript(null, {code:"document.body.bgColor='red'"}); +chrome.browserAction.onClicked.addListener(function(tab) { + // Privacy-sensitive properties are treated specially. Ensure they are + // present. + chrome.test.assertTrue(Boolean(tab.url.length)); + chrome.test.assertTrue(Boolean(tab.title.length)); + + // Everything else is handled in a general way and should of course also + // be present. + chrome.test.assertTrue(Boolean(tab.id)); + chrome.test.notifyPass(); }); chrome.test.notifyPass(); diff --git a/chrome/test/data/extensions/api_test/browser_action/basics/manifest.json b/chrome/test/data/extensions/api_test/browser_action/basics/manifest.json index c9acc10..e67eaa8 100644 --- a/chrome/test/data/extensions/api_test/browser_action/basics/manifest.json +++ b/chrome/test/data/extensions/api_test/browser_action/basics/manifest.json @@ -6,7 +6,7 @@ "scripts": ["background.js"] }, "permissions": [ - "tabs", "http://*/*" + "http://*/*" ], "browser_action": { "default_title": "Make this page red", diff --git a/chrome/test/data/extensions/api_test/messaging/connect/test.js b/chrome/test/data/extensions/api_test/messaging/connect/test.js index 54c58a2..95a9d1d 100644 --- a/chrome/test/data/extensions/api_test/messaging/connect/test.js +++ b/chrome/test/data/extensions/api_test/messaging/connect/test.js @@ -65,6 +65,9 @@ chrome.test.getConfig(function(config) { // Tests that postMessage from the tab and its response works. function postMessageFromTab() { chrome.extension.onConnect.addListener(function(port) { + chrome.test.assertTrue(Boolean(port.sender.tab.url)); + chrome.test.assertTrue(Boolean(port.sender.tab.title)); + chrome.test.assertTrue(Boolean(port.sender.tab.id)); port.onMessage.addListener(function(msg) { chrome.test.assertTrue(msg.testPostMessageFromTab); port.postMessage({success: true, portName: port.name}); |