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