diff options
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp')
-rw-r--r-- | src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 1f97e69..85d4b60 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -80,7 +80,8 @@ private slots: void modified(); void contextMenuCrash(); void database(); - void createPlugin(); + void createPluginWithPluginsEnabled(); + void createPluginWithPluginsDisabled(); void destroyPlugin_data(); void destroyPlugin(); void createViewlessPlugin_data(); @@ -518,27 +519,20 @@ protected: } }; -void tst_QWebPage::createPlugin() +static void createPlugin(QWebView *view) { - QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); + QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool))); - PluginPage* newPage = new PluginPage(m_view); - m_view->setPage(newPage); + PluginPage* newPage = new PluginPage(view); + view->setPage(newPage); - // plugins not enabled by default, so the plugin shouldn't be loaded - m_view->setHtml(QString("<html><body><object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/></body></html>")); + // type has to be application/x-qt-plugin + view->setHtml(QString("<html><body><object type='application/x-foobarbaz' classid='pushbutton' id='mybutton'/></body></html>")); QTRY_COMPARE(loadSpy.count(), 1); QCOMPARE(newPage->calls.count(), 0); - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - - // type has to be application/x-qt-plugin - m_view->setHtml(QString("<html><body><object type='application/x-foobarbaz' classid='pushbutton' id='mybutton'/></body></html>")); + view->setHtml(QString("<html><body><object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/></body></html>")); QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(newPage->calls.count(), 0); - - m_view->setHtml(QString("<html><body><object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/></body></html>")); - QTRY_COMPARE(loadSpy.count(), 3); QCOMPARE(newPage->calls.count(), 1); { PluginPage::CallInfo ci = newPage->calls.takeFirst(); @@ -569,11 +563,11 @@ void tst_QWebPage::createPlugin() QCOMPARE(newPage->mainFrame()->evaluateJavaScript("mybutton.clicked.toString()").toString(), QString::fromLatin1("function clicked() {\n [native code]\n}")); - m_view->setHtml(QString("<html><body><table>" + view->setHtml(QString("<html><body><table>" "<tr><object type='application/x-qt-plugin' classid='lineedit' id='myedit'/></tr>" "<tr><object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/></tr>" "</table></body></html>"), QUrl("http://foo.bar.baz")); - QTRY_COMPARE(loadSpy.count(), 4); + QTRY_COMPARE(loadSpy.count(), 3); QCOMPARE(newPage->calls.count(), 2); { PluginPage::CallInfo ci = newPage->calls.takeFirst(); @@ -605,14 +599,22 @@ void tst_QWebPage::createPlugin() QVERIFY(ci.returnValue != 0); QVERIFY(ci.returnValue->inherits("QPushButton")); } +} - m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, false); - - m_view->setHtml(QString("<html><body><object type='application/x-qt-plugin' classid='pushbutton' id='mybutton'/></body></html>")); - QTRY_COMPARE(loadSpy.count(), 5); - QCOMPARE(newPage->calls.count(), 0); +void tst_QWebPage::createPluginWithPluginsEnabled() +{ + m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); + createPlugin(m_view); } +void tst_QWebPage::createPluginWithPluginsDisabled() +{ + // Qt Plugins should be loaded by QtWebKit even when PluginsEnabled is + // false. The client decides whether a Qt plugin is enabled or not when + // it decides whether or not to instantiate it. + m_view->settings()->setAttribute(QWebSettings::PluginsEnabled, false); + createPlugin(m_view); +} // Standard base class for template PluginTracerPage. In tests it is used as interface. class PluginCounterPage : public QWebPage { |