OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 24151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24162 | 24162 |
24163 | 24163 |
24164 static void ExtrasBindingTestRuntimeFunction( | 24164 static void ExtrasBindingTestRuntimeFunction( |
24165 const v8::FunctionCallbackInfo<v8::Value>& args) { | 24165 const v8::FunctionCallbackInfo<v8::Value>& args) { |
24166 CHECK_EQ( | 24166 CHECK_EQ( |
24167 3, | 24167 3, |
24168 args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()); | 24168 args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()); |
24169 args.GetReturnValue().Set(v8_num(7)); | 24169 args.GetReturnValue().Set(v8_num(7)); |
24170 } | 24170 } |
24171 | 24171 |
| 24172 TEST(ExtrasFunctionSource) { |
| 24173 v8::Isolate* isolate = CcTest::isolate(); |
| 24174 v8::HandleScope handle_scope(isolate); |
| 24175 LocalContext env; |
| 24176 |
| 24177 v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); |
| 24178 |
| 24179 // Functions defined in extras do not expose source code. |
| 24180 auto func = binding->Get(env.local(), v8_str("testFunctionToString")) |
| 24181 .ToLocalChecked() |
| 24182 .As<v8::Function>(); |
| 24183 auto undefined = v8::Undefined(isolate); |
| 24184 auto result = func->Call(env.local(), undefined, 0, {}) |
| 24185 .ToLocalChecked() |
| 24186 .As<v8::String>(); |
| 24187 CHECK(result->StrictEquals(v8_str("function foo() { [native code] }"))); |
| 24188 |
| 24189 // Functions defined in extras do not show up in the stack trace. |
| 24190 auto wrapper = binding->Get(env.local(), v8_str("testStackTrace")) |
| 24191 .ToLocalChecked() |
| 24192 .As<v8::Function>(); |
| 24193 CHECK(env->Global()->Set(env.local(), v8_str("wrapper"), wrapper).FromJust()); |
| 24194 ExpectString( |
| 24195 "function f(x) { return wrapper(x) }" |
| 24196 "function g() { return new Error().stack; }" |
| 24197 "f(g)", |
| 24198 "Error\n" |
| 24199 " at g (<anonymous>:1:58)\n" |
| 24200 " at f (<anonymous>:1:24)\n" |
| 24201 " at <anonymous>:1:78"); |
| 24202 } |
24172 | 24203 |
24173 TEST(ExtrasBindingObject) { | 24204 TEST(ExtrasBindingObject) { |
24174 v8::Isolate* isolate = CcTest::isolate(); | 24205 v8::Isolate* isolate = CcTest::isolate(); |
24175 v8::HandleScope handle_scope(isolate); | 24206 v8::HandleScope handle_scope(isolate); |
24176 LocalContext env; | 24207 LocalContext env; |
24177 | 24208 |
24178 // standalone.gypi ensures we include the test-extra.js file, which should | 24209 // standalone.gypi ensures we include the test-extra.js file, which should |
24179 // export the tested functions. | 24210 // export the tested functions. |
24180 v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); | 24211 v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); |
24181 | 24212 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24648 CHECK(proxy->GetTarget()->SameValue(target)); | 24679 CHECK(proxy->GetTarget()->SameValue(target)); |
24649 CHECK(proxy->GetHandler()->SameValue(handler)); | 24680 CHECK(proxy->GetHandler()->SameValue(handler)); |
24650 | 24681 |
24651 proxy->Revoke(); | 24682 proxy->Revoke(); |
24652 CHECK(proxy->IsProxy()); | 24683 CHECK(proxy->IsProxy()); |
24653 CHECK(!target->IsProxy()); | 24684 CHECK(!target->IsProxy()); |
24654 CHECK(proxy->IsRevoked()); | 24685 CHECK(proxy->IsRevoked()); |
24655 CHECK(proxy->GetTarget()->SameValue(target)); | 24686 CHECK(proxy->GetTarget()->SameValue(target)); |
24656 CHECK(proxy->GetHandler()->IsNull()); | 24687 CHECK(proxy->GetHandler()->IsNull()); |
24657 } | 24688 } |
OLD | NEW |