| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 4874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4885 | 4885 |
| 4886 v8::Local<v8::String> data_obj_source = v8::String::New( | 4886 v8::Local<v8::String> data_obj_source = v8::String::New( |
| 4887 "({ a: 'abc',\n" | 4887 "({ a: 'abc',\n" |
| 4888 " b: 123,\n" | 4888 " b: 123,\n" |
| 4889 " toString: function() { return this.a + ' ' + this.b; }\n" | 4889 " toString: function() { return this.a + ' ' + this.b; }\n" |
| 4890 "})\n"); | 4890 "})\n"); |
| 4891 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run(); | 4891 v8::Local<v8::Value> data_obj = v8::Script::Compile(data_obj_source)->Run(); |
| 4892 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); | 4892 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); |
| 4893 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); | 4893 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); |
| 4894 script2->Run(); | 4894 script2->Run(); |
| 4895 script2->SetData(data_obj); | 4895 script2->SetData(data_obj->ToString()); |
| 4896 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 4896 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
| 4897 f->Call(env->Global(), 0, NULL); | 4897 f->Call(env->Global(), 0, NULL); |
| 4898 CHECK_EQ(3, break_point_hit_count); | 4898 CHECK_EQ(3, break_point_hit_count); |
| 4899 CHECK_EQ("new name", last_script_name_hit); | 4899 CHECK_EQ("new name", last_script_name_hit); |
| 4900 CHECK_EQ("abc 123", last_script_data_hit); | 4900 CHECK_EQ("abc 123", last_script_data_hit); |
| 4901 } | 4901 } |
| 4902 | 4902 |
| 4903 | 4903 |
| 4904 static v8::Persistent<v8::Context> expected_context; | 4904 static v8::Persistent<v8::Context> expected_context; |
| 4905 static v8::Handle<v8::Value> expected_context_data; | 4905 static v8::Handle<v8::Value> expected_context_data; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4938 v8::Handle<v8::ObjectTemplate>(); | 4938 v8::Handle<v8::ObjectTemplate>(); |
| 4939 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); | 4939 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); |
| 4940 context_1 = v8::Context::New(NULL, global_template, global_object); | 4940 context_1 = v8::Context::New(NULL, global_template, global_object); |
| 4941 context_2 = v8::Context::New(NULL, global_template, global_object); | 4941 context_2 = v8::Context::New(NULL, global_template, global_object); |
| 4942 | 4942 |
| 4943 // Default data value is undefined. | 4943 // Default data value is undefined. |
| 4944 CHECK(context_1->GetData()->IsUndefined()); | 4944 CHECK(context_1->GetData()->IsUndefined()); |
| 4945 CHECK(context_2->GetData()->IsUndefined()); | 4945 CHECK(context_2->GetData()->IsUndefined()); |
| 4946 | 4946 |
| 4947 // Set and check different data values. | 4947 // Set and check different data values. |
| 4948 v8::Handle<v8::Value> data_1 = v8::Number::New(1); | 4948 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
| 4949 v8::Handle<v8::Value> data_2 = v8::String::New("2"); | 4949 v8::Handle<v8::String> data_2 = v8::String::New("2"); |
| 4950 context_1->SetData(data_1); | 4950 context_1->SetData(data_1); |
| 4951 context_2->SetData(data_2); | 4951 context_2->SetData(data_2); |
| 4952 CHECK(context_1->GetData()->StrictEquals(data_1)); | 4952 CHECK(context_1->GetData()->StrictEquals(data_1)); |
| 4953 CHECK(context_2->GetData()->StrictEquals(data_2)); | 4953 CHECK(context_2->GetData()->StrictEquals(data_2)); |
| 4954 | 4954 |
| 4955 // Simple test function which causes a break. | 4955 // Simple test function which causes a break. |
| 4956 const char* source = "function f() { debugger; }"; | 4956 const char* source = "function f() { debugger; }"; |
| 4957 | 4957 |
| 4958 // Enter and run function in the first context. | 4958 // Enter and run function in the first context. |
| 4959 { | 4959 { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5102 v8::Persistent<v8::Context> context_1; | 5102 v8::Persistent<v8::Context> context_1; |
| 5103 v8::Handle<v8::ObjectTemplate> global_template = | 5103 v8::Handle<v8::ObjectTemplate> global_template = |
| 5104 v8::Handle<v8::ObjectTemplate>(); | 5104 v8::Handle<v8::ObjectTemplate>(); |
| 5105 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); | 5105 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); |
| 5106 context_1 = v8::Context::New(NULL, global_template, global_object); | 5106 context_1 = v8::Context::New(NULL, global_template, global_object); |
| 5107 | 5107 |
| 5108 // Default data value is undefined. | 5108 // Default data value is undefined. |
| 5109 CHECK(context_1->GetData()->IsUndefined()); | 5109 CHECK(context_1->GetData()->IsUndefined()); |
| 5110 | 5110 |
| 5111 // Set and check a data value. | 5111 // Set and check a data value. |
| 5112 v8::Handle<v8::Value> data_1 = v8::Number::New(1); | 5112 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
| 5113 context_1->SetData(data_1); | 5113 context_1->SetData(data_1); |
| 5114 CHECK(context_1->GetData()->StrictEquals(data_1)); | 5114 CHECK(context_1->GetData()->StrictEquals(data_1)); |
| 5115 | 5115 |
| 5116 // Simple test function with eval that causes a break. | 5116 // Simple test function with eval that causes a break. |
| 5117 const char* source = "function f() { eval('debugger;'); }"; | 5117 const char* source = "function f() { eval('debugger;'); }"; |
| 5118 | 5118 |
| 5119 // Enter and run function in the context. | 5119 // Enter and run function in the context. |
| 5120 { | 5120 { |
| 5121 v8::Context::Scope context_scope(context_1); | 5121 v8::Context::Scope context_scope(context_1); |
| 5122 expected_context = context_1; | 5122 expected_context = context_1; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5589 | 5589 |
| 5590 break_point_hit_count = 0; | 5590 break_point_hit_count = 0; |
| 5591 foo->Call(env->Global(), 0, NULL); | 5591 foo->Call(env->Global(), 0, NULL); |
| 5592 CHECK_EQ(1, break_point_hit_count); | 5592 CHECK_EQ(1, break_point_hit_count); |
| 5593 | 5593 |
| 5594 v8::Debug::SetDebugEventListener(NULL); | 5594 v8::Debug::SetDebugEventListener(NULL); |
| 5595 debugee_context = v8::Handle<v8::Context>(); | 5595 debugee_context = v8::Handle<v8::Context>(); |
| 5596 debugger_context = v8::Handle<v8::Context>(); | 5596 debugger_context = v8::Handle<v8::Context>(); |
| 5597 CheckDebuggerUnloaded(); | 5597 CheckDebuggerUnloaded(); |
| 5598 } | 5598 } |
| OLD | NEW |