After the HTML is parsed and the DOM tree is built, for each DOM element, a
JSObject is created. The JSObject class is defined in objects.h file and
the methods reside in objects.cc file.
JSObject is inherited from class Object, and Object class is inherited from
class MaybeObject. Each JSObject probably has a map which keeps pairs of
key-value things for each DOM element, including parent, child nodes, name,
and value. The key in which keeps the value is _nodeValue (which should be
named by jsdom or htmlparser which I use for parsing and creating the DOM
tree). I change the _nodeValue directly (for example want to encrypt it). I
can change the _nodevalue. But when I assign the value of that node to a
variable, the old value is assigned to that variable.
By "directly", I mean that I want to intercept the access to DOM elements
in v8, and when a value wants to be assigned to the node, I want to encrypt
the value. In the reverse side, i should decrypt when I am reading from the
node. Currently, I think that the JSObject::SetProperty and
Object::GetProperty methods in objects.cc file is the correct place.
I intercept there and change the _nodeValue property of the JSObject then I
change the value like this:
// i is the index of _nodeValue in the map of properties of the node
DescriptorArray* descs = map()->instance_descriptors();
int index = 0;
index = descs->GetFieldIndex(i);
int offset = map()->inobject_properties() + (index * kPointerSize);
*reinterpret_cast<uint16_t*>(reinterpret_cast<byte*>(this) + offset
- kHeapObjectTag -1 ) = ENCRYPTEDVALUE;
That is how I do that. But I do not know why the change does not applies?
Am I doing right? What is the problem?
Thanks,
Hossein
On Mon, Oct 29, 2012 at 6:38 PM, Jakob Kummerow <[email protected]>wrote:
> I don't know what you're talking about. What's the "value" of a JSObject?
> What does changing it "directly" mean? What's a "_nodeValue" attribute? The
> V8 source code does not contain this string.
>
>
> On Mon, Oct 29, 2012 at 9:08 AM, HDev <[email protected]> wrote:
>
>> Hi All,
>>
>> I wan to change the value of JSObject s directly. Should I change the
>> value of _nodeValue attribute?
>> Please help!!!!!
>>
>> Thanks,
>> HDev
>>
>> --
>> v8-dev mailing list
>> [email protected]
>> http://groups.google.com/group/v8-dev
>
>
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev