Reviewers: rossberg, arv, adamk,

Description:
Object.unobserve(obj, callback) now throws a TypeError when callback is not a
function.


Please review this at https://codereview.chromium.org/11293248/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/object-observe.js
  M test/mjsunit/harmony/object-observe.js


Index: src/object-observe.js
diff --git a/src/object-observe.js b/src/object-observe.js
index 28aa1f4e4e988caf624efcfd72df9c5d83325e30..61f8aa3a016bb92d90c29aab095e653dfd9b7bbe 100644
--- a/src/object-observe.js
+++ b/src/object-observe.js
@@ -100,6 +100,8 @@ function ObjectObserve(object, callback) {
 function ObjectUnobserve(object, callback) {
   if (!IS_SPEC_OBJECT(object))
     throw MakeTypeError("observe_non_object", ["unobserve"]);
+  if (!IS_SPEC_FUNCTION(callback))
+    throw MakeTypeError("observe_non_function", ["unobserve"]);

   var objectInfo = objectInfoMap.get(object);
   if (IS_UNDEFINED(objectInfo))
Index: test/mjsunit/harmony/object-observe.js
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js index 945841bd50ebc552084e0c658e145d4295459587..dbdf84848d14e228e4a11a5ff4df4e6fd5a0cbcd 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -100,6 +100,7 @@ assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError);

 // Object.unobserve
assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); +assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError);

 // Object.getNotifier
 var notifier = Object.getNotifier(obj);


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to