Changeset 53847 in webkit


Ignore:
Timestamp:
Jan 26, 2010 2:40:58 AM (14 years ago)
Author:
Simon Hausmann
Message:

WebCore: [Qt] JavaScript prompt is currently broken.
https://bugs.webkit.org/show_bug.cgi?id=30914

Patch by Holger Hans Peter Freyther <zecke@selfish.org> on 2010-01-26
Reviewed by Simon Hausmann.

Remove the manual test case in favor of an automated
test case in WebKit/qt/tests/qwebpage.

  • manual-tests/qt/java-script-prompt.html: Removed.

WebKit/qt: [Qt] JavaScript prompt is currently broken
https://bugs.webkit.org/show_bug.cgi?id=30914

Patch by Holger Hans Peter Freyther <zecke@selfish.org> on 2010-01-26
Reviewed by Simon Hausmann.

In r52152 a patch was landed to convert a null QString
to an empty WebCore::String in case the prompt was accepted
but the default implementation returned the null QString.

The patch tried to avoid assign to result twice and
was not checking the QString if it is null but the default
value. This lead to always returning an empty string on
successful prompts. Fix it by checking the variable 'x'
for isNull.

The manual test case used didn't cover the case of non
empty input, replace it with an automatic test case that
should cover all cases.

  • WebCoreSupport/ChromeClientQt.cpp:

(WebCore::ChromeClientQt::runJavaScriptPrompt): Fix the bug.

  • tests/qwebpage/tst_qwebpage.cpp: Add automatic test case

(JSPromptPage::JSPromptPage):
(JSPromptPage::javaScriptPrompt):
(tst_QWebPage::testJSPrompt):

Location:
trunk
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53846 r53847  
     12010-01-26  Holger Hans Peter Freyther  <zecke@selfish.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] JavaScript prompt is currently broken.
     6        https://bugs.webkit.org/show_bug.cgi?id=30914
     7
     8        Remove the manual test case in favor of an automated
     9        test case in WebKit/qt/tests/qwebpage.
     10
     11        * manual-tests/qt/java-script-prompt.html: Removed.
     12
    1132010-01-26  Pavel Feldman  <pfeldman@chromium.org>
    214
  • trunk/WebKit/qt/ChangeLog

    r53802 r53847  
     12010-01-26  Holger Hans Peter Freyther  <zecke@selfish.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] JavaScript prompt is currently broken
     6        https://bugs.webkit.org/show_bug.cgi?id=30914
     7
     8        In r52152 a patch was landed to convert a null QString
     9        to an empty WebCore::String in case the prompt was accepted
     10        but the default implementation returned the null QString.
     11
     12        The patch tried to avoid assign to result twice and
     13        was not checking the QString if it is null but the default
     14        value. This lead to always returning an empty string on
     15        successful prompts. Fix it by checking the variable 'x'
     16        for isNull.
     17
     18        The manual test case used didn't cover the case of non
     19        empty input, replace it with an automatic test case that
     20        should cover all cases.
     21
     22        * WebCoreSupport/ChromeClientQt.cpp:
     23        (WebCore::ChromeClientQt::runJavaScriptPrompt): Fix the bug.
     24        * tests/qwebpage/tst_qwebpage.cpp: Add automatic test case
     25        (JSPromptPage::JSPromptPage):
     26        (JSPromptPage::javaScriptPrompt):
     27        (tst_QWebPage::testJSPrompt):
     28
    1292010-01-25  Simon Hausmann  <hausmann@webkit.org>
    230
  • trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp

    r53618 r53847  
    292292    // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty
    293293    // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914.
    294     if (rc && result.isNull())
     294    if (rc && x.isNull())
    295295        result = String("");
    296296    else
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r53614 r53847  
    22    Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
    33    Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
     4    Copyright (C) 2010 Holger Hans Peter Freyther
    45
    56    This library is free software; you can redistribute it and/or
     
    109110
    110111    void originatingObjectInNetworkRequests();
     112    void testJSPrompt();
    111113
    112114private:
     
    17601762}
    17611763
     1764/**
     1765 * Test fixups for https://bugs.webkit.org/show_bug.cgi?id=30914
     1766 *
     1767 * From JS we test the following conditions.
     1768 *
     1769 *   OK     + QString() => SUCCESS, empty string (but not null)
     1770 *   OK     + "text"    => SUCCESS, "text"
     1771 *   CANCEL + QString() => CANCEL, null string
     1772 *   CANCEL + "text"    => CANCEL, null string
     1773 */
     1774class JSPromptPage : public QWebPage {
     1775    Q_OBJECT
     1776public:
     1777    JSPromptPage()
     1778    {}
     1779
     1780    bool javaScriptPrompt(QWebFrame* frame, const QString& msg, const QString& defaultValue, QString* result)
     1781    {
     1782        if (msg == QLatin1String("test1")) {
     1783            *result = QString();
     1784            return true;
     1785        } else if (msg == QLatin1String("test2")) {
     1786            *result = QLatin1String("text");
     1787            return true;
     1788        } else if (msg == QLatin1String("test3")) {
     1789            *result = QString();
     1790            return false;
     1791        } else if (msg == QLatin1String("test4")) {
     1792            *result = QLatin1String("text");
     1793            return false;
     1794        }
     1795
     1796        qFatal("Unknown msg.");
     1797        return QWebPage::javaScriptPrompt(frame, msg, defaultValue, result);
     1798    }
     1799};
     1800
     1801void tst_QWebPage::testJSPrompt()
     1802{
     1803    JSPromptPage page;
     1804    bool res;
     1805
     1806    // OK + QString()
     1807    res = page.mainFrame()->evaluateJavaScript(
     1808            "var retval = prompt('test1');"
     1809            "retval=='' && retval.length == 0;").toBool();
     1810    QVERIFY(res);
     1811
     1812    // OK + "text"
     1813    res = page.mainFrame()->evaluateJavaScript(
     1814            "var retval = prompt('test2');"
     1815            "retval=='text' && retval.length == 4;").toBool();
     1816    QVERIFY(res);
     1817
     1818    // Cancel + QString()
     1819    res = page.mainFrame()->evaluateJavaScript(
     1820            "var retval = prompt('test3');"
     1821            "retval===null;").toBool();
     1822    QVERIFY(res);
     1823
     1824    // Cancel + "text"
     1825    res = page.mainFrame()->evaluateJavaScript(
     1826            "var retval = prompt('test4');"
     1827            "retval===null;").toBool();
     1828    QVERIFY(res);
     1829}
     1830
    17621831QTEST_MAIN(tst_QWebPage)
    17631832#include "tst_qwebpage.moc"
Note: See TracChangeset for help on using the changeset viewer.