add new commane clear-cookies; select text on testgui sets an expectation
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include <QProcess>
|
||||
#include <QMouseEvent>
|
||||
#include <QRegularExpression>
|
||||
#include <QNetworkCookieJar>
|
||||
#include <QNetworkCookie>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
@@ -2344,7 +2346,7 @@ class Echo: public Command {
|
||||
log(script->replacevars(_text));
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
private:
|
||||
QString _text;
|
||||
};
|
||||
|
||||
@@ -2378,6 +2380,42 @@ class OfflineStoragePath: public Command {
|
||||
QString _path;
|
||||
};
|
||||
|
||||
class ClearCookies: public Command {
|
||||
public:
|
||||
QString tag() const {
|
||||
return "clear-cookies";
|
||||
}
|
||||
QString description() const {
|
||||
return
|
||||
tag()+" <url>"
|
||||
"\n\n"
|
||||
"Clear all cookies of given URL <url>, or of the current URL if no"
|
||||
" <url> is specified.";
|
||||
}
|
||||
QString command() const {
|
||||
return tag()+(_url.isEmpty()?"":" "+_url);
|
||||
}
|
||||
std::shared_ptr<Command> parse(Script*, QString args,
|
||||
QStringList&, QString, int, int) {
|
||||
std::shared_ptr<ClearCookies> cmd(new ClearCookies());
|
||||
if (args.size()) cmd->_url = args;
|
||||
return cmd;
|
||||
}
|
||||
bool execute(Script* script, QWebFrame* frame) {
|
||||
Logger log(this, script);
|
||||
QString url(_url);
|
||||
if (url.isEmpty()) url = frame->url().toString();
|
||||
QNetworkCookieJar* cookies = frame->page()->networkAccessManager()->cookieJar();
|
||||
Q_FOREACH(QNetworkCookie cookie, cookies->cookiesForUrl(url)) {
|
||||
log("delete cookie "+cookie.name());
|
||||
cookies->deleteCookie(cookie);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
QString _url;
|
||||
};
|
||||
|
||||
/* Template:
|
||||
class : public Command {
|
||||
public:
|
||||
@@ -2508,6 +2546,7 @@ inline void Script::initPrototypes() {
|
||||
add(new For);
|
||||
add(new Echo);
|
||||
add(new OfflineStoragePath);
|
||||
add(new ClearCookies);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -351,7 +351,13 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
|
||||
// is important, but the text that will be typed
|
||||
_typing = true;
|
||||
} else {
|
||||
appendCommand("click "+map(selected));
|
||||
if (_web->page()->selectedText() != "")
|
||||
// user has selected a text, append a check
|
||||
appendCommand("expect "+map(selected)
|
||||
+" -> "+_web->page()->selectedText());
|
||||
else
|
||||
// user has clicked without selection, append a click
|
||||
appendCommand("click "+map(selected));
|
||||
}
|
||||
} else {
|
||||
appendCommand("# click, but where?");
|
||||
|
Reference in New Issue
Block a user