summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 18:03:42 +0000
committerskerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 18:03:42 +0000
commitd1894cea41b1c4bff639ea125645daf8a7ce57de (patch)
treebba063f6dfa0b471c1e876b8962e716fb20dfacd
parent6136c43ee1a776040560b1f5a82debfe6f5615c4 (diff)
downloadchromium_src-d1894cea41b1c4bff639ea125645daf8a7ce57de.zip
chromium_src-d1894cea41b1c4bff639ea125645daf8a7ce57de.tar.gz
chromium_src-d1894cea41b1c4bff639ea125645daf8a7ce57de.tar.bz2
Revert 43101 - 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 Review URL: http://codereview.chromium.org/1520005 TBR=skerner@chromium.org Review URL: http://codereview.chromium.org/1577002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43109 0039d316-1c4b-4281-b951-d872f2087c98
-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, 50 insertions, 154 deletions
diff --git a/chrome/browser/extensions/extension_tabs_apitest.cc b/chrome/browser/extensions/extension_tabs_apitest.cc
index 781ae74..35bbf0d 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 on chrome os: http://crbug.com/39843
-// TODO(skerner): Crash observed on linux as well: http://crbug.com/39746
-#if defined(OS_LINUX)
+// 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)
#define MAYBE_Tabs DISABLED_Tabs
#else
#define MAYBE_Tabs Tabs
@@ -28,16 +28,3 @@ 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 3f67eaa..ed206a5 100644
--- a/chrome/test/data/extensions/api_test/tabs/basics/test.js
+++ b/chrome/test/data/extensions/api_test/tabs/basics/test.js
@@ -253,6 +253,53 @@ 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
deleted file mode 100644
index dcd442e..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/a.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<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
deleted file mode 100644
index 7bff50a..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/b.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<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
deleted file mode 100644
index ccaad19..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/c.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<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
deleted file mode 100644
index 779b040..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/manifest.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "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
deleted file mode 100644
index 7d4f6d9..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/tabs_util.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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
deleted file mode 100644
index 54f4ab7..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<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
deleted file mode 100644
index 06aad2f..0000000
--- a/chrome/test/data/extensions/api_test/tabs/capture_visible_tab/test.js
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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() {}));
- }));
- }));
- }));
- });
- }
-]);