[PyQt] Bug in QWebKit?...

James Polk jpolk5001 at yahoo.com
Fri Jan 13 00:28:17 GMT 2012



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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120112/1a66f795/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: webkit_bug.zip
Type: application/zip
Size: 1854 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120112/1a66f795/attachment.zip>


More information about the PyQt mailing list