amaitland wrote:Interesting that CSP only appears to be limiting Eval. I would have ExecuteJavascript to behave the same, and yet it doesn't. Thank Czarek!
I thought exactly the same... so I even didn't try. Test below works fine on pages with CSP:
- Code: Select all
FocusedFrame->ExecuteJavaScript("alert(window.pageYOffset);", FocusedFrame->GetURL(), 0);
I'll have to find a way to replace each Eval() with ExecuteJavaScript()
- Code: Select all
v8Context->Eval("document.body.clientHeight", ret, excep);
v8Context->Eval("window.getSelection().toString()", ret, excep);
v8Context->Eval("document.activeElement.tagName", ret, excep);
....
Czarek wrote:I think you can accomplish the same using ExecuteJavascript to inject custom js on pages in CefLoadHandler and javascript bindings to communicate with C++ (see wiki pages for tutorial).
EDIT: to inject custom js from the Renderer process call CefV8Context::GetFrame::ExecuteJavascript.
Czarek wrote:Try also CefV8Context::GetGlobal::GetValue("pageYOffset").GetIntValue - along with HasValue and other checks.
will study how this works in detail and then try to implement a solution. I just want to thank you very much for all the help you gave me.