summaryrefslogtreecommitdiffstats
path: root/content/renderer/v8_value_converter_impl_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Add a base::ParseJson() function to help tests construct Values.jyasskin@chromium.org2012-12-171-52/+47
| | | | | | | | | | | | | | This is very similar to base::JSONReader::Read() except that it allows trailing commas and EXPECT-fails with a good message when the json is malformed. I migrated two tests to use this as a demonstration that it's widely useful and makes things more readable. Review URL: https://chromiumcodereview.appspot.com/11567027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173540 0039d316-1c4b-4281-b951-d872f2087c98
* Move the remaining code in content\renderer that wasn't in the content ↵jam@chromium.org2012-10-221-1/+3
| | | | | | namespace to it. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163290 0039d316-1c4b-4281-b951-d872f2087c98
* Make V8ValueConverter.FromV8Value be more consistent with JSON.stringify: don'tkalman@chromium.org2012-09-171-23/+85
| | | | | | | | | | | | | | | | | | | | | | | serialize undefined as null, don't serialize functions as objects, omit values from objects when they don't serialize, and insert null into arrays when they don't serialize. It is now possible for FromV8Value to return NULL; previously it would return Value::CreateNullValue on failure. This is needed for the Storage API, where we promise that the values that are passed in are serialized as JSON, yet the value conversion doesn't work in a way that allows it. However, the null-stripping behavior needs to be configurable so that existing extension APIs (which only expect null/undefined to appear for optional values) still work. BUG=145081 Review URL: https://chromiumcodereview.appspot.com/10890002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157074 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 157025 - Make V8ValueConverter.FromV8Value be more consistent with ↵kalman@chromium.org2012-09-161-85/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | JSON.stringify: don't serialize undefined as null, don't serialize functions as objects, omit values from objects when they don't serialize, and insert null into arrays when they don't serialize. It is now possible for FromV8Value to return NULL; previously it would return Value::CreateNullValue on failure. This is needed for the Storage API, where we promise that the values that are passed in are serialized as JSON, yet the value conversion doesn't work in a way that allows it. However, the null-stripping behavior needs to be configurable so that existing extension APIs (which only expect null/undefined to appear for optional values) still work. BUG=145081 Review URL: https://codereview.chromium.org/10890002 TBR=kalman@chromium.org Review URL: https://codereview.chromium.org/10911327 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157031 0039d316-1c4b-4281-b951-d872f2087c98
* Make V8ValueConverter.FromV8Value be more consistent with JSON.stringify: don'tkalman@chromium.org2012-09-151-23/+85
| | | | | | | | | | | | | | | | | | | | | | | serialize undefined as null, don't serialize functions as objects, omit values from objects when they don't serialize, and insert null into arrays when they don't serialize. It is now possible for FromV8Value to return NULL; previously it would return Value::CreateNullValue on failure. This is needed for the Storage API, where we promise that the values that are passed in are serialized as JSON, yet the value conversion doesn't work in a way that allows it. However, the null-stripping behavior needs to be configurable so that existing extension APIs (which only expect null/undefined to appear for optional values) still work. BUG=145081 Review URL: https://codereview.chromium.org/10890002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157025 0039d316-1c4b-4281-b951-d872f2087c98
* Make V8ValueConverterImpl able to convert objects with "indexed" (numbered)kalman@chromium.org2012-09-131-0/+33
| | | | | | | | | | | | properties, such as {1: 'foo', '1': 'bar'}. BUG=146978 Review URL: https://chromiumcodereview.appspot.com/10910216 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156477 0039d316-1c4b-4281-b951-d872f2087c98
* Valgrind: Fix a leak in the V8ValueConverterImplTest test.jhawkins@chromium.org2012-09-011-10/+14
| | | | | | | | | | | | Helper function takes ownership now. BUG=98967 R=khorimoto@chromium.org TBR=jamesr Review URL: https://chromiumcodereview.appspot.com/10912035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154592 0039d316-1c4b-4281-b951-d872f2087c98
* Fixing crash in V8ValueConverter.eaugusti@chromium.org2012-08-051-0/+30
| | | | | | | | | | | | | | | | | | | | It appears that the crash occurs when the V8ValueConverter is passed an object that has a named callback (v8::Object::HasRealNamedCallbackProperty()) that is an internal property (something that is not defined in JS, but intercepted by the c++ side). Something like a DOM input element is a good example of this. The crash doesn't happen with every object that has internal properties and named callbacks, but so far I am unable to figure out how to programatically differentiate between the ones that will crash and the ones that won't. My current solution is to not convert any named callback. BUG=139933 Review URL: https://chromiumcodereview.appspot.com/10837066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150035 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 146891 - Revert 146852 - Forces V8ValueConverter to switch context ↵erg@google.com2012-07-161-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when converting objects. [The speculative revert was WRONG; test was just flaky.] Objects passed into the V8ValueConverter may have fields that reference objects in a v8::Context different than the one that was passed in. This is very common for objects that were created in an isolated world and reference globals in that world (such as window). This fix will check to see if the current v8::Context is the same as the converting objects CreationContext(). If they are different, they will be swaped during the object's conversion. In addition, the V8ValueConverter has been expanded to have the ability to omit duplicate fileds in an object. This is very important when something with a graph structure (like a DOM node) is converted. Extra checks for integer/string fields have been added as in respone to Jakob's observation: https://code.google.com/p/chromium/issues/detail?id=134661#c5 BUG=134661, 135104 TEST=content_unittests::V8ValueConverterImplTest.RecursiveObject Review URL: https://chromiumcodereview.appspot.com/10704030 TBR=eaugusti@chromium.org Review URL: https://chromiumcodereview.appspot.com/10789024 TBR=erg@google.com Review URL: https://chromiumcodereview.appspot.com/10794002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146903 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 146852 - Forces V8ValueConverter to switch context when converting ↵erg@google.com2012-07-161-72/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects. [This is a speculative revert. This is the largest patch in the blamelist and we have no idea how to proceed. http://build.chromium.org/p/chromium.memory/builders/Chromium%20OS%20ASAN%20Tests%20%281%29/builds/19 ] Objects passed into the V8ValueConverter may have fields that reference objects in a v8::Context different than the one that was passed in. This is very common for objects that were created in an isolated world and reference globals in that world (such as window). This fix will check to see if the current v8::Context is the same as the converting objects CreationContext(). If they are different, they will be swaped during the object's conversion. In addition, the V8ValueConverter has been expanded to have the ability to omit duplicate fileds in an object. This is very important when something with a graph structure (like a DOM node) is converted. Extra checks for integer/string fields have been added as in respone to Jakob's observation: https://code.google.com/p/chromium/issues/detail?id=134661#c5 BUG=134661, 135104 TEST=content_unittests::V8ValueConverterImplTest.RecursiveObject Review URL: https://chromiumcodereview.appspot.com/10704030 TBR=eaugusti@chromium.org Review URL: https://chromiumcodereview.appspot.com/10789024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146891 0039d316-1c4b-4281-b951-d872f2087c98
* Forces V8ValueConverter to switch context when converting objects.eaugusti@chromium.org2012-07-161-0/+72
| | | | | | | | | | | | | | | | | | | | | | | Objects passed into the V8ValueConverter may have fields that reference objects in a v8::Context different than the one that was passed in. This is very common for objects that were created in an isolated world and reference globals in that world (such as window). This fix will check to see if the current v8::Context is the same as the converting objects CreationContext(). If they are different, they will be swaped during the object's conversion. In addition, the V8ValueConverter has been expanded to have the ability to omit duplicate fileds in an object. This is very important when something with a graph structure (like a DOM node) is converted. Extra checks for integer/string fields have been added as in respone to Jakob's observation: https://code.google.com/p/chromium/issues/detail?id=134661#c5 BUG=134661, 135104 TEST=content_unittests::V8ValueConverterImplTest.RecursiveObject Review URL: https://chromiumcodereview.appspot.com/10704030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146852 0039d316-1c4b-4281-b951-d872f2087c98
* Allow "null" to mean optional in extension APIs (for realz), but normalise itkalman@chromium.org2012-05-301-0/+22
| | | | | | | | | | | | | | | | | | for browser implementations by stripping it from objects. The following are all now exactly the same, where previously they weren't and would either not work or crash the browser/renderer: chrome.tabs.create({}); chrome.tabs.create({windowId: undefined}); chrome.tabs.create({windowId: null}); BUG=129411 TEST=as in bug Review URL: https://chromiumcodereview.appspot.com/10456010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139510 0039d316-1c4b-4281-b951-d872f2087c98
* Support optional arguments in SendRequestNatives::StartRequestbattre@chromium.org2012-05-161-4/+4
| | | | | | | | | | | | | | | Extensions send calls via SendRequestNatives::StartRequest. It is necessary to support undefined v8 values to express optional parameters. This CL exposes the functionality to configure support for Undefined, Date and Regex data types in content::V8ValueConverter and uses it to enable Undefined values in SendRequestNatives::StartRequest. BUG=127533 TEST=error messages on console are gone, see bug report Review URL: https://chromiumcodereview.appspot.com/10387055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137452 0039d316-1c4b-4281-b951-d872f2087c98
* Make V8ValueConverter be an interface and move it to content\public\renderer ↵jam@chromium.org2011-10-041-0/+326
and put in the content namespace. BUG=98716 Review URL: http://codereview.chromium.org/8122011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103925 0039d316-1c4b-4281-b951-d872f2087c98