summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 14:56:19 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-01 14:56:19 +0000
commitda9754bccd331b877a25272f2daae6d05b2f81e7 (patch)
treeeff676fc493472aba02141f6c09980ce0eea49f5 /chrome
parent499763a4e8099df205ee393285eed7ace1d9daad (diff)
downloadchromium_src-da9754bccd331b877a25272f2daae6d05b2f81e7.zip
chromium_src-da9754bccd331b877a25272f2daae6d05b2f81e7.tar.gz
chromium_src-da9754bccd331b877a25272f2daae6d05b2f81e7.tar.bz2
Break the test of chrome.tab.captureVisibleTab() out of ExtensionApiTest.Tabs.
Tests of chrome.tab.captureVisibleTab() fail on mac 10.6, and disabling all tab tests because of this is unfortunate. Breaking the test this way makes the 10.6 failure easier to debug. BUG=37387 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=43101 Review URL: http://codereview.chromium.org/1520005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_tabs_apitest.cc19
-rw-r--r--chrome/test/data/extensions/api_test/tabs/basics/test.js47
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/a.html5
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/b.html5
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/c.html5
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/manifest.json7
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/tabs_util.js55
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.html2
-rw-r--r--chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.js59
9 files changed, 154 insertions, 50 deletions
diff --git a/chrome/browser/extensions/extension_tabs_apitest.cc b/chrome/browser/extensions/extension_tabs_apitest.cc
index 35bbf0d..781ae74 100644
--- a/chrome/browser/extensions/extension_tabs_apitest.cc
+++ b/chrome/browser/extensions/extension_tabs_apitest.cc
@@ -9,9 +9,9 @@
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"
-// TODO(skerner): This test is flaky in linux, chromeos and on Mac OS X 10.6.
-// Figure out why and fix.
-#if defined(OS_LINUX) || defined(OS_MACOSX)
+// TODO(skerner): This test is flaky on chrome os: http://crbug.com/39843
+// TODO(skerner): Crash observed on linux as well: http://crbug.com/39746
+#if defined(OS_LINUX)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
@@ -28,3 +28,16 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Tabs) {
ASSERT_TRUE(RunExtensionTest("tabs/basics")) << message_;
}
+
+// chrome.tabs.captureVisibleTab fails on the 10.6 bots.
+// http://crbug.com/37387
+#if defined(OS_MACOSX)
+#define MAYBE_CaptureVisibleTab DISABLED_CaptureVisible
+#else
+#define MAYBE_CaptureVisibleTab CaptureVisibleTab
+#endif
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_CaptureVisibleTab) {
+ StartHTTPServer();
+
+ ASSERT_TRUE(RunExtensionTest("tabs/capture_visible_tab")) << message_;
+}
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/test.js b/chrome/test/data/extensions/api_test/tabs/basics/test.js
index ed206a5..3f67eaa 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/test.js
+++ b/chrome/test/data/extensions/api_test/tabs/basics/test.js
@@ -253,53 +253,6 @@ chrome.test.runTests([
},
*/
- // Open a window with one tab, take a snapshot.
- function captureVisibleTabSimple() {
- // Keep the resulting image small by making the window small.
- createWindow([pageUrl("a")], {"width": 300, "height": 150},
- pass(function(winId, tabIds) {
- waitForAllTabs(pass(function() {
- chrome.tabs.getSelected(winId, pass(function(tab) {
- assertEq('complete', tab.status); // waitForAllTabs ensures this.
- chrome.tabs.captureVisibleTab(winId, pass(function(imgDataUrl) {
- // The URL should be a data URL with has a JPEG mime type.
- assertEq('data:image/jpg;base64,', imgDataUrl.substr(0,22));
- }));
- }));
- }));
- }));
- },
-
- // Open a window with three tabs, take a snapshot of each.
- function captureVisibleTabMultiTab() {
- var snapshotAndRemoveSelectedTab = function(winId, callback) {
- chrome.tabs.getSelected(winId, function(tab) {
- chrome.tabs.captureVisibleTab(winId, function(imgDataUrl) {
- // Test that the URL we got is a data URL which encodes a JPEG image.
- assertEq('data:image/jpg;base64,', imgDataUrl.substr(0,22));
-
- // TODO(skerner): Once an option allows captureVisibleTab to
- // take a lossless snapshot with a set color depth, use
- // a canvas to compare |imgDataUrl| to an image of the tab
- // we expect. This can't be done with JPEG, as the results
- // vary based on the display settings.
- chrome.tabs.remove(tab.id, callback);
- });
- });
- };
-
- createWindow(["a", "b", "c"].map(pageUrl), {"width": 300, "height": 150},
- function(winId, tabIds){
- waitForAllTabs(pass(function() {
- snapshotAndRemoveSelectedTab(winId, pass(function() {
- snapshotAndRemoveSelectedTab(winId, pass(function() {
- snapshotAndRemoveSelectedTab(winId, pass(function() {}));
- }));
- }));
- }));
- });
- },
-
function tabsOnCreated() {
chrome.test.listenOnce(chrome.tabs.onCreated, function(tab) {
assertEq(pageUrl("f"), tab.url);
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/a.html b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/a.html
new file mode 100644
index 0000000..dcd442e
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/a.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>A</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/b.html b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/b.html
new file mode 100644
index 0000000..7bff50a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/b.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>B</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/c.html b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/c.html
new file mode 100644
index 0000000..ccaad19
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/c.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <h1>C</h1>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/manifest.json b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/manifest.json
new file mode 100644
index 0000000..779b040
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/manifest.json
@@ -0,0 +1,7 @@
+{
+ "name": "chrome.tabs.captureVisibleTab test",
+ "version": "0.1",
+ "description": "end-to-end browser test for chrome.tabs.captureVisibleTab",
+ "background_page": "test.html",
+ "permissions": ["tabs"]
+}
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/tabs_util.js b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/tabs_util.js
new file mode 100644
index 0000000..7d4f6d9
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/tabs_util.js
@@ -0,0 +1,55 @@
+// Utility functions to help with tabs/windows testing.
+
+// Creates one window with tabs set to the urls in the array |tabUrls|.
+// At least one url must be specified.
+// The |callback| should look like function(windowId, tabIds) {...}.
+function createWindow(tabUrls, winOptions, callback) {
+ winOptions["url"] = tabUrls[0];
+ chrome.windows.create(winOptions, function(win) {
+ assertTrue(win.id > 0);
+ var newTabIds = [];
+
+ // Create tabs and populate newTabIds array.
+ chrome.tabs.getSelected(win.id, function (tab) {
+ newTabIds.push(tab.id);
+ for (var i = 1; i < tabUrls.length; i++) {
+ chrome.tabs.create({"windowId": win.id, "url": tabUrls[i]},
+ function(tab){
+ newTabIds.push(tab.id);
+ if (newTabIds.length == tabUrls.length)
+ callback(win.id, newTabIds);
+ });
+ }
+ if (tabUrls.length == 1)
+ callback(win.id, newTabIds);
+ });
+ });
+}
+
+// Waits until all tabs (yes, in every window) have status "complete".
+// This is useful to prevent test overlap when testing tab events.
+// |callback| should look like function() {...}.
+function waitForAllTabs(callback) {
+ // Wait for all tabs to load.
+ function waitForTabs(){
+ chrome.windows.getAll({"populate": true}, function(windows) {
+ var ready = true;
+ for (var i in windows){
+ for (var j in windows[i].tabs) {
+ if (windows[i].tabs[j].status != "complete") {
+ ready = false;
+ break;
+ }
+ }
+ if (!ready)
+ break;
+ }
+ if (ready)
+ callback();
+ else
+ window.setTimeout(waitForTabs, 30);
+ });
+ }
+ waitForTabs();
+}
+
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.html b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.html
new file mode 100644
index 0000000..54f4ab7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.html
@@ -0,0 +1,2 @@
+<script src="tabs_util.js"></script>
+<script src="test.js"></script>
diff --git a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.js b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.js
new file mode 100644
index 0000000..06aad2f
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.js
@@ -0,0 +1,59 @@
+// tabs api test
+// browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleTab
+
+var pass = chrome.test.callbackPass;
+var assertEq = chrome.test.assertEq;
+var assertTrue = chrome.test.assertTrue;
+
+function pageUrl(letter) {
+ return chrome.extension.getURL(letter + ".html");
+}
+
+chrome.test.runTests([
+ // Open a window with one tab, take a snapshot.
+ function captureVisibleTabSimple() {
+ // Keep the resulting image small by making the window small.
+ createWindow([pageUrl("a")], {"width": 300, "height": 150},
+ pass(function(winId, tabIds) {
+ waitForAllTabs(pass(function() {
+ chrome.tabs.getSelected(winId, pass(function(tab) {
+ assertEq('complete', tab.status); // waitForAllTabs ensures this.
+ chrome.tabs.captureVisibleTab(winId, pass(function(imgDataUrl) {
+ // The URL should be a data URL with has a JPEG mime type.
+ assertEq('data:image/jpg;base64,', imgDataUrl.substr(0,22));
+ }));
+ }));
+ }));
+ }));
+ },
+
+ // Open a window with three tabs, take a snapshot of each.
+ function captureVisibleTabMultiTab() {
+ var snapshotAndRemoveSelectedTab = function(winId, callback) {
+ chrome.tabs.getSelected(winId, function(tab) {
+ chrome.tabs.captureVisibleTab(winId, function(imgDataUrl) {
+ // Test that the URL we got is a data URL which encodes a JPEG image.
+ assertEq('data:image/jpg;base64,', imgDataUrl.substr(0,22));
+
+ // TODO(skerner): Once an option allows captureVisibleTab to
+ // take a lossless snapshot with a set color depth, use
+ // a canvas to compare |imgDataUrl| to an image of the tab
+ // we expect. This can't be done with JPEG, as the results
+ // vary based on the display settings.
+ chrome.tabs.remove(tab.id, callback);
+ });
+ });
+ };
+
+ createWindow(["a", "b", "c"].map(pageUrl), {"width": 300, "height": 150},
+ function(winId, tabIds){
+ waitForAllTabs(pass(function() {
+ snapshotAndRemoveSelectedTab(winId, pass(function() {
+ snapshotAndRemoveSelectedTab(winId, pass(function() {
+ snapshotAndRemoveSelectedTab(winId, pass(function() {}));
+ }));
+ }));
+ }));
+ });
+ }
+]);