zubastik3000 / delphichromiumembedded

Automatically exported from code.google.com/p/delphichromiumembedded
0 stars 0 forks source link

TCefRTTIExtension.Register() adds unwanted Delphi native methods to *ALL* JavaScript variables inside the chromium embedded environment. #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
*What steps will reproduce the problem?

//Use Delphi 2010 or higher,define a class exposed to JS :
  TMyClass = class 
    class procedure MyFunc(const v: string); 
  end; 
initialization 
// Register your object
var
  gMyObj: TMyClass;
  gMyObj := TMyClass.Create;
  TCefRTTIExtension.Register('myObj', gMyObj, True); 

//execute the following javascript code:
var s = '';
for (var key in s) {
   var obj = s[key];
   for (var prop in obj) {
      console.log(prop + " = " + obj[prop]);
   }
}

*What is the expected output?
console.log should output nothing since the JavaScript viable s is a string.

*What do you see instead?
a list of native Delphi object methods such as MyFunc, Create, Free, 
InitInstnace, and so on.

What version of the product are you using? On what operating system?
the latest svn, on win 7.

Original issue reported on code.google.com by edwin....@innovationgear.com on 4 Feb 2012 at 10:13

GoogleCodeExporter commented 9 years ago
additional info: it seems that you'll have to call MyFunc at least once in the 
JavaScript environment in order to reproduce this bug...

Original comment by edwin....@innovationgear.com on 4 Feb 2012 at 10:50

GoogleCodeExporter commented 9 years ago
Hi Heri,

I fixed the problem.

In ceflib.pas, replace this line
proto.SetValueByKey(m.Name, f, V8_PROPERTY_ATTRIBUTE_NONE);

with this line:
ret.SetValueByKey(m.Name, f, V8_PROPERTY_ATTRIBUTE_NONE);

I guess there are still similar problems with codes related to the JavaScript 
__proto__ property... Not sure, I'm quite new to the JS world...

Original comment by MindVisualizer@gmail.com on 5 Feb 2012 at 10:11

GoogleCodeExporter commented 9 years ago
Thank you

Original comment by hgourv...@gmail.com on 7 Feb 2012 at 9:43