Commit f99298bf authored by rossberg@chromium.org's avatar rossberg@chromium.org

Allow implicit conversion of acceptList values to string during Object.observe

R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/23464058

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16703 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e4c179e2
...@@ -284,11 +284,6 @@ function AcceptArgIsValid(arg) { ...@@ -284,11 +284,6 @@ function AcceptArgIsValid(arg) {
arg.length < 0) arg.length < 0)
return false; return false;
var length = arg.length;
for (var i = 0; i < length; i++) {
if (!IS_STRING(arg[i]))
return false;
}
return true; return true;
} }
......
...@@ -110,14 +110,16 @@ Object.defineProperty(changeRecordWithAccessor, 'name', { ...@@ -110,14 +110,16 @@ Object.defineProperty(changeRecordWithAccessor, 'name', {
// Object.observe // 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, nonFunction); }, TypeError);
assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError);
assertThrows(function() { Object.observe(obj, function() {}, 1); }, TypeError); assertEquals(obj, Object.observe(obj, observer.callback, [1]));
assertThrows(function() { Object.observe(obj, function() {}, [undefined]); }, TypeError); assertEquals(obj, Object.observe(obj, observer.callback, [true]));
assertThrows(function() { Object.observe(obj, function() {}, [1]); }, TypeError); assertEquals(obj, Object.observe(obj, observer.callback, ['foo', null]));
assertThrows(function() { Object.observe(obj, function() {}, ['foo', null]); }, TypeError); 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,
['foo', 'bar', 'baz']));
assertEquals(obj, Object.observe(obj, observer.callback, [])); assertEquals(obj, Object.observe(obj, observer.callback, []));
assertEquals(obj, Object.observe(obj, observer.callback, undefined)); assertEquals(obj, Object.observe(obj, observer.callback, undefined));
assertEquals(obj, Object.observe(obj, observer.callback)); assertEquals(obj, Object.observe(obj, observer.callback));
...@@ -202,6 +204,25 @@ observer.assertCallbackRecords([ ...@@ -202,6 +204,25 @@ observer.assertCallbackRecords([
{ object: obj, name: 'bar', type: 'deleted', expando2: 'str' } { 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 // No delivery takes place if no records are pending
reset(); reset();
...@@ -307,7 +328,7 @@ observer.assertCallbackRecords([ ...@@ -307,7 +328,7 @@ observer.assertCallbackRecords([
// Accept // Accept
reset(); reset();
Object.observe(obj, observer.callback, []); Object.observe(obj, observer.callback, ['somethingElse']);
Object.getNotifier(obj).notify({ Object.getNotifier(obj).notify({
type: 'new' type: 'new'
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment