aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtWebKit/shouldInterruptjavascript_test.py
blob: b624220dfce0ffd578285d2b0e3d61986d280963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
from PySide import QtCore, QtWebKit

from helper import UsesQApplication

class QWebPageHeadless(QtWebKit.QWebPage):
    # FIXME: This is not working, the slot is not overriden!
    # http://doc.qt.nokia.com/4.7-snapshot/qwebpage.html#shouldInterruptJavaScript
    @QtCore.Slot()
    def shouldInterruptJavaScript(self):
        self._interrupted = True
        QtCore.QTimer.singleShot(300, self._app.quit)
        return True

class TestSlotOverride(UsesQApplication):
    def testFunctionCall(self):
        page = QWebPageHeadless()
        page._interrupted = False
        page._app = self.app
        page.mainFrame().setHtml('<script>while(1);</script>')
        self.app.exec_()
        self.assertTrue(page._interrupted)

if __name__ == '__main__':
    unittest.main()