|
|
|
@ -845,11 +845,16 @@ class Script: public QObject { |
|
|
|
|
return _clicktype; |
|
|
|
|
} |
|
|
|
|
QString replacevars(QString txt) { |
|
|
|
|
for(QMap<QString, QString>::iterator it(_variables.begin()); |
|
|
|
|
for (QMap<QString, QString>::iterator it(_variables.begin()); |
|
|
|
|
it!=_variables.end(); ++it) |
|
|
|
|
txt.replace(it.key(), it.value(), Qt::CaseSensitive); |
|
|
|
|
return txt; |
|
|
|
|
} |
|
|
|
|
QStringList replacevars(QStringList txts) { |
|
|
|
|
for (QStringList::iterator txt(txts.begin()); txt!=txts.end(); ++txt) |
|
|
|
|
*txt = replacevars(*txt); |
|
|
|
|
return txts; |
|
|
|
|
} |
|
|
|
|
QString insertvars(QString txt) { |
|
|
|
|
QMapIterator<LenString, LenString> it(_rvariables); |
|
|
|
|
it.toBack(); |
|
|
|
@ -1113,7 +1118,7 @@ class Expect: public Command { |
|
|
|
|
"There is a short hand:\n" |
|
|
|
|
" - load <url>\n" |
|
|
|
|
" stands for the three signals:\n" |
|
|
|
|
" - loadStarted\n" |
|
|
|
|
" - loadStarted (optional)\n" |
|
|
|
|
" - urlChanged <url>\n" |
|
|
|
|
" - loadFinished true"; |
|
|
|
|
} |
|
|
|
@ -1130,24 +1135,22 @@ class Expect: public Command { |
|
|
|
|
} |
|
|
|
|
bool execute(Script* script, QWebFrame*) { |
|
|
|
|
Logger log(this, script); |
|
|
|
|
QList<Signal> sigs; |
|
|
|
|
QStringList args(script->replacevars(_signal._args)); |
|
|
|
|
Script::Signal lastsignal(script->getSignal()); |
|
|
|
|
if (_signal._signal=="load") { // special signal load
|
|
|
|
|
sigs += Signal("loadStarted"); |
|
|
|
|
sigs += Signal("urlChanged", _signal._args); |
|
|
|
|
sigs += Signal("loadFinished", "true"); |
|
|
|
|
if (lastsignal.first=="loadStarted") { |
|
|
|
|
log("ignore loadStarted"); |
|
|
|
|
lastsignal = script->getSignal(); // ignore optional loadStarted
|
|
|
|
|
} |
|
|
|
|
if (lastsignal.first!="urlChanged" || (args.size() && lastsignal.second!=args)) |
|
|
|
|
throw WrongSignal("urlChanged", args, lastsignal); |
|
|
|
|
lastsignal = script->getSignal(); |
|
|
|
|
args=QStringList("true"); |
|
|
|
|
if (lastsignal.first!="loadFinished" || (lastsignal.second!=args)) |
|
|
|
|
throw WrongSignal("loadFinished", args, lastsignal); |
|
|
|
|
} else { |
|
|
|
|
sigs += _signal; |
|
|
|
|
} |
|
|
|
|
Q_FOREACH(Signal signal, sigs) { |
|
|
|
|
QStringList args; |
|
|
|
|
Q_FOREACH(QString arg, signal._args) |
|
|
|
|
args.push_back(script->replacevars(arg)); |
|
|
|
|
Script::Signal lastsignal(script->getSignal()); |
|
|
|
|
QStringList lastargs; |
|
|
|
|
Q_FOREACH(QString arg, lastsignal.second) |
|
|
|
|
lastargs.push_back(script->replacevars(arg)); |
|
|
|
|
if (lastsignal.first!=signal._signal || (args.size() && args!=lastargs)) |
|
|
|
|
throw WrongSignal(signal._signal, args, lastsignal); |
|
|
|
|
if (lastsignal.first!=_signal._signal || (args.size() && lastsignal.second!=args)) |
|
|
|
|
throw WrongSignal(_signal._signal, args, lastsignal); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -2084,7 +2087,8 @@ class Call: public Command { |
|
|
|
|
} |
|
|
|
|
bool execute(Script* script, QWebFrame* frame) { |
|
|
|
|
Logger log(this, script); |
|
|
|
|
return script->function(_name)->call(this, _args, script, frame); |
|
|
|
|
return script->function(_name)->call(this, script->replacevars(_args), |
|
|
|
|
script, frame); |
|
|
|
|
} |
|
|
|
|
public: |
|
|
|
|
QString _name; |
|
|
|
|