Index: test/cctest/test-global-object.cc |
diff --git a/test/mjsunit/regress/regress-2489.js b/test/cctest/test-global-object.cc |
similarity index 67% |
copy from test/mjsunit/regress/regress-2489.js |
copy to test/cctest/test-global-object.cc |
index 882c4f794a88e24d1d64e86a466b27c39f51e625..16c0be0eb95ee4a4fe5e42c2bcfa6760f0c8120e 100644 |
--- a/test/mjsunit/regress/regress-2489.js |
+++ b/test/cctest/test-global-object.cc |
@@ -25,26 +25,27 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Flags: --allow-natives-syntax |
+#include "v8.h" |
-"use strict"; |
+#include "cctest.h" |
-function f(a, b) { |
- return g("c", "d"); |
-} |
- |
-function g(a, b) { |
- g.constructor.apply(this, arguments); |
-} |
+using namespace v8; |
-g.constructor = function(a, b) { |
- assertEquals("c", a); |
- assertEquals("d", b); |
+// This test fails if properties on the prototype of the global object appear |
+// as declared globals. |
+TEST(StrictUndeclaredGlobalVariable) { |
+ HandleScope scope; |
+ v8::Local<v8::String> var_name = v8_str("x"); |
+ LocalContext context; |
+ v8::TryCatch try_catch; |
+ v8::Local<v8::Script> script = v8_compile("\"use strict\"; x = 42;"); |
+ v8::Handle<v8::Object> proto = v8::Object::New(); |
+ v8::Handle<v8::Object> global = |
+ context->Global()->GetPrototype().As<v8::Object>(); |
+ proto->Set(var_name, v8_num(100)); |
+ global->SetPrototype(proto); |
+ script->Run(); |
+ CHECK(try_catch.HasCaught()); |
+ v8::String::Utf8Value exception(try_catch.Exception()); |
+ CHECK_EQ("ReferenceError: x is not defined", *exception); |
} |
- |
-f("a", "b"); |
-f("a", "b"); |
-%OptimizeFunctionOnNextCall(f); |
-f("a", "b"); |
-g.x = "deopt"; |
-f("a", "b"); |