Revision: 16703
Author: [email protected]
Date: Fri Sep 13 08:09:39 2013 UTC
Log: Allow implicit conversion of acceptList values to string during
Object.observe
[email protected]
BUG=
Review URL: https://codereview.chromium.org/23464058
http://code.google.com/p/v8/source/detail?r=16703
Modified:
/branches/bleeding_edge/src/object-observe.js
/branches/bleeding_edge/test/mjsunit/harmony/object-observe.js
=======================================
--- /branches/bleeding_edge/src/object-observe.js Wed Sep 11 20:03:54 2013
UTC
+++ /branches/bleeding_edge/src/object-observe.js Fri Sep 13 08:09:39 2013
UTC
@@ -284,11 +284,6 @@
arg.length < 0)
return false;
- var length = arg.length;
- for (var i = 0; i < length; i++) {
- if (!IS_STRING(arg[i]))
- return false;
- }
return true;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/object-observe.js Wed Sep
11 10:52:20 2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/harmony/object-observe.js Fri Sep
13 08:09:39 2013 UTC
@@ -110,14 +110,16 @@
// Object.observe
-assertThrows(function() { Object.observe("non-object", observer.callback);
}, TypeError);
+assertThrows(function() { Object.observe("non-object", observer.callback);
},
+ TypeError);
assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError);
assertThrows(function() { Object.observe(obj, frozenFunction); },
TypeError);
-assertThrows(function() { Object.observe(obj, function() {}, 1); },
TypeError);
-assertThrows(function() { Object.observe(obj, function() {}, [undefined]);
}, TypeError);
-assertThrows(function() { Object.observe(obj, function() {}, [1]); },
TypeError);
-assertThrows(function() { Object.observe(obj, function() {}, ['foo',
null]); }, TypeError);
-assertEquals(obj, Object.observe(obj, observer.callback,
['foo', 'bar', 'baz']));
+assertEquals(obj, Object.observe(obj, observer.callback, [1]));
+assertEquals(obj, Object.observe(obj, observer.callback, [true]));
+assertEquals(obj, Object.observe(obj, observer.callback, ['foo', null]));
+assertEquals(obj, Object.observe(obj, observer.callback, [undefined]));
+assertEquals(obj, Object.observe(obj, observer.callback,
+ ['foo', 'bar', 'baz']));
assertEquals(obj, Object.observe(obj, observer.callback, []));
assertEquals(obj, Object.observe(obj, observer.callback, undefined));
assertEquals(obj, Object.observe(obj, observer.callback));
@@ -202,6 +204,25 @@
{ object: obj, name: 'bar', type: 'deleted', expando2: 'str' }
]);
+// Non-string accept values are coerced to strings
+reset();
+Object.observe(obj, observer.callback, [true, 1, null, undefined]);
+notifier = Object.getNotifier(obj);
+notifier.notify({ type: 'true' });
+notifier.notify({ type: 'false' });
+notifier.notify({ type: '1' });
+notifier.notify({ type: '-1' });
+notifier.notify({ type: 'null' });
+notifier.notify({ type: 'nill' });
+notifier.notify({ type: 'undefined' });
+notifier.notify({ type: 'defined' });
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: obj, type: 'true' },
+ { object: obj, type: '1' },
+ { object: obj, type: 'null' },
+ { object: obj, type: 'undefined' }
+]);
// No delivery takes place if no records are pending
reset();
@@ -307,7 +328,7 @@
// Accept
reset();
-Object.observe(obj, observer.callback, []);
+Object.observe(obj, observer.callback, ['somethingElse']);
Object.getNotifier(obj).notify({
type: 'new'
});
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.