summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 02:12:10 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 02:12:10 +0000
commit765d0cf58c5e241facdee2bf1ceb7f95e6cb141e (patch)
treeb90493209ee1610e3c1ea1602e59c3577dcf757e
parentf3bdd8872778e4482891e364e6bacbf8a71a0ce4 (diff)
downloadchromium_src-765d0cf58c5e241facdee2bf1ceb7f95e6cb141e.zip
chromium_src-765d0cf58c5e241facdee2bf1ceb7f95e6cb141e.tar.gz
chromium_src-765d0cf58c5e241facdee2bf1ceb7f95e6cb141e.tar.bz2
Add test harness for isolated worlds. Actual tests will appear upstream.
R=dglazkov BUG=15989 Review URL: http://codereview.chromium.org/149193 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20122 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc20
-rw-r--r--webkit/tools/test_shell/layout_test_controller.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index fd30eb8..374f95f 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -134,6 +134,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) {
BindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
BindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled);
+ BindMethod("queueScriptInIsolatedWorld", &LayoutTestController::queueScriptInIsolatedWorld);
// The fallback method is called when an unknown method is invoked.
BindFallbackMethod(&LayoutTestController::fallbackMethod);
@@ -345,6 +346,18 @@ class WorkItemNonLoadingScript : public LayoutTestController::WorkItem {
string script_;
};
+class WorkItemIsolatedWorldScript : public LayoutTestController::WorkItem {
+ public:
+ WorkItemIsolatedWorldScript(const string& script) : script_(script) {}
+ bool Run(TestShell* shell) {
+ WebScriptSource source(WebString::fromUTF8(script_));
+ shell->webView()->GetMainFrame()->ExecuteScriptInNewContext(&source, 1);
+ return false;
+ }
+ private:
+ string script_;
+};
+
void LayoutTestController::queueLoadingScript(
const CppArgumentList& args, CppVariant* result) {
if (args.size() > 0 && args[0].isString())
@@ -771,6 +784,13 @@ void LayoutTestController::setXSSAuditorEnabled(
result->SetNull();
}
+void LayoutTestController::queueScriptInIsolatedWorld(
+ const CppArgumentList& args, CppVariant* result) {
+ if (args.size() > 0 && args[0].isString())
+ work_queue_.AddWork(new WorkItemIsolatedWorldScript(args[0].ToString()));
+ result->SetNull();
+}
+
void LayoutTestController::fallbackMethod(
const CppArgumentList& args, CppVariant* result) {
std::wstring message(L"JavaScript ERROR: unknown method called on LayoutTestController");
diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h
index fb9f9be..ca8e2a8 100644
--- a/webkit/tools/test_shell/layout_test_controller.h
+++ b/webkit/tools/test_shell/layout_test_controller.h
@@ -171,6 +171,7 @@ class LayoutTestController : public CppBoundClass {
void setPrivateBrowsingEnabled(const CppArgumentList& args, CppVariant* result);
void setXSSAuditorEnabled(const CppArgumentList& args, CppVariant* result);
+ void queueScriptInIsolatedWorld(const CppArgumentList& args, CppVariant* result);
// The fallback method is called when a nonexistent method is called on
// the layout test controller object.