diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 14:25:39 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 14:25:39 +0000 |
commit | aaadcd81066a3430b33702288cd56a39986b4326 (patch) | |
tree | 08f2f9e011880015dd47c669f4311f17faa55391 /chrome/test | |
parent | 83e29c010812422515660e4a0b77f1738f238aec (diff) | |
download | chromium_src-aaadcd81066a3430b33702288cd56a39986b4326.zip chromium_src-aaadcd81066a3430b33702288cd56a39986b4326.tar.gz chromium_src-aaadcd81066a3430b33702288cd56a39986b4326.tar.bz2 |
Add unit test that uses V8's JSON.parse() to read extension_api.json .
BUG=18717
TEST=ExtensionApiJsonValidityTest.WithV8
Review URL: http://codereview.chromium.org/661406
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/v8_unit_test.cc | 7 | ||||
-rw-r--r-- | chrome/test/v8_unit_test.h | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/chrome/test/v8_unit_test.cc b/chrome/test/v8_unit_test.cc index 4b94ad9..0ac6c1f 100644 --- a/chrome/test/v8_unit_test.cc +++ b/chrome/test/v8_unit_test.cc @@ -14,6 +14,13 @@ void V8UnitTest::SetUp() { context_ = v8::Context::New(NULL, global); } +void V8UnitTest::SetGlobalStringVar(const std::string& var_name, + const std::string& value) { + v8::Context::Scope context_scope(context_); + context_->Global()->Set(v8::String::New(var_name.c_str(), var_name.length()), + v8::String::New(value.c_str(), value.length())); +} + void V8UnitTest::ExecuteScriptInContext(const base::StringPiece& script_source, const base::StringPiece& script_name) { v8::Context::Scope context_scope(context_); diff --git a/chrome/test/v8_unit_test.h b/chrome/test/v8_unit_test.h index 644c660..7e05783 100644 --- a/chrome/test/v8_unit_test.h +++ b/chrome/test/v8_unit_test.h @@ -28,6 +28,10 @@ class V8UnitTest : public testing::Test { virtual void ExecuteScriptInContext(const base::StringPiece& script_source, const base::StringPiece& script_name); + // Set a variable to a string value in the global scope. + virtual void SetGlobalStringVar(const std::string& var_name, + const std::string& value); + // Converts a v8::TryCatch into a human readable string. virtual std::string ExceptionToString(v8::TryCatch* try_catch); |