summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 18:29:55 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 18:29:55 +0000
commitbb08f1570dd01855b7a4d71ba37b43af5dae4578 (patch)
treedf21b77f7d7e129ecb256738046719fa8c518f92
parentbec2c9fbba00e66bf5b13c59d021a0aa4d03427b (diff)
downloadchromium_src-bb08f1570dd01855b7a4d71ba37b43af5dae4578.zip
chromium_src-bb08f1570dd01855b7a4d71ba37b43af5dae4578.tar.gz
chromium_src-bb08f1570dd01855b7a4d71ba37b43af5dae4578.tar.bz2
Enable layout tests: worker-constructor.html and worker-script-error.html.
BUG=none TEST=none Review URL: http://codereview.chromium.org/159429 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21863 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/worker/worker_uitest.cc39
-rw-r--r--webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/use-machine-stack-expected.txt4
-rw-r--r--webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-constructor-expected.txt8
-rw-r--r--webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-location-expected.txt15
-rw-r--r--webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-constructor-expected.txt3
-rw-r--r--webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-script-error-expected.txt10
-rw-r--r--webkit/glue/webworkerclient_impl.cc24
7 files changed, 60 insertions, 43 deletions
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index fde40d2..06e8c8e 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -55,6 +55,7 @@ class WorkerTest : public UITest {
FilePath new_http_root_dir_;
FilePath new_layout_test_dir_;
FilePath rebase_result_dir_;
+ FilePath rebase_result_win_dir_;
std::string layout_test_controller_;
};
@@ -117,17 +118,16 @@ void WorkerTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
// If not found, try to use the original copy of WebKit layout tests for
// workers. For testing only in local machine only.
- // webkit/data/layout_tests/LayoutTests/.../workers
+ // third_party/LayoutTests/.../workers
if (!file_util::DirectoryExists(layout_test_dir_)) {
- layout_test_dir_ = src_dir.AppendASCII("webkit");
- layout_test_dir_ = layout_test_dir_.AppendASCII("data");
- layout_test_dir_ = layout_test_dir_.AppendASCII("layout_tests");
+ layout_test_dir_ = src_dir.AppendASCII("third_party");
layout_test_dir_ = layout_test_dir_.Append(test_parent_dir);
layout_test_dir_ = layout_test_dir_.Append(test_case_dir);
ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_));
}
- // Gets the file path to rebased expected result directory for workers.
+ // Gets the file path to rebased expected result directory for workers for
+ // current platform.
// webkit/data/layout_tests/platform/chromium_***/LayoutTests/.../workers
rebase_result_dir_ = src_dir.AppendASCII("webkit");
rebase_result_dir_ = rebase_result_dir_.AppendASCII("data");
@@ -137,6 +137,19 @@ void WorkerTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir);
rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir);
+ // Gets the file path to rebased expected result directory for workers under
+ // win32 platform. This is used by other non-win32 platform to use the same
+ // rebased expected results.
+#if !defined(OS_WIN)
+ rebase_result_win_dir_ = src_dir.AppendASCII("webkit");
+ rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("data");
+ rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("layout_tests");
+ rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("platform");
+ rebase_result_win_dir_ = rebase_result_win_dir_.AppendASCII("chromium-win");
+ rebase_result_win_dir_ = rebase_result_win_dir_.Append(test_parent_dir);
+ rebase_result_win_dir_ = rebase_result_win_dir_.Append(test_case_dir);
+#endif
+
// Creates the temporary directory.
ASSERT_TRUE(file_util::CreateNewTempDirectory(
FILE_PATH_LITERAL("chrome_worker_test_"), &temp_test_dir_));
@@ -244,10 +257,15 @@ void WorkerTest::RunLayoutTest(const std::string& test_case_file_name,
std::string expected_result_value;
if (!ReadExpectedResult(rebase_result_dir_,
test_case_file_name,
- &expected_result_value))
- ReadExpectedResult(layout_test_dir_,
- test_case_file_name,
- &expected_result_value);
+ &expected_result_value)) {
+ if (rebase_result_win_dir_.empty() ||
+ !ReadExpectedResult(rebase_result_win_dir_,
+ test_case_file_name,
+ &expected_result_value))
+ ReadExpectedResult(layout_test_dir_,
+ test_case_file_name,
+ &expected_result_value);
+ }
ASSERT_TRUE(!expected_result_value.empty());
// Normalizes the expected result.
@@ -283,7 +301,7 @@ TEST_F(WorkerTest, WorkerFastLayoutTests) {
"stress-js-execution.html",
"use-machine-stack.html",
"worker-close.html",
- //"worker-constructor.html",
+ "worker-constructor.html",
"worker-context-gc.html",
"worker-event-listener.html",
"worker-gc.html",
@@ -291,6 +309,7 @@ TEST_F(WorkerTest, WorkerFastLayoutTests) {
"worker-navigator.html",
"worker-replace-global-constructor.html",
"worker-replace-self.html",
+ "worker-script-error.html",
"worker-terminate.html",
"worker-timeout.html"
};
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/use-machine-stack-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/use-machine-stack-expected.txt
deleted file mode 100644
index 1c344db..0000000
--- a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/use-machine-stack-expected.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Test worker thread stack usage. Should not crash.
-
-PASS (RangeError: Maximum call stack size exceeded)
-
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-constructor-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-constructor-expected.txt
deleted file mode 100644
index 15a042c..0000000
--- a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-constructor-expected.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Test Worker constructor functionality. Should print a series of PASS messages, followed with DONE.
-
-PASS: toString exception propagated correctly.
-PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded)
-PASS: invoking Worker constructor without arguments resulted in an exception (SyntaxError: Not enough arguments)
-PASS: onerror invoked for a script that could not be loaded.
-DONE
-
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-location-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-location-expected.txt
deleted file mode 100644
index 2596296..0000000
--- a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/fast/workers/worker-location-expected.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Test WorkerLocation properties.
-
-WorkerLocation: function WorkerLocation() { [native code] }
-typeof location: object
-location: file:<...>/fast/workers/resources/worker-common.js
-location.href: file:<...>/fast/workers/resources/worker-common.js
-location.protocol: file:
-location.host:
-location.hostname:
-location.port:
-location.pathname: <...>/fast/workers/resources/worker-common.js
-location.search:
-location.hash:
-DONE
-
diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-constructor-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-constructor-expected.txt
index 15a042c..8dde63c 100644
--- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-constructor-expected.txt
+++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-constructor-expected.txt
@@ -3,6 +3,9 @@ Test Worker constructor functionality. Should print a series of PASS messages, f
PASS: toString exception propagated correctly.
PASS: trying to create workers recursively resulted in an exception (RangeError: Maximum call stack size exceeded)
PASS: invoking Worker constructor without arguments resulted in an exception (SyntaxError: Not enough arguments)
+PASS: onerror invoked for an empty script URL.
+PASS: onerror invoked for an invalid script URL.
PASS: onerror invoked for a script that could not be loaded.
+PASS: Successfully created worker.
DONE
diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-script-error-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-script-error-expected.txt
new file mode 100644
index 0000000..42044af
--- /dev/null
+++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/fast/workers/worker-script-error-expected.txt
@@ -0,0 +1,10 @@
+Test Worker script error handling functionality. Should print a series of PASS messages, followed with DONE.
+
+PASS: onerror invoked for a script that has invalid syntax.
+PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 1.
+PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
+PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
+PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
+PASS: message received from WorkerGlobalScope.onerror: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
+DONE
+
diff --git a/webkit/glue/webworkerclient_impl.cc b/webkit/glue/webworkerclient_impl.cc
index 22b7c17..1465eda 100644
--- a/webkit/glue/webworkerclient_impl.cc
+++ b/webkit/glue/webworkerclient_impl.cc
@@ -212,10 +212,17 @@ void WebWorkerClientImpl::postExceptionToWorkerObject(
return;
}
- script_execution_context_->reportException(
- webkit_glue::WebStringToString(error_message),
- line_number,
- webkit_glue::WebStringToString(source_url));
+ bool handled = false;
+ if (worker_->onerror())
+ handled = worker_->dispatchScriptErrorEvent(
+ webkit_glue::WebStringToString(error_message),
+ webkit_glue::WebStringToString(source_url),
+ line_number);
+ if (!handled)
+ script_execution_context_->reportException(
+ webkit_glue::WebStringToString(error_message),
+ line_number,
+ webkit_glue::WebStringToString(source_url));
}
void WebWorkerClientImpl::postConsoleMessageToWorkerObject(
@@ -325,8 +332,13 @@ void WebWorkerClientImpl::PostExceptionToWorkerObjectTask(
const WebCore::String& error_message,
int line_number,
const WebCore::String& source_url) {
- this_ptr->script_execution_context_->reportException(
- error_message, line_number, source_url);
+ bool handled = false;
+ if (this_ptr->worker_ && this_ptr->worker_->onerror())
+ handled = this_ptr->worker_->dispatchScriptErrorEvent(
+ error_message, source_url, line_number);
+ if (!handled)
+ this_ptr->script_execution_context_->reportException(
+ error_message, line_number, source_url);
}
void WebWorkerClientImpl::PostConsoleMessageToWorkerObjectTask(