Commit f8df1ace authored by kalman@chromium.org's avatar kalman@chromium.org

Make V8ValueConverterImpl serialize objects with internal field counts to an

empty object rather than skipping them altogether. This is more consistent with
the expected behaviour of extension APIs.

BUG=330559
R=jochen@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243972 0039d316-1c4b-4281-b951-d872f2087c98
parent 387e526a
......@@ -86,9 +86,10 @@ chrome.test.getConfig(function(config) {
});
},
// DOM objects (nodes, properties, etc) should not get converted. We
// could try to convert them the best they can but it's undefined what
// that means.
// DOM objects (nodes, properties, etc) should be converted to empty
// objects. We could try to convert them the best they can but it's
// undefined what that means. Ideally it'd just throw an exception but
// the backwards compatible ship sailed long ago.
function executeCallbackDOMObjShouldSucceedAndReturnNull() {
[ 'document',
'document.getElementById("testDiv")',
......@@ -99,7 +100,7 @@ chrome.test.getConfig(function(config) {
chrome.tabs.executeScript(tabId,
{code: 'var obj = ' + expr + '; obj'},
chrome.test.callbackPass(function(result) {
chrome.test.assertEq([null], result, 'Failed for ' + expr);
chrome.test.assertEq([{}], result, 'Failed for ' + expr);
}));
});
},
......
......@@ -406,8 +406,11 @@ base::Value* V8ValueConverterImpl::FromV8Object(
//
// NOTE: check this after |strategy_| so that callers have a chance to
// do something else, such as convert to the node's name rather than NULL.
//
// ANOTHER NOTE: returning an empty dictionary here to minimise surprise.
// See also http://crbug.com/330559.
if (val->InternalFieldCount())
return NULL;
return new base::DictionaryValue();
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
v8::Handle<v8::Array> property_names(val->GetOwnPropertyNames());
......
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