[PyQt] Bug in QWebKit?...
Kovid Goyal
kovid at kovidgoyal.net
Fri Jan 13 08:15:29 GMT 2012
In my experience (writing an ebook viewer based on Qt WebKit) disagreements
between DOM and javascript values are *very* common. There's no a priori way to
know which is correct. You have to do it on a case by case basis and be prepared
to have lots of heuristic sanity checks. Furthermore, the things that disagree
and how they disagree change with Qt releases.
See for example lines 430 to 447 here:
http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/gui2/viewer/documentview.py
In short, it's a crapshoot.
Kovid.
On Thu, Jan 12, 2012 at 04:28:17PM -0800, James Polk wrote:
>
>
> Greetings All,
>
> We've uncovered what appears to be a very unfortunate bug in QWebKit...
> If it is indeed a bug, we can't tell _where_ the bug is originating from..
> .is it a Qt-bug? PyQt? We're on Qt 4.7,..could it be fixed in 4.8? (Env info below)
>
>
> Essentially what's happening,...is that there is a difference between the data
> that is returned via JavaScript method vs. DOM method. We're trying to decide
> which one to use, this issue isn't helping, lol...
>
> When you run the program,...a textField and two buttons are displayed.
> 1. In the textField is "John".
> 2. Hitting Button1 calls a decorator pyqtslot/function that changes the textField to "Mary".
> 3. Hitting Button2 calls a different decorator pyqtslot/function that queries the textField in two ways,
> one JavaScript, one via DOM.
>
> 4. JavaScript returns "Mary"
> DOM returns "John"
>
> which one's correct?....
>
> (1011)% p test-form.py
> Defaults button:
> Submit button:
> Value of Name: field according to javascript: Mary
> Value of Name: field according to DOM: John
>
> Here are the decorator slot/functions in question:
>
>
> @QtCore.pyqtSlot()
> def SetDefault(self):
> print "Defaults button:"
>
> self.ui.webView.page().mainFrame().evaluateJavaScript("""document.thisForm.name.value = "Mary";""")
>
>
>
> @QtCore.pyqtSlot(str)
> def SubmitButton(self,name_via_javascript):
> print " Submit button:"
>
> frame = self.ui.webView.page().mainFrame()
> name_via_dom = frame.findFirstElement("#nameId").attribute("value")
> print " Value of Name: field according to javascript: " + name_via_javascript
> print " Value of Name: field according to Python/DOM: " + name_via_dom
>
>
>
> If anybody can shed any light on this...and/or has any thoughts or suggestions, we're all ears ;-)
>
> (Btw,..our test-form.py is a heavily edited version of the distribution example file "formextractor")
>
>
> I whittled down the phenomena to two pretty small test files to illustrate the problem..
>
> Attached as a zipfile....one file is .py and the other one is .html
>
>
> Environment,..
>
> OSX Lion 10.7.2
>
> Python 2.7.2
> Qt 4.7.4
> Sip 4.13
> PyQt 4.8.6
>
>
> Thank you very much,
> Jim
>
>
> !DSPAM:3,4f0f7ac816201166415380!
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:3,4f0f7ac816201166415380!
--
_____________________________________
Dr. Kovid Goyal
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120113/06936c63/attachment.pgp>
More information about the PyQt
mailing list