How to disable web security (cross origin reequest

2019-08-14 22:02发布

问题:

I'm trying to write a site specific browser for a few sites and am facing an issue with webkitgtk. WebKitGtk blocks some cross domain request as a security measure and there is no way to disable it in the WebKitGtk API

Python simple example

from gi.repository import Gtk, WebKit
window = Gtk.Window()
webview = WebKit.WebView()
webview.load_uri('http://drive.google.com')
window.add(webview)
window.show_all()
Gtk.main()

Output:

  ** Message: console message:  @0: Unable to post message to https://0.drive.google.com. Recipient has origin https://drive.google.com.

回答1:

Not possible as of now. Bug: https://bugs.webkit.org/show_bug.cgi?id=58378



回答2:

The only setting that appears relevant to me is enable-xss-auditor:

settings = WebKit.WebSettings()
settings.set_property('enable-xss-auditor', False)
webview.set_settings(settings)