Commit f713507e authored by johnme@chromium.org's avatar johnme@chromium.org

Fix notifications tests' use of assert_object_equals

Several notifications layout tests misues assert_object_equals, passing
in non-object values, and assuming it will behave like assert_equals.

Spoiler - it doesn't: assert_object_equals(true, false) passes!

BUG=none

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

git-svn-id: svn://svn.chromium.org/blink/trunk@201317 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8dfddcef
...@@ -14,10 +14,8 @@ ...@@ -14,10 +14,8 @@
function assertNotificationDataReflects(value) { function assertNotificationDataReflects(value) {
var notification = new Notification('Title', { data: value }); var notification = new Notification('Title', { data: value });
if (Array.isArray(value)) if (typeof value === 'object')
assert_object_equals(notification.data, value); assert_object_equals(notification.data, value);
else if (typeof value === 'object')
assert_array_equals(notification.data, value);
else else
assert_equals(notification.data, value); assert_equals(notification.data, value);
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
var notificationDataList = new Array( var notificationDataList = new Array(
true, // Check Boolean type true, // Check Boolean type
1024, // Check Number type 1024, // Check Number type
Number.NaN, // Check Number.NaN type
'any data', // Check String type 'any data', // Check String type
new Array('Saab', 'Volvo', 'BMW'), // Check Array type new Array('Saab', 'Volvo', 'BMW'), // Check Array type
{ first: 'first', second: 'second' } // Check object { first: 'first', second: 'second' } // Check object
...@@ -64,10 +63,13 @@ ...@@ -64,10 +63,13 @@
var pos = event.data.notification.tag; var pos = event.data.notification.tag;
assert_object_equals(event.data.notification.data, notificationDataList[pos], 'The data field must be the same.'); if (typeof notificationDataList[pos] === 'object')
assert_object_equals(event.data.notification.data, notificationDataList[pos], 'The data field must be the same.');
else
assert_equals(event.data.notification.data, notificationDataList[pos], 'The data field must be the same.');
if (pos < notificationDataList.length) if (++pos < notificationDataList.length)
assertNotificationDataReflects(++pos); assertNotificationDataReflects(pos);
else else
test.done(); test.done();
}); });
......
...@@ -68,11 +68,12 @@ ...@@ -68,11 +68,12 @@
// set on the Notification object are as expected. // set on the Notification object are as expected.
assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.'); assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
options.actions = options.actions.slice(0, Notification.maxActions);
Object.keys(options).forEach(function(key) { Object.keys(options).forEach(function(key) {
if (key == 'actions') if (typeof options[key] == 'object')
assert_object_equals(event.data.notification.actions, options.actions.slice(0, Notification.maxActions));
else
assert_object_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.'); assert_object_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
else
assert_equals(event.data.notification[key], options[key], 'The ' + key + ' field must be the same.');
}); });
test.done(); test.done();
......
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