Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: chrome/renderer/extensions/safe_builtins.cc

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hopefully fix tests Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/safe_builtins.cc
diff --git a/chrome/renderer/extensions/safe_builtins.cc b/chrome/renderer/extensions/safe_builtins.cc
index c28b07763d7bf2287f86155a2a4e2e12ec4921aa..bc0c5f2d5f5fbf42501337c2576f80a2ef4b9623 100644
--- a/chrome/renderer/extensions/safe_builtins.cc
+++ b/chrome/renderer/extensions/safe_builtins.cc
@@ -59,7 +59,7 @@ const char kScript[] =
" return safe;\n"
"}\n"
"\n"
- "[Array, Function, Object].forEach(function(builtin) {\n"
+ "[Array, Function, Object, RegExp, String].forEach(function(builtin) {\n"
" Save(builtin.name, getSafeBuiltin(builtin));\n"
"});\n"
"}());\n";
@@ -105,13 +105,17 @@ class ExtensionImpl : public v8::Extension {
info[2]->IsObject() && // args
info[3]->IsInt32() && // first_arg_index
info[4]->IsInt32()); // args_length
- if (!info[1]->IsObject()) {
+ v8::Local<v8::Function> function = info[0].As<v8::Function>();
+ v8::Local<v8::Object> recv;
+ if (info[1]->IsObject()) {
+ recv = info[1]->ToObject();
+ } else if (info[1]->IsString()) {
+ recv = v8::StringObject::New(info[1]->ToString())->ToObject();
Jeffrey Yasskin 2013/06/20 23:33:04 Why are you creating a new string here instead of
not at google - send to devlin 2013/06/21 00:01:44 No new string is being created, ToString() is just
+ } else {
v8::ThrowException(v8::Exception::TypeError(v8::String::New(
"The first argument is the receiver and must be an object")));
return;
}
- v8::Local<v8::Function> function = info[0].As<v8::Function>();
- v8::Local<v8::Object> recv = info[1]->ToObject();
v8::Local<v8::Object> args = info[2]->ToObject();
int first_arg_index = static_cast<int>(info[3]->ToInt32()->Value());
int args_length = static_cast<int>(info[4]->ToInt32()->Value());
@@ -161,4 +165,12 @@ v8::Local<v8::Object> SafeBuiltins::GetObjekt() const {
return Load("Object", context_->v8_context());
}
+v8::Local<v8::Object> SafeBuiltins::GetRegExp() const {
+ return Load("RegExp", context_->v8_context());
+}
+
+v8::Local<v8::Object> SafeBuiltins::GetString() const {
+ return Load("String", context_->v8_context());
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698