[Qtwebengine] Any way to disable same-origin policy?

Kevin Truong knt261 at gmail.com
Fri Nov 20 23:53:33 CET 2015


Thanks Kai, that was helpful! I would actually prefer to use this method if
I can better control when to execute the script -- it seems like the
injection points are very limited, tied to certain document events.

On Thu, Nov 19, 2015 at 11:55 PM, Koehne Kai <Kai.Koehne at theqtcompany.com>
wrote:

>
>
> > -----Original Message-----
> > From: Kevin Truong [mailto:knt261 at gmail.com]
> > [...]
> > Kai -- Although my issue is fixed, I'm still curious to try out your
> method. How do
> > I use QWebEngineScript with the QWebEnginePage object that I have? For
> > example, I tried to add the following code right after calling m_page-
> > >runJavascript(m_script):
> >
> >
> >
> >
> >     QWebEngineScriptCollection* scripts = &m_page->scripts();
> >     QList<QWebEngineScript> scriptsList = scripts->toList();
> >     for (int i = 0; i < scriptsList.size(); i++) {
> >         QWebEngineScript script = scriptsList.at(i);
> >         script.setRunsOnSubFrames(true);
> >     }
> >
> >
> > But it doesn't seem to work (maybe the javascript is already finished
> running
> > before I was able to iterate through all the script source and set
> > runsOnSubFrames to true). Mind if you point me to the right
> > direction/documentation?
>
> You've to replace the runJavaScript() call with a QWebEngineScript.
>
> So
>
>   page.runJavascript(m_script);
>
> becomes e.g.
>
>   QWebEngineScript script;
>   script.setSourceCode(m_script);
>   script.setInjectionPoint(QWebEngineScript::DocumentReady);
>   script.setRunsOnSubFrames(true);
>   page.scripts.insert(script);
>
> Note that you can't set a callback method in this API though.
>
> The relationship with runJavaScript() could be indeed better documented
> ... I'll have a look.
>
> Regards
>
> Kai
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qtwebengine/attachments/20151120/0adb7616/attachment.html>


More information about the QtWebEngine mailing list