Fix error message for Object.observe accept argument

BUG=chromium:464695
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#27171}
This commit is contained in:
adamk 2015-03-12 12:04:29 -07:00 committed by Commit bot
parent a1a2046274
commit 0c305e0b1b
3 changed files with 15 additions and 2 deletions

View File

@ -81,7 +81,7 @@ var kMessages = {
observe_non_object: ["Object.", "%0", " cannot ", "%0", " non-object"], observe_non_object: ["Object.", "%0", " cannot ", "%0", " non-object"],
observe_non_function: ["Object.", "%0", " cannot deliver to non-function"], observe_non_function: ["Object.", "%0", " cannot deliver to non-function"],
observe_callback_frozen: ["Object.observe cannot deliver to a frozen function object"], observe_callback_frozen: ["Object.observe cannot deliver to a frozen function object"],
observe_invalid_accept: ["Object.observe accept must be an array of strings."], observe_invalid_accept: ["Third argument to Object.observe must be an array of strings."],
observe_type_non_string: ["Invalid changeRecord with non-string 'type' property"], observe_type_non_string: ["Invalid changeRecord with non-string 'type' property"],
observe_perform_non_string: ["Invalid non-string changeType"], observe_perform_non_string: ["Invalid non-string changeType"],
observe_perform_non_function: ["Cannot perform non-function"], observe_perform_non_function: ["Cannot perform non-function"],

View File

@ -271,7 +271,7 @@ function ConvertAcceptListToTypeMap(arg) {
return arg; return arg;
if (!IS_SPEC_OBJECT(arg)) if (!IS_SPEC_OBJECT(arg))
throw MakeTypeError("observe_accept_invalid"); throw MakeTypeError("observe_invalid_accept");
var len = ToInteger(arg.length); var len = ToInteger(arg.length);
if (len < 0) len = 0; if (len < 0) len = 0;

View File

@ -1824,3 +1824,16 @@ for (var b1 = 0; b1 < 2; ++b1)
{ object: fun, type: 'add', name: 'name' }, { object: fun, type: 'add', name: 'name' },
]); ]);
})(); })();
(function TestObserveInvalidAcceptMessage() {
var ex;
try {
Object.observe({}, function(){}, "not an object");
} catch (e) {
ex = e;
}
assertInstanceof(ex, TypeError);
assertEquals("Third argument to Object.observe must be an array of strings.",
ex.message);
})()