summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 19:45:06 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-26 19:45:06 +0000
commit73b8a1ce654d9d0f82f02c1838f803f5ec345e7f (patch)
tree0a489c3c8597dccec78f9f59677be9978c741ef9 /chrome/test
parent9c035022e847ba18bb51f63212f9cb86c9cf27c0 (diff)
downloadchromium_src-73b8a1ce654d9d0f82f02c1838f803f5ec345e7f.zip
chromium_src-73b8a1ce654d9d0f82f02c1838f803f5ec345e7f.tar.gz
chromium_src-73b8a1ce654d9d0f82f02c1838f803f5ec345e7f.tar.bz2
We need to add UI tests to test workers after we switch to process-per-worker model and remove uses of V8 lockers. Due to this, we can not run any worker layout test that starts multiple workers because we load V8 instance in DLL in test shell. To cover this deficiency, we need to add UI tests to test multiple workers.
BUG=12554 TEST=none Review URL: http://codereview.chromium.org/115731 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16890 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/workers/multi_worker.html52
-rw-r--r--chrome/test/data/workers/single_worker.html25
-rw-r--r--chrome/test/data/workers/worker_common.js11
-rw-r--r--chrome/test/data/workers/worker_utils.js18
-rw-r--r--chrome/test/ui/ui_tests.vcproj8
5 files changed, 114 insertions, 0 deletions
diff --git a/chrome/test/data/workers/multi_worker.html b/chrome/test/data/workers/multi_worker.html
new file mode 100644
index 0000000..b0ef8cc
--- /dev/null
+++ b/chrome/test/data/workers/multi_worker.html
@@ -0,0 +1,52 @@
+<html>
+
+<head>
+<title>Multi-Worker Test</title>
+
+<script src="worker_utils.js"></script>
+
+<script>
+
+var expected_total = 0;
+var actual_total = 0;
+var completed_worker_count = 0;
+var total_workers = 4;
+
+function createWorker(base) {
+ var worker = new Worker("worker_common.js");
+ for (var i = 0; i < 100; i++) {
+ worker.postMessage("eval " + base + "+" + i);
+ expected_total += base + i;
+ }
+ worker.postMessage("ping");
+ worker.onmessage = function(evt) {
+ if (evt.data == "pong") {
+ completed_worker_count++;
+ if (completed_worker_count == total_workers) {
+ if (expected_total == actual_total)
+ onSuccess();
+ else
+ onFailure();
+ }
+ } else {
+ try {
+ actual_total += parseInt(evt.data);
+ } catch (ex) {
+ onFailure();
+ }
+ }
+ }
+ return worker;
+}
+
+for (var i = 0; i < total_workers; ++i) {
+ var worker = createWorker(100 + i);
+}
+
+</script>
+</head>
+
+<body>
+<div id=statusPanel></div>
+</body>
+</html>
diff --git a/chrome/test/data/workers/single_worker.html b/chrome/test/data/workers/single_worker.html
new file mode 100644
index 0000000..d5b1962
--- /dev/null
+++ b/chrome/test/data/workers/single_worker.html
@@ -0,0 +1,25 @@
+<html>
+
+<head>
+<title>Single Worker Test</title>
+
+<script src="worker_utils.js"></script>
+
+<script>
+
+var worker = new Worker("worker_common.js");
+worker.postMessage("ping");
+worker.onmessage = function(evt) {
+ if (evt.data == "pong")
+ onSuccess();
+ else
+ onFailure();
+}
+
+</script>
+</head>
+
+<body>
+<div id=statusPanel></div>
+</body>
+</html>
diff --git a/chrome/test/data/workers/worker_common.js b/chrome/test/data/workers/worker_common.js
new file mode 100644
index 0000000..583c6a5
--- /dev/null
+++ b/chrome/test/data/workers/worker_common.js
@@ -0,0 +1,11 @@
+onmessage = function(evt) {
+ if (evt.data == "ping")
+ postMessage("pong");
+ else if (/eval.+/.test(evt.data)) {
+ try {
+ postMessage(eval(evt.data.substr(5)));
+ } catch (ex) {
+ postMessage(ex);
+ }
+ }
+}
diff --git a/chrome/test/data/workers/worker_utils.js b/chrome/test/data/workers/worker_utils.js
new file mode 100644
index 0000000..03c84631
--- /dev/null
+++ b/chrome/test/data/workers/worker_utils.js
@@ -0,0 +1,18 @@
+function onSuccess()
+{
+ setTimeout(onFinished, 0, "OK");
+}
+
+function onFailure() {
+ setTimeout(onFinished, 0, "FAIL");
+}
+
+function onFinished(result) {
+ var statusPanel = document.getElementById("statusPanel");
+ if (statusPanel) {
+ statusPanel.innerHTML = result;
+ }
+
+ var cookie = "status=" + result + "; path=/";
+ document.cookie = cookie;
+} \ No newline at end of file
diff --git a/chrome/test/ui/ui_tests.vcproj b/chrome/test/ui/ui_tests.vcproj
index e50ff06..c959806 100644
--- a/chrome/test/ui/ui_tests.vcproj
+++ b/chrome/test/ui/ui_tests.vcproj
@@ -606,6 +606,14 @@
>
</File>
</Filter>
+ <Filter
+ Name="TestWorker"
+ >
+ <File
+ RelativePath="..\..\worker\worker_uitest.cc"
+ >
+ </File>
+ </Filter>
</Files>
<Globals>
</Globals>