From 3947c4d60629f25db90519933ea98bf273259fdd Mon Sep 17 00:00:00 2001 From: "rafaelw@chromium.org" Date: Thu, 13 Aug 2009 00:04:06 +0000 Subject: I have taken over this patch, original authored by Adam Hunter (adamhunter). The original issue is: http://codereview.chromium.org/144019 -------------- Functionality has been requested in the Extension API for Javascript to take screenshots of the currently visible tab. This changelist builds this function, chrome.tabs.getVisibleScreenCapture. This function takes a single callback function and returns to that function a data URL of a JPEG image of the current screen. A simple sample extension is provided as a use case. BUG=14760 TEST=There is an extension in chrome\test\data\extensions\samples\screenshot, load this extension. It creates a toolstrip button. Click this button, you should get a page with a screenshot of the active tab. The API function is found at chrome.tabs.getVisibleScreenCapture. Review URL: http://codereview.chromium.org/160228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23259 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/extensions/extension_api_client_unittest.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'chrome/renderer') diff --git a/chrome/renderer/extensions/extension_api_client_unittest.cc b/chrome/renderer/extensions/extension_api_client_unittest.cc index 5465a5c..49136c5 100644 --- a/chrome/renderer/extensions/extension_api_client_unittest.cc +++ b/chrome/renderer/extensions/extension_api_client_unittest.cc @@ -422,6 +422,18 @@ TEST_F(ExtensionAPIClientTest, RemoveTab) { "tabs.remove", "2"); } +TEST_F(ExtensionAPIClientTest, CaptureVisibleTab) { + ExpectJsFail("chrome.tabs.captureVisibleTab(0);", + "Uncaught Error: Parameter 1 is required."); + + ExpectJsFail("chrome.tabs.captureVisibleTab(function(){}, 0)", + "Uncaught Error: Invalid value for argument 0. " + "Expected 'integer' but got 'function'."); + + ExpectJsPass("chrome.tabs.captureVisibleTab(null, function(img){});", + "tabs.captureVisibleTab", "null"); +} + // Bookmark API tests // TODO(erikkay) add more variations here -- cgit v1.1