Title: [125029] trunk/Source/WebKit/qt
- Revision
- 125029
- Author
- [email protected]
- Date
- 2012-08-08 06:13:43 -0700 (Wed, 08 Aug 2012)
Log Message
[Qt] Add unit test for QObject bindings for scriptable plugins
https://bugs.webkit.org/show_bug.cgi?id=93462
Reviewed by Kenneth Rohde Christiansen.
The bindings code is subject to refactoring in the future, so added a unit test to verify that
accessing an embedded QWidget from _javascript_ goes through the QObject bindings.
* tests/qobjectbridge/tst_qobjectbridge.cpp:
(tst_QObjectBridge):
(TestPluginWidget):
(TestPluginWidget::TestPluginWidget):
(TestPluginWidget::slotWithReturnValue):
(TestWebPage):
(TestWebPage::TestWebPage):
(TestWebPage::createPlugin):
(tst_QObjectBridge::scriptablePlugin):
Modified Paths
Diff
Modified: trunk/Source/WebKit/qt/ChangeLog (125028 => 125029)
--- trunk/Source/WebKit/qt/ChangeLog 2012-08-08 13:11:54 UTC (rev 125028)
+++ trunk/Source/WebKit/qt/ChangeLog 2012-08-08 13:13:43 UTC (rev 125029)
@@ -1,3 +1,23 @@
+2012-08-08 Simon Hausmann <[email protected]>
+
+ [Qt] Add unit test for QObject bindings for scriptable plugins
+ https://bugs.webkit.org/show_bug.cgi?id=93462
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The bindings code is subject to refactoring in the future, so added a unit test to verify that
+ accessing an embedded QWidget from _javascript_ goes through the QObject bindings.
+
+ * tests/qobjectbridge/tst_qobjectbridge.cpp:
+ (tst_QObjectBridge):
+ (TestPluginWidget):
+ (TestPluginWidget::TestPluginWidget):
+ (TestPluginWidget::slotWithReturnValue):
+ (TestWebPage):
+ (TestWebPage::TestWebPage):
+ (TestWebPage::createPlugin):
+ (tst_QObjectBridge::scriptablePlugin):
+
2012-08-07 Simon Hausmann <[email protected]>
Unreviewed trivial fix: Missed HAVE_QT5 removal as part of r124879
Modified: trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp (125028 => 125029)
--- trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp 2012-08-08 13:11:54 UTC (rev 125028)
+++ trunk/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp 2012-08-08 13:13:43 UTC (rev 125029)
@@ -652,6 +652,7 @@
void qObjectWrapperWithSameIdentity();
void introspectQtMethods_data();
void introspectQtMethods();
+ void scriptablePlugin();
private:
QString evalJS(const QString& s)
@@ -2181,5 +2182,47 @@
QCOMPARE(evalJS("myWebElementSlotObject.tagName"), QString("BODY"));
}
+class TestPluginWidget : public QWidget {
+ Q_OBJECT
+public:
+ TestPluginWidget() { }
+
+public slots:
+ int slotWithReturnValue() { return 42; }
+};
+
+class TestWebPage : public QWebPage {
+ Q_OBJECT
+public:
+ TestWebPage(QObject* parent = 0)
+ : QWebPage(parent)
+ , creationCount(0)
+ { }
+
+ int creationCount;
+
+protected:
+ virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&)
+ {
+ creationCount++;
+ return new TestPluginWidget;
+ }
+};
+
+void tst_QObjectBridge::scriptablePlugin()
+{
+ QWebView view;
+ TestWebPage* page = new TestWebPage;
+ view.setPage(page);
+ page->setParent(&view);
+ view.settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+
+ page->mainFrame()->setHtml("<object width=100 height=100 type=\"application/x-qt-plugin\"></object>");
+ QCOMPARE(page->creationCount, 1);
+
+ QVariant result = page->mainFrame()->evaluateJavaScript("document.querySelector(\"object\").slotWithReturnValue()");
+ QCOMPARE(result.toString(), QLatin1String("42"));
+}
+
QTEST_MAIN(tst_QObjectBridge)
#include "tst_qobjectbridge.moc"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes