Commit 2a5c9a3b authored by eric@webkit.org's avatar eric@webkit.org

2009-10-02 Jakub Wieczorek <faw217@gmail.com>

        Reviewed by Simon Hausmann.

        [Qt] Implement layoutTestController.overridePreference().
        https://bugs.webkit.org/show_bug.cgi?id=29970

        * DumpRenderTree/qt/DumpRenderTree.cpp:
        (WebCore::WebPage::WebPage):
        (WebCore::WebPage::resetSettings):
        (WebCore::DumpRenderTree::resetToConsistentStateBeforeTesting):
        * DumpRenderTree/qt/jsobjects.cpp:
        (LayoutTestController::reset):
        (LayoutTestController::setPrivateBrowsingEnabled):
        (LayoutTestController::setPopupBlockingEnabled):
        (LayoutTestController::overridePreference):
        * DumpRenderTree/qt/jsobjects.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49024 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d6e83d82
2009-10-02 Jakub Wieczorek <faw217@gmail.com>
Reviewed by Simon Hausmann.
[Qt] Implement layoutTestController.overridePreference().
https://bugs.webkit.org/show_bug.cgi?id=29970
* DumpRenderTree/qt/DumpRenderTree.cpp:
(WebCore::WebPage::WebPage):
(WebCore::WebPage::resetSettings):
(WebCore::DumpRenderTree::resetToConsistentStateBeforeTesting):
* DumpRenderTree/qt/jsobjects.cpp:
(LayoutTestController::reset):
(LayoutTestController::setPrivateBrowsingEnabled):
(LayoutTestController::setPopupBlockingEnabled):
(LayoutTestController::overridePreference):
* DumpRenderTree/qt/jsobjects.h:
2009-10-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -84,6 +84,8 @@ public:
bool javaScriptConfirm(QWebFrame *frame, const QString& msg);
bool javaScriptPrompt(QWebFrame *frame, const QString& msg, const QString& defaultValue, QString* result);
void resetSettings();
public slots:
bool shouldInterruptJavaScript() { return false; }
......@@ -104,15 +106,21 @@ private:
WebPage::WebPage(QWidget *parent, DumpRenderTree *drt)
: QWebPage(parent), m_drt(drt)
{
settings()->setFontSize(QWebSettings::MinimumFontSize, 5);
settings()->setFontSize(QWebSettings::MinimumLogicalFontSize, 5);
settings()->setFontSize(QWebSettings::DefaultFontSize, 16);
settings()->setFontSize(QWebSettings::DefaultFixedFontSize, 13);
settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
settings()->setAttribute(QWebSettings::PluginsEnabled, true);
settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
QWebSettings* globalSettings = QWebSettings::globalSettings();
globalSettings->setFontSize(QWebSettings::MinimumFontSize, 5);
globalSettings->setFontSize(QWebSettings::MinimumLogicalFontSize, 5);
globalSettings->setFontSize(QWebSettings::DefaultFontSize, 16);
globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13);
globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
globalSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false);
connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
this, SLOT(setViewGeometry(const QRect & )));
......@@ -120,6 +128,20 @@ WebPage::WebPage(QWidget *parent, DumpRenderTree *drt)
setPluginFactory(new TestPlugin(this));
}
void WebPage::resetSettings()
{
// After each layout test, reset the settings that may have been changed by
// layoutTestController.overridePreference() or similar.
settings()->resetFontSize(QWebSettings::DefaultFontSize);
settings()->resetAttribute(QWebSettings::JavascriptCanOpenWindows);
settings()->resetAttribute(QWebSettings::JavascriptEnabled);
settings()->resetAttribute(QWebSettings::PrivateBrowsingEnabled);
settings()->resetAttribute(QWebSettings::LinksIncludedInFocusChain);
settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled);
}
QWebPage *WebPage::createWindow(QWebPage::WebWindowType)
{
return m_drt->createWindow();
......@@ -252,6 +274,8 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting()
m_page->blockSignals(false);
m_page->mainFrame()->setZoomFactor(1.0);
static_cast<WebPage*>(m_page)->resetSettings();
qt_drt_clearFrameName(m_page->mainFrame());
WorkQueue::shared()->clear();
......
......@@ -134,7 +134,6 @@ void LayoutTestController::reset()
m_waitForPolicy = false;
qt_dump_editing_callbacks(false);
qt_dump_resource_load_callbacks(false);
QWebSettings::globalSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
}
void LayoutTestController::processWork()
......@@ -288,12 +287,12 @@ void LayoutTestController::setFixedContentsSize(int width, int height)
void LayoutTestController::setPrivateBrowsingEnabled(bool enable)
{
QWebSettings::globalSettings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable);
m_drt->webPage()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable);
}
void LayoutTestController::setPopupBlockingEnabled(bool enable)
{
QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable);
m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable);
}
bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString &animationName,
......@@ -355,6 +354,20 @@ void LayoutTestController::waitForPolicyDelegate()
waitUntilDone();
}
void LayoutTestController::overridePreference(const QString& name, const QVariant& value)
{
QWebSettings* settings = m_topLoadingFrame->page()->settings();
if (name == "WebKitJavaScriptEnabled")
settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool());
else if (name == "WebKitTabToLinksPreferenceKey")
settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool());
else if (name == "WebKitOfflineWebApplicationCacheEnabled")
settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool());
else if (name == "WebKitDefaultFontSize")
settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt());
}
EventSender::EventSender(QWebPage *parent)
: QObject(parent)
{
......
......@@ -109,6 +109,7 @@ public slots:
void clearAllDatabases();
void waitForPolicyDelegate();
void overridePreference(const QString& name, const QVariant& value);
private slots:
void processWork();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment