| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 2b50db7ecdbbdb99d79bd27f2951bb9021d61bcf..d18667018d4bb8baec8f5866372ae138464e6493 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -11308,3 +11308,72 @@ TEST(GCInFailedAccessCheckCallback) {
|
| // the other tests.
|
| v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
|
| }
|
| +
|
| +
|
| +TEST(StringCheckMultipleContexts) {
|
| + const char* code =
|
| + "(function() { return \"a\".charAt(0); })()";
|
| +
|
| + {
|
| + // Run the code twice in the first context to initialize the call IC.
|
| + v8::HandleScope scope;
|
| + LocalContext context1;
|
| + ExpectString(code, "a");
|
| + ExpectString(code, "a");
|
| + }
|
| +
|
| + {
|
| + // Change the String.prototype in the second context and check
|
| + // that the right function gets called.
|
| + v8::HandleScope scope;
|
| + LocalContext context2;
|
| + CompileRun("String.prototype.charAt = function() { return \"not a\"; }");
|
| + ExpectString(code, "not a");
|
| + }
|
| +}
|
| +
|
| +
|
| +TEST(NumberCheckMultipleContexts) {
|
| + const char* code =
|
| + "(function() { return (42).toString(); })()";
|
| +
|
| + {
|
| + // Run the code twice in the first context to initialize the call IC.
|
| + v8::HandleScope scope;
|
| + LocalContext context1;
|
| + ExpectString(code, "42");
|
| + ExpectString(code, "42");
|
| + }
|
| +
|
| + {
|
| + // Change the Number.prototype in the second context and check
|
| + // that the right function gets called.
|
| + v8::HandleScope scope;
|
| + LocalContext context2;
|
| + CompileRun("Number.prototype.toString = function() { return \"not 42\"; }");
|
| + ExpectString(code, "not 42");
|
| + }
|
| +}
|
| +
|
| +
|
| +TEST(BooleanCheckMultipleContexts) {
|
| + const char* code =
|
| + "(function() { return true.toString(); })()";
|
| +
|
| + {
|
| + // Run the code twice in the first context to initialize the call IC.
|
| + v8::HandleScope scope;
|
| + LocalContext context1;
|
| + ExpectString(code, "true");
|
| + ExpectString(code, "true");
|
| + }
|
| +
|
| + {
|
| + // Change the Boolean.prototype in the second context and check
|
| + // that the right function gets called.
|
| + v8::HandleScope scope;
|
| + LocalContext context2;
|
| + CompileRun("Boolean.prototype.toString = function() { return \"\"; }");
|
| + ExpectString(code, "");
|
| + }
|
| +}
|
|
|