Commit 6d0e9ecb authored by jam@chromium.org's avatar jam@chromium.org

Rewrite HTML5 workers ui_tests to browser_tests. Compared to ui_tests,...

Rewrite HTML5 workers ui_tests to browser_tests. Compared to ui_tests, browser_tests are faster, less flaky and sharded. They're also portable to content_browsertests once we have it.

A bunch of these tests have bitrotted because they've been disabled for so long, so there are a number of fixes throughout (some were checked into WebKit). I'll keep an eye out on flakiness of the renabled tests and disable if necessary.

I haven't seen any flakiness when running them now dozens of times on my Win/Mac/Linux, so I'm renabling all disabled tests (36!). I'll keep a close eye on the tree and flakiness dashboard afterwards.

BUG=98716,48148,69881,70861,59786,36800,35965,36555,101996,34996,16934,22599
Review URL: https://chromiumcodereview.appspot.com/9802025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129641 0039d316-1c4b-4281-b951-d872f2087c98
parent 6d610bbe
......@@ -219,6 +219,9 @@ deps = {
"src/content/test/data/layout_tests/LayoutTests/platform/chromium/fast/workers":
Var("webkit_trunk") + "/LayoutTests/platform/chromium/fast/workers@" +
Var("webkit_revision"),
"src/content/test/data/layout_tests/LayoutTests/platform/chromium/fast/events":
Var("webkit_trunk") + "/LayoutTests/platform/chromium/fast/events@" +
Var("webkit_revision"),
"src/content/test/data/layout_tests/LayoutTests/platform/chromium-win/fast/events":
Var("webkit_trunk") + "/LayoutTests/platform/chromium-win/fast/events@" +
Var("webkit_revision"),
......
......@@ -838,7 +838,6 @@
'../content/browser/appcache/appcache_ui_test.cc',
'../content/browser/in_process_webkit/dom_storage_uitest.cc',
'../content/browser/renderer_host/resource_dispatcher_host_uitest.cc',
'../content/worker/test/worker_uitest.cc',
# DON'T ADD NEW FILES! SEE NOTE AT TOP OF SECTION.
],
'conditions': [
......@@ -2898,6 +2897,8 @@
'renderer/safe_browsing/phishing_thumbnailer_browsertest.cc',
'renderer/translate_helper_browsertest.cc',
'test/automation/dom_automation_browsertest.cc',
'test/base/layout_test_http_server.cc',
'test/base/layout_test_http_server.h',
'test/base/in_process_browser_test_browsertest.cc',
'test/base/chrome_render_view_test.cc',
'test/base/chrome_render_view_test.h',
......@@ -2954,6 +2955,7 @@
'../content/browser/renderer_host/resource_dispatcher_host_browsertest.cc',
'../content/browser/speech/speech_recognition_browsertest.cc',
'../content/browser/webkit_browsertest.cc',
'../content/browser/worker_host/test/worker_browsertest.cc',
'../content/renderer/mouse_lock_dispatcher_browsertest.cc',
'../content/renderer/render_view_browsertest.cc',
'../content/renderer/render_view_browsertest_mac.mm',
......
......@@ -10,6 +10,7 @@
#include "base/process_util.h"
#include "base/string_number_conversions.h"
#include "content/public/common/content_paths.h"
#include "net/test/python_utils.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
......@@ -22,7 +23,10 @@ bool PrepareCommandLine(CommandLine* cmd_line) {
if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_path))
return false;
cmd_line->SetProgram(FilePath(FILE_PATH_LITERAL("python")));
FilePath python_runtime;
if (!GetPythonRunTime(&python_runtime))
return false;
cmd_line->SetProgram(python_runtime);
FilePath script_path(src_path);
script_path = script_path.AppendASCII("third_party");
......
......@@ -34,6 +34,8 @@ class LayoutTestHttpServer {
// failures.
bool Stop() WARN_UNUSED_RESULT;
int port() const { return port_; }
private:
FilePath root_directory_; // Root directory of the server.
......
......@@ -435,12 +435,18 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
content::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
WindowedNotificationObserver auth_observer(
chrome::NOTIFICATION_AUTH_NEEDED,
content::NotificationService::AllSources());
browser->OpenURL(OpenURLParams(
url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false));
if (browser_test_flags & BROWSER_TEST_WAIT_FOR_BROWSER)
browser = WaitForBrowserNotInSet(initial_browsers);
if (browser_test_flags & BROWSER_TEST_WAIT_FOR_TAB)
tab_added_observer.Wait();
if (browser_test_flags & BROWSER_TEST_WAIT_FOR_AUTH)
auth_observer.Wait();
if (!(browser_test_flags & BROWSER_TEST_WAIT_FOR_NAVIGATION)) {
// Some other flag caused the wait prior to this.
return;
......
......@@ -82,6 +82,7 @@ enum BrowserTestWaitFlags {
BROWSER_TEST_WAIT_FOR_BROWSER = 1 << 0, // Wait for a new browser.
BROWSER_TEST_WAIT_FOR_TAB = 1 << 1, // Wait for a new tab.
BROWSER_TEST_WAIT_FOR_NAVIGATION = 1 << 2, // Wait for navigation to finish.
BROWSER_TEST_WAIT_FOR_AUTH = 1 << 3, // Wait for auth prompt.
BROWSER_TEST_MASK = BROWSER_TEST_WAIT_FOR_BROWSER |
BROWSER_TEST_WAIT_FOR_TAB |
......
<html>
<head>
<script src="worker_utils.js"></script>
</head>
<body>
<div id=result></div>
<script>
......@@ -28,9 +31,9 @@ function createWorker(i) {
workers_created++;
log("worker " + worker_id + " started - num_clients = " + event.data);
if (workers_created == num_workers) {
// created the last worker
log("SUCCESS: all workers created");
document.cookie = "status=OK";
// created the last worker
log("SUCCESS: all workers created");
onSuccess();
}
}
}
......
<html>
<head>
<script src="worker_utils.js"></script>
</head>
<body>
<div id=result></div>
<script>
......@@ -38,7 +41,7 @@ function createWorker(i) {
} else if (workers_created == (num_workers+2)) {
// created the last worker
log("SUCCESS: queued worker created");
document.cookie = "status=OK";
onSuccess();
}
}
}
......
<html>
<head>
<title>Single Worker Test</title>
<script src="worker_utils.js"></script>
<script>
var workers = [];
function startAndTerminateWorkers() {
var terminateCount = 0;
for (var i = 0 ; i < 200 ; i++) {
var w = new Worker("worker_common.js");
workers.push(w);
w.postMessage("ping");
w.onmessage = function() {
terminateCount++;
if (terminateCount == 16) {
shutdownWorkers();
}
if (terminateCount > 16) {
// Should not get more than 16 messages back unless we raise the worker
// limit.
onFailure();
}
}
}
}
function shutdownWorkers() {
for (var i = 0 ; i < workers.length ; i++) {
workers[i].terminate();
}
workers = [];
onSuccess();
}
startAndTerminateWorkers();
</script>
<body>
<div id=statusPanel></div>
</body>
<html>
<head>
<script src="worker_utils.js"></script>
</head>
<body>
<div id=result></div>
<script>
......@@ -23,7 +26,7 @@ function workerStarted(event) {
function sharedWorkerStarted(event) {
log ("shared worker created");
sharedWorker.port.postMessage("close");
document.cookie = "status=OK";
onSuccess();
}
</script>
......
......@@ -33,6 +33,5 @@ function onFinished(result) {
statusPanel.innerHTML = result;
}
var cookie = "status=" + result + "; path=/";
document.cookie = cookie;
document.title = result;
}
......@@ -8,7 +8,7 @@
class IndexedDBLayoutTest : public InProcessBrowserLayoutTest {
public:
IndexedDBLayoutTest() : InProcessBrowserLayoutTest(
FilePath().AppendASCII("storage").AppendASCII("indexeddb")) {
FilePath(), FilePath().AppendASCII("storage").AppendASCII("indexeddb")) {
}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,24 +6,50 @@
#include "base/scoped_temp_dir.h"
#include "chrome/test/base/in_process_browser_test.h"
class LayoutTestHttpServer;
class InProcessBrowserLayoutTest : public InProcessBrowserTest {
public:
explicit InProcessBrowserLayoutTest(const FilePath relative_layout_test_path);
explicit InProcessBrowserLayoutTest(const FilePath& test_parent_dir,
const FilePath& test_case_dir);
// Used when running HTTP layout tests. Starts the server in the constructor
// and keeps it running through the lifetime of this test. This is done to
// avoid flakiness in restarting the server while the port is still in use.
// If -1 is passed for |port|, a random number will be used. This is
// recommended when possible, in case multiple tests are running at the same
// time. For some tests this isn't possible though, because they use resources
// that hardcode a specific port.
InProcessBrowserLayoutTest(const FilePath& test_parent_dir,
const FilePath& test_case_dir,
int port);
virtual ~InProcessBrowserLayoutTest();
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
// Runs a layout test given its filename relative to the path given to the
// constructor.
void RunLayoutTest(const std::string& test_case_file_name);
// Runs a layout test using the HTTP test server. The second constructor must
// have been used.
void RunHttpLayoutTest(const std::string& test_case_file_name);
void AddResourceForLayoutTest(const FilePath& parent_dir,
const FilePath& resource_name);
private:
void RunLayoutTestInternal(const std::string& test_case_file_name,
const GURL& url);
void WriteModifiedFile(const std::string& test_case_file_name,
GURL* test_url);
FilePath* test_path);
FilePath our_original_layout_test_dir_;
FilePath original_relative_path_;
FilePath test_parent_dir_;
FilePath test_case_dir_;
FilePath our_layout_test_temp_dir_;
FilePath rebase_result_dir_;
FilePath rebase_result_chromium_dir_;
FilePath rebase_result_win_dir_;
ScopedTempDir scoped_temp_dir_;
int port_; // -2 means no port. -1 means random.
scoped_ptr<LayoutTestHttpServer> test_http_server_;
DISALLOW_COPY_AND_ASSIGN(InProcessBrowserLayoutTest);
};
include_rules = [
"-chrome",
"+chrome/app", # For UI test
"+chrome/test", # For UI test
"+content/browser/worker_host", # For UI test.
"+sandbox/src",
"+webkit/appcache",
"+webkit/glue",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment