Changeset 49440 in webkit
- Timestamp:
- Oct 12, 2009 8:05:59 AM (15 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/ChangeLog
r49397 r49440 1 2009-10-12 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> 2 3 Reviewed by Simon Hausmann. 4 5 QWebPage's createViewlessPlugin autotest crash fix. 6 7 It is possible that plugins that are QWidgets or QGraphicsWidgets 8 are created before a view has been assigned to a QWebPage. The 9 plug-ins won't be fully functional, as by design, they should 10 visualise something, but they won't crash and will stay in memory. 11 12 An autotest that covers this use-case, is included. 13 14 https://bugs.webkit.org/show_bug.cgi?id=30118 15 16 * WebCoreSupport/FrameLoaderClientQt.cpp: 17 (WebCore::FrameLoaderClientQt::createPlugin): 18 * tests/qwebpage/tst_qwebpage.cpp: 19 (PluginTrackedPageWidget::PluginTrackedPageWidget): 20 (PluginTrackedPageGraphicsWidget::PluginTrackedPageGraphicsWidget): 21 (PluginTrackedPageGraphicsWidget::createPlugin): 22 (tst_QWebPage::destroyPlugin): 23 (tst_QWebPage::createViewlessPlugin): 24 1 25 2009-10-09 Joe Ligman <joseph.ligman@nokia.com> 2 26 -
trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
r49284 r49440 1231 1231 QWidget* widget = qobject_cast<QWidget*>(object); 1232 1232 if (widget) { 1233 QWidget* parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); 1234 if (parentWidget) 1235 widget->setParent(parentWidget); 1233 QWidget* parentWidget; 1234 if (m_webFrame->page()->d->client) 1235 parentWidget = qobject_cast<QWidget*>(m_webFrame->page()->d->client->pluginParent()); 1236 else 1237 parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. 1238 widget->setParent(parentWidget); 1236 1239 RefPtr<QtPluginWidget> w = adoptRef(new QtPluginWidget()); 1237 1240 w->setPlatformWidget(widget); … … 1243 1246 QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object); 1244 1247 if (graphicsWidget) { 1248 QGraphicsObject* parentWidget; 1249 if (m_webFrame->page()->d->client) 1250 parentWidget = qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()); 1251 else 1252 parentWidget = 0; // The plug-in won't be fully functional because the QWebView doesn't exist. 1245 1253 graphicsWidget->hide(); 1246 graphicsWidget->setParentItem( qobject_cast<QGraphicsObject*>(m_webFrame->page()->d->client->pluginParent()));1254 graphicsWidget->setParentItem(parentWidget); 1247 1255 RefPtr<QtPluginGraphicsWidget> w = QtPluginGraphicsWidget::create(graphicsWidget); 1248 1256 // Make sure it's invisible until properly placed into the layout -
trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
r49397 r49440 24 24 #include <qwebpage.h> 25 25 #include <qwidget.h> 26 #include <QGraphicsWidget> 26 27 #include <qwebview.h> 27 28 #include <qwebframe.h> … … 102 103 void database(); 103 104 void createPlugin(); 105 void destroyPlugin_data(); 104 106 void destroyPlugin(); 107 void createViewlessPlugin_data(); 105 108 void createViewlessPlugin(); 106 109 void multiplePageGroupsAndLocalStorage(); … … 622 625 } 623 626 624 class PluginTrackedPage : public QWebPage 625 { 627 628 // Standard base class for template PluginTracerPage. In tests it is used as interface. 629 class PluginCounterPage : public QWebPage { 626 630 public: 627 628 int count; 629 QPointer<QWidget> widget; 630 631 PluginTrackedPage(QWidget *parent = 0) : QWebPage(parent), count(0) { 631 int m_count; 632 QPointer<QObject> m_widget; 633 PluginCounterPage(QObject* parent = 0) : QWebPage(parent), m_count(0), m_widget(0) 634 { 632 635 settings()->setAttribute(QWebSettings::PluginsEnabled, true); 633 636 } 634 635 virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) {636 count++;637 QWidget *w = new QWidget;638 widget = w;639 return w;640 }641 637 }; 642 638 639 template<class T> 640 class PluginTracerPage : public PluginCounterPage { 641 public: 642 PluginTracerPage(QObject* parent = 0) : PluginCounterPage(parent) {} 643 virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) 644 { 645 m_count++; 646 return m_widget = new T(); 647 } 648 }; 649 650 class PluginFactory { 651 public: 652 enum FactoredType {QWidgetType, QGraphicsWidgetType}; 653 static PluginCounterPage* create(FactoredType type, QObject* parent = 0) 654 { 655 PluginCounterPage* result = 0; 656 switch (type) { 657 case QWidgetType: 658 result = new PluginTracerPage<QWidget>(parent); 659 break; 660 case QGraphicsWidgetType: 661 result = new PluginTracerPage<QGraphicsWidget>(parent); 662 break; 663 default: {/*Oops*/}; 664 } 665 return result; 666 } 667 668 static void prepareTestData() 669 { 670 QTest::addColumn<int>("type"); 671 QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType; 672 QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType; 673 } 674 }; 675 676 void tst_QWebPage::destroyPlugin_data() 677 { 678 PluginFactory::prepareTestData(); 679 } 680 643 681 void tst_QWebPage::destroyPlugin() 644 682 { 645 PluginTrackedPage* page = new PluginTrackedPage(m_view); 683 QFETCH(int, type); 684 PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view); 646 685 m_view->setPage(page); 647 686 … … 649 688 QString content("<html><body><object type=\"application/x-qt-plugin\" classid=\"QProgressBar\"></object></body></html>"); 650 689 m_view->setHtml(content); 651 QVERIFY(page-> widget != 0);652 QCOMPARE(page-> count, 1);690 QVERIFY(page->m_widget); 691 QCOMPARE(page->m_count, 1); 653 692 654 693 // navigate away, the plugin widget should be destructed 655 694 m_view->setHtml("<html><body>Hi</body></html>"); 656 695 QTestEventLoop::instance().enterLoop(1); 657 QVERIFY(page->widget == 0); 696 QVERIFY(!page->m_widget); 697 } 698 699 void tst_QWebPage::createViewlessPlugin_data() 700 { 701 PluginFactory::prepareTestData(); 658 702 } 659 703 660 704 void tst_QWebPage::createViewlessPlugin() 661 705 { 662 PluginTrackedPage* page = new PluginTrackedPage; 706 QFETCH(int, type); 707 PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type); 663 708 QString content("<html><body><object type=\"application/x-qt-plugin\" classid=\"QProgressBar\"></object></body></html>"); 664 709 page->mainFrame()->setHtml(content); 665 QCOMPARE(page-> count, 1);666 QVERIFY(page-> widget != 0);710 QCOMPARE(page->m_count, 1); 711 QVERIFY(page->m_widget); 667 712 delete page; 713 668 714 } 669 715
Note: See TracChangeset
for help on using the changeset viewer.