Commit f15d07af authored by ager@chromium.org's avatar ager@chromium.org

Update d8 so that it can be used to run the mjsunit tests.

Set the security token on the debugger context after all contexts have
been created in d8.  This ensures that all d8 contexts (including the
debugger context) can access eachother.

Copy extra command-line handling from the shell sample to d8.

Review URL: http://codereview.chromium.org/12431

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@836 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9367637d
......@@ -252,7 +252,6 @@ void Shell::Initialize() {
// Install the debugger object in the utility scope
i::Debug::Load();
i::Debug::debug_context()->set_security_token(i::Heap::undefined_value());
i::JSObject* debug = i::Debug::debug_context()->global();
utility_context_->Global()->Set(String::New("$debug"),
Utils::ToLocal(&debug));
......@@ -272,6 +271,9 @@ void Shell::Initialize() {
// Create the evaluation context
evaluation_context_ = Context::New(NULL, global_template);
evaluation_context_->SetSecurityToken(Undefined());
// Set the security token of the debug context to allow access.
i::Debug::debug_context()->set_security_token(i::Heap::undefined_value());
}
......@@ -341,15 +343,32 @@ int Shell::Main(int argc, char* argv[]) {
Context::Scope context_scope(evaluation_context_);
for (int i = 1; i < argc; i++) {
char* str = argv[i];
HandleScope handle_scope;
Handle<String> file_name = v8::String::New(str);
Handle<String> source = ReadFile(str);
if (source.IsEmpty()) {
printf("Error reading '%s'\n", str);
return 1;
if (strcmp(str, "-f") == 0) {
// Ignore any -f flags for compatibility with other stand-alone
// JavaScript engines.
continue;
} else if (strncmp(str, "--", 2) == 0) {
printf("Warning: unknown flag %s.\nTry --help for options\n", str);
} else if (strcmp(str, "-e") == 0 && i + 1 < argc) {
// Execute argument given to -e option directly.
v8::HandleScope handle_scope;
v8::Handle<v8::String> file_name = v8::String::New("unnamed");
v8::Handle<v8::String> source = v8::String::New(argv[i + 1]);
if (!ExecuteString(source, file_name, false, true))
return 1;
i++;
} else {
// Use all other arguments as names of files to load and run.
HandleScope handle_scope;
Handle<String> file_name = v8::String::New(str);
Handle<String> source = ReadFile(str);
if (source.IsEmpty()) {
printf("Error reading '%s'\n", str);
return 1;
}
if (!ExecuteString(source, file_name, false, true))
return 1;
}
if (!ExecuteString(source, file_name, false, true))
return 1;
}
if (run_shell)
RunShell();
......
......@@ -58,7 +58,9 @@ assertEquals(12, native_count);
// If no snapshot is used, only the 'gc' extension is loaded.
// If snapshot is used, all extensions are cached in the snapshot.
assertTrue(extension_count == 1 || extension_count == 5);
assertEquals(2, normal_count); // This script and mjsunit.js.
// This script and mjsunit.js has been loaded. If using d8, d8 loads
// a normal script during startup too.
assertTrue(normal_count == 2 || normal_count == 3);
// Test a builtins script.
var math_script = Debug.findScript('native math.js');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment