Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: test/cctest/test-global-object.cc

Issue 12040042: Merged r13480, r13481 into trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698