summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebKit/qt/tests/qwebelement
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@nokia.com>2009-09-29 10:36:30 (GMT)
committerJocelyn Turcotte <jocelyn.turcotte@nokia.com>2009-09-29 10:41:41 (GMT)
commitbb917438a942da68e065a4810b29697a1340cdd6 (patch)
tree84f2f55fda1d2895bc2d0f10529fcdbbef76adef /src/3rdparty/webkit/WebKit/qt/tests/qwebelement
parentf234e50f3d29c4a7dfefd89d537787b1fc327eb2 (diff)
downloadQt-bb917438a942da68e065a4810b29697a1340cdd6.zip
Qt-bb917438a942da68e065a4810b29697a1340cdd6.tar.gz
Qt-bb917438a942da68e065a4810b29697a1340cdd6.tar.bz2
Updated WebKit from /home/joce/dev/qtwebkit/ to qtwebkit-4.6-snapshot-29092009-2 ( 999c28aa9f6ad9e0d6a26a794220e1cb45408a97 )
Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-09-28 HJK Reviewed by Simon Hausmann. Compile fix with namespaced Qt. * Api/qwebinspector_p.h: 2009-09-27 Joe Ligman <joseph.ligman@mindspring.com> Reviewed by Simon Hausmann. [Qt] Adding API setFocus and hasFocus to QWebElement. This API is needed for clients that want to check/set the focus node of the document. https://bugs.webkit.org/show_bug.cgi?id=29682 * Api/qwebelement.cpp: (QWebElement::hasFocus): (QWebElement::setFocus): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::hasSetFocus): 2009-09-25 Csaba Osztrogonac <oszi@inf.u-szeged.hu> Reviewed by Simon Hausmann. [Qt] Make tst_qwebframe work if Qt built without SSL support https://bugs.webkit.org/show_bug.cgi?id=29735 * tests/qwebframe/tst_qwebframe.cpp: Missing #ifndef blocks added. 2009-09-24 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Update QWebElement API to remove script related methods. QWebElement::evaluateScript is the only one kept, these are removed to postpone most of the QtWebKit<->JavaScript API design after 4.6. https://bugs.webkit.org/show_bug.cgi?id=29708 * Api/qwebelement.cpp: * Api/qwebelement.h: Methods removed: - QWebElement::callFunction - QWebElement::functions - QWebElement::scriptableProperty - QWebElement::setScriptableProperty - QWebElement::scriptableProperties * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateScript): 2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Rename QWebElement::evaluateScript to QWebElement::evaluateJavaScript. https://bugs.webkit.org/show_bug.cgi?id=29709 * Api/qwebelement.cpp: (QWebElement::evaluateJavaScript): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateJavaScript): 2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Update the stypeProperty API of QWebElement. https://bugs.webkit.org/show_bug.cgi?id=29711 * Api/qwebelement.cpp: (QWebElement::styleProperty): - Merge the stypeProperty and the computedStyleProperty methods - Remove the default value for the style resolving enum - Rename ResolveRule to StyleResolveStrategy (QWebElement::setStyleProperty): - Remove the priority argument since it is possible to control the behaviour by adding !important or removing in the value. * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::style): (tst_QWebElement::computedStyle): * tests/qwebframe/tst_qwebframe.cpp: 2009-09-24 Jon Honeycutt <jhoneycutt@apple.com> Reviewed by Alice Liu. * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): Pass 0 for new Page constructor argument.
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt/tests/qwebelement')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp163
1 files changed, 55 insertions, 108 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index 0819a3a..00783d1 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -71,15 +71,11 @@ private slots:
void classes();
void namespaceURI();
void foreachManipulation();
- void evaluateScript();
- void callFunction();
- void callFunctionSubmitForm();
- void functionNames();
+ void evaluateJavaScript();
void documentElement();
void frame();
void style();
void computedStyle();
- void properties();
void appendAndPrepend();
void insertBeforeAndAfter();
void remove();
@@ -90,6 +86,7 @@ private slots:
void nullSelect();
void firstChildNextSibling();
void lastChildPreviousSibling();
+ void hasSetFocus();
private:
QWebView* m_view;
@@ -282,69 +279,31 @@ void tst_QWebElement::foreachManipulation()
QCOMPARE(body.findAll("div").count(), 4);
}
-void tst_QWebElement::evaluateScript()
+void tst_QWebElement::evaluateJavaScript()
{
QVariant result;
m_mainFrame->setHtml("<body><p>test");
QWebElement para = m_mainFrame->findFirstElement("p");
- result = para.evaluateScript("this.tagName");
+ result = para.evaluateJavaScript("this.tagName");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::String);
QCOMPARE(result.toString(), QLatin1String("P"));
- QVERIFY(para.functions().contains("hasAttributes"));
- result = para.evaluateScript("this.hasAttributes()");
+ result = para.evaluateJavaScript("this.hasAttributes()");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::Bool);
QVERIFY(!result.toBool());
- para.evaluateScript("this.setAttribute('align', 'left');");
+ para.evaluateJavaScript("this.setAttribute('align', 'left');");
QCOMPARE(para.attribute("align"), QLatin1String("left"));
- result = para.evaluateScript("this.hasAttributes()");
+ result = para.evaluateJavaScript("this.hasAttributes()");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::Bool);
QVERIFY(result.toBool());
}
-void tst_QWebElement::callFunction()
-{
- m_mainFrame->setHtml("<body><p>test");
- QWebElement body = m_mainFrame->documentElement();
- QVERIFY(body.functions().contains("hasChildNodes"));
- QVariant result = body.callFunction("hasChildNodes");
- QVERIFY(result.isValid());
- QVERIFY(result.type() == QVariant::Bool);
- QVERIFY(result.toBool());
-
- body.callFunction("setAttribute", QVariantList() << "foo" << "bar");
- QCOMPARE(body.attribute("foo"), QString("bar"));
-}
-
-void tst_QWebElement::callFunctionSubmitForm()
-{
- m_mainFrame->setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>"
- "<input type='text'><input type='submit'></form></body></html>"), QUrl());
-
- QWebElement form = m_mainFrame->documentElement().findAll("form").at(0);
- QVERIFY(form.functions().contains("submit"));
- QVERIFY(!form.isNull());
- form.callFunction("submit");
-
- waitForSignal(m_page, SIGNAL(loadFinished(bool)));
- QCOMPARE(m_mainFrame->url().toString(), QString("data:text/html,foo?"));
-}
-
-void tst_QWebElement::functionNames()
-{
- m_mainFrame->setHtml("<body><p>Test");
-
- QWebElement body = m_mainFrame->documentElement();
-
- QVERIFY(body.functions().contains("setAttribute"));
-}
-
void tst_QWebElement::documentElement()
{
m_mainFrame->setHtml("<body><p>Test");
@@ -398,27 +357,27 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html);
QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QVERIFY(p.styleProperty("cursor").isEmpty());
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty());
p.setStyleProperty("color", "red");
p.setStyleProperty("cursor", "auto");
- QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("yellow"));
- QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("yellow"));
+ QCOMPARE(p.styleProperty("cursor", QWebElement::InlineStyle), QLatin1String("auto"));
p.setStyleProperty("color", "green !important");
- QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green"));
p.setStyleProperty("color", "blue");
- QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green"));
- p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ p.setStyleProperty("color", "blue !important");
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html2 = "<head>"
"<style type='text/css'>"
@@ -434,8 +393,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html2);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html3 = "<head>"
"<style type='text/css'>"
@@ -451,8 +410,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html3);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html5 = "<head>"
"<style type='text/css'>"
@@ -468,8 +427,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html5);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String(""));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red"));
QString html6 = "<head>"
"<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
@@ -489,8 +448,8 @@ void tst_QWebElement::style()
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black"));
QString html7 = "<head>"
"<style type='text/css'>"
@@ -507,15 +466,15 @@ void tst_QWebElement::style()
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black"));
QString html8 = "<body><p>some text</p></body>";
m_mainFrame->setHtml(html8);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String(""));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String(""));
}
void tst_QWebElement::computedStyle()
@@ -524,47 +483,16 @@ void tst_QWebElement::computedStyle()
m_mainFrame->setHtml(html);
QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("auto"));
- QVERIFY(!p.computedStyleProperty("cursor").isEmpty());
- QVERIFY(p.styleProperty("cursor").isEmpty());
+ QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("auto"));
+ QVERIFY(!p.styleProperty("cursor", QWebElement::ComputedStyle).isEmpty());
+ QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty());
p.setStyleProperty("cursor", "text");
p.setStyleProperty("color", "red");
- QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("text"));
- QCOMPARE(p.computedStyleProperty("color"), QLatin1String("rgb(255, 0, 0)"));
- QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
-}
-
-void tst_QWebElement::properties()
-{
- m_mainFrame->setHtml("<body><form><input type=checkbox id=ourcheckbox checked=true>");
-
- QWebElement checkBox = m_mainFrame->findFirstElement("#ourcheckbox");
- QVERIFY(!checkBox.isNull());
-
- QVERIFY(checkBox.scriptableProperties().contains("checked"));
-
- QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(true));
- checkBox.setScriptableProperty("checked", false);
- QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(false));
-
- QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
-
- checkBox.setScriptableProperty("non_existant", "test");
-
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant("test"));
- QVERIFY(checkBox.scriptableProperties().contains("non_existant"));
-
- // removing scriptableProperties is currently not supported. We should look into this
- // and consider the option of just allowing through the QtScript API only.
-#if 0
- checkBox.setScriptableProperty("non_existant", QVariant());
-
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
- QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
-#endif
+ QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("text"));
+ QCOMPARE(p.styleProperty("color", QWebElement::ComputedStyle), QLatin1String("rgb(255, 0, 0)"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red"));
}
void tst_QWebElement::appendAndPrepend()
@@ -878,5 +806,24 @@ void tst_QWebElement::lastChildPreviousSibling()
QVERIFY(p.previousSibling().isNull());
}
+void tst_QWebElement::hasSetFocus()
+{
+ m_mainFrame->setHtml("<html><body>" \
+ "<input type='text' id='input1'/>" \
+ "<br>"\
+ "<input type='text' id='input2'/>" \
+ "</body></html>");
+
+ QList<QWebElement> inputs = m_mainFrame->documentElement().findAll("input");
+ QWebElement input1 = inputs.at(0);
+ input1.setFocus();
+ QVERIFY(input1.hasFocus());
+
+ QWebElement input2 = inputs.at(1);
+ input2.setFocus();
+ QVERIFY(!input1.hasFocus());
+ QVERIFY(input2.hasFocus());
+}
+
QTEST_MAIN(tst_QWebElement)
#include "tst_qwebelement.moc"