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

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

Issue 692313003: Allow uncaught exception messaging in Object.observe callbacks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed Created 6 years, 1 month 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/test-debug.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-object-observe.cc
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index d208a26922d5c2a97264590092d63fecfd080e33..8851d888933947143bd66f3850dd683a37d40de8 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -130,6 +130,59 @@ TEST(DeliveryOrdering) {
}
+TEST(DeliveryCallbackThrows) {
+ HandleScope scope(CcTest::isolate());
+ LocalContext context(CcTest::isolate());
+ CompileRun(
+ "var obj = {};"
+ "var ordering = [];"
+ "function observer1() { ordering.push(1); };"
+ "function observer2() { ordering.push(2); };"
+ "function observer_throws() {"
+ " ordering.push(0);"
+ " throw new Error();"
+ " ordering.push(-1);"
+ "};"
+ "Object.observe(obj, observer_throws.bind());"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, observer_throws.bind());"
+ "Object.observe(obj, observer2);"
+ "Object.observe(obj, observer_throws.bind());"
+ "obj.foo = 'bar';");
+ CHECK_EQ(5, CompileRun("ordering.length")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[0]")->Int32Value());
+ CHECK_EQ(1, CompileRun("ordering[1]")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[2]")->Int32Value());
+ CHECK_EQ(2, CompileRun("ordering[3]")->Int32Value());
+ CHECK_EQ(0, CompileRun("ordering[4]")->Int32Value());
+}
+
+
+TEST(DeliveryChangesMutationInCallback) {
+ HandleScope scope(CcTest::isolate());
+ LocalContext context(CcTest::isolate());
+ CompileRun(
+ "var obj = {};"
+ "var ordering = [];"
+ "function observer1(records) {"
+ " ordering.push(100 + records.length);"
+ " records.push(11);"
+ " records.push(22);"
+ "};"
+ "function observer2(records) {"
+ " ordering.push(200 + records.length);"
+ " records.push(33);"
+ " records.push(44);"
+ "};"
+ "Object.observe(obj, observer1);"
+ "Object.observe(obj, observer2);"
+ "obj.foo = 'bar';");
+ CHECK_EQ(2, CompileRun("ordering.length")->Int32Value());
+ CHECK_EQ(101, CompileRun("ordering[0]")->Int32Value());
+ CHECK_EQ(201, CompileRun("ordering[1]")->Int32Value());
+}
+
+
TEST(DeliveryOrderingReentrant) {
HandleScope scope(CcTest::isolate());
LocalContext context(CcTest::isolate());
« no previous file with comments | « test/cctest/test-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698