summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 23:03:24 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-01 23:03:24 +0000
commit31b882b2aac660139d1ea77b953e6c99ab184cb4 (patch)
tree2f2de701f31eafdfda111f4726b19154336a3d61
parentd933c47fdee518533c427d2873cd345bdbe2522e (diff)
downloadchromium_src-31b882b2aac660139d1ea77b953e6c99ab184cb4.zip
chromium_src-31b882b2aac660139d1ea77b953e6c99ab184cb4.tar.gz
chromium_src-31b882b2aac660139d1ea77b953e6c99ab184cb4.tar.bz2
The layoutTestController had its queueScript method broken into two:
queueLoadingScript and queueNonLoadingScript. The behavior of the work queue also changed to be a bit simpler. Now, each WorkItem reports whether or not it kicked off a load. There is a bit more work to do here to determine if work items actually resulted in a load. For now, I am just guessing, which is almost always correct. I will follow-up with the other part of the CL once this one clears the bots. This change corresponds roughly to: http://trac.webkit.org/changeset/42082 BUG=9581 R=dglazkov Review URL: http://codereview.chromium.org/56164 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12991 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc60
-rw-r--r--webkit/tools/test_shell/layout_test_controller.h7
2 files changed, 50 insertions, 17 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index affd0da..114fc3c 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -14,6 +14,7 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/string_util.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/webframe.h"
#include "webkit/glue/webpreferences.h"
@@ -24,6 +25,9 @@
using std::string;
using std::wstring;
+using WebKit::WebScriptSource;
+using WebKit::WebString;
+
#if defined(OS_WIN)
namespace {
@@ -84,7 +88,8 @@ LayoutTestController::LayoutTestController(TestShell* shell) {
BindMethod("waitUntilDone", &LayoutTestController::waitUntilDone);
BindMethod("notifyDone", &LayoutTestController::notifyDone);
BindMethod("queueReload", &LayoutTestController::queueReload);
- BindMethod("queueScript", &LayoutTestController::queueScript);
+ BindMethod("queueLoadingScript", &LayoutTestController::queueLoadingScript);
+ BindMethod("queueNonLoadingScript", &LayoutTestController::queueNonLoadingScript);
BindMethod("queueLoad", &LayoutTestController::queueLoad);
BindMethod("queueBackNavigation", &LayoutTestController::queueBackNavigation);
BindMethod("queueForwardNavigation", &LayoutTestController::queueForwardNavigation);
@@ -161,15 +166,17 @@ void LayoutTestController::WorkQueue::ProcessWorkSoon() {
void LayoutTestController::WorkQueue::ProcessWork() {
// Quit doing work once a load is in progress.
- while (!queue_.empty() && !shell_->delegate()->top_loading_frame()) {
- queue_.front()->Run(shell_);
+ while (!queue_.empty()) {
+ bool started_load = queue_.front()->Run(shell_);
delete queue_.front();
queue_.pop();
+
+ if (started_load)
+ return;
}
- if (!shell_->delegate()->top_loading_frame() && !wait_until_done_) {
+ if (!wait_until_done_)
shell_->TestFinished();
- }
}
void LayoutTestController::WorkQueue::Reset() {
@@ -280,8 +287,9 @@ void LayoutTestController::notifyDone(
class WorkItemBackForward : public LayoutTestController::WorkItem {
public:
WorkItemBackForward(int distance) : distance_(distance) {}
- void Run(TestShell* shell) {
+ bool Run(TestShell* shell) {
shell->GoBackOrForward(distance_);
+ return true; // TODO(darin): Did it really start a navigation?
}
private:
int distance_;
@@ -303,8 +311,9 @@ void LayoutTestController::queueForwardNavigation(
class WorkItemReload : public LayoutTestController::WorkItem {
public:
- void Run(TestShell* shell) {
+ bool Run(TestShell* shell) {
shell->Reload();
+ return true;
}
};
@@ -314,21 +323,41 @@ void LayoutTestController::queueReload(
result->SetNull();
}
-class WorkItemScript : public LayoutTestController::WorkItem {
+class WorkItemLoadingScript : public LayoutTestController::WorkItem {
+ public:
+ WorkItemLoadingScript(const string& script) : script_(script) {}
+ bool Run(TestShell* shell) {
+ shell->webView()->GetMainFrame()->ExecuteScript(
+ WebScriptSource(WebString::fromUTF8(script_)));
+ return true; // TODO(darin): Did it really start a navigation?
+ }
+ private:
+ string script_;
+};
+
+class WorkItemNonLoadingScript : public LayoutTestController::WorkItem {
public:
- WorkItemScript(const string& script) : script_(script) {}
- void Run(TestShell* shell) {
- wstring url = L"javascript:" + UTF8ToWide(script_);
- shell->LoadURL(url.c_str());
+ WorkItemNonLoadingScript(const string& script) : script_(script) {}
+ bool Run(TestShell* shell) {
+ shell->webView()->GetMainFrame()->ExecuteScript(
+ WebScriptSource(WebString::fromUTF8(script_)));
+ return false;
}
private:
string script_;
};
-void LayoutTestController::queueScript(
+void LayoutTestController::queueLoadingScript(
+ const CppArgumentList& args, CppVariant* result) {
+ if (args.size() > 0 && args[0].isString())
+ work_queue_.AddWork(new WorkItemLoadingScript(args[0].ToString()));
+ result->SetNull();
+}
+
+void LayoutTestController::queueNonLoadingScript(
const CppArgumentList& args, CppVariant* result) {
if (args.size() > 0 && args[0].isString())
- work_queue_.AddWork(new WorkItemScript(args[0].ToString()));
+ work_queue_.AddWork(new WorkItemNonLoadingScript(args[0].ToString()));
result->SetNull();
}
@@ -336,9 +365,10 @@ class WorkItemLoad : public LayoutTestController::WorkItem {
public:
WorkItemLoad(const GURL& url, const string& target)
: url_(url), target_(target) {}
- void Run(TestShell* shell) {
+ bool Run(TestShell* shell) {
shell->LoadURLForFrame(UTF8ToWide(url_.spec()).c_str(),
UTF8ToWide(target_).c_str());
+ return true; // TODO(darin): Did it really start a navigation?
}
private:
GURL url_;
diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h
index 5bceddf..3f56bce 100644
--- a/webkit/tools/test_shell/layout_test_controller.h
+++ b/webkit/tools/test_shell/layout_test_controller.h
@@ -80,7 +80,8 @@ class LayoutTestController : public CppBoundClass {
void queueBackNavigation(const CppArgumentList& args, CppVariant* result);
void queueForwardNavigation(const CppArgumentList& args, CppVariant* result);
void queueReload(const CppArgumentList& args, CppVariant* result);
- void queueScript(const CppArgumentList& args, CppVariant* result);
+ void queueLoadingScript(const CppArgumentList& args, CppVariant* result);
+ void queueNonLoadingScript(const CppArgumentList& args, CppVariant* result);
void queueLoad(const CppArgumentList& args, CppVariant* result);
// Although this is named "objC" to match the Mac version, it actually tests
@@ -214,7 +215,9 @@ class LayoutTestController : public CppBoundClass {
class WorkItem {
public:
virtual ~WorkItem() {}
- virtual void Run(TestShell* shell) = 0;
+
+ // Returns true if this started a load.
+ virtual bool Run(TestShell* shell) = 0;
};
// Used to clear the value of shell_ from test_shell_tests.