aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@gmail.com>2013-06-11 17:50:01 -0700
committerGravatar Rogan Creswick <creswick@gmail.com>2013-06-11 17:50:01 -0700
commitf3b071e1d14353ec87ea97b4bec08214ed70fbd8 (patch)
treec17a821bf5aac9b9793a6d770ccd57abdf166f00 /src
parent5bbebd24b7f240eaadc9368fce0455f7acbb4090 (diff)
fixed the injection code in the headless runner
Diffstat (limited to 'src')
-rw-r--r--src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java33
-rw-r--r--src/js/selenium/selenium-injected-compute.js5
2 files changed, 14 insertions, 24 deletions
diff --git a/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java b/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java
index 7fb541c..d953239 100644
--- a/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java
+++ b/src/batchtools/headless/src/main/java/com/galois/fiveui/BatchRunner.java
@@ -27,6 +27,7 @@ import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.io.Files;
import com.galois.fiveui.Result;
@@ -91,9 +92,9 @@ public class BatchRunner {
CrawlParameters params = new CrawlParameters(run.getCrawlType());
int politeness = params.toString().equals("none") ? 1000 : params.politeness;
List<String> urls;
- Map<String, Map<String, List<String>>> urlCache;
+
//- URL, params, urls
- urlCache = new HashMap<String, Map<String, List<String>>>();
+ Map<String, Map<String, List<String>>> urlCache = Maps.newHashMap();
for (HeadlessAtom a: run.getAtoms()) {
RuleSet rs = a.getRuleSet();
@@ -196,16 +197,9 @@ public class BatchRunner {
", ruleSet=\"" + ruleSet.getName() + "\"";
logger.debug("runRule: " + state);
- _exe.executeScript(contentScript);
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- logger.error(e1.toString());
- }
-
- Object res = _exe.executeScript("return fiveui.selPort.query(type='ReportProblem')");
-
+ contentScript += "return fiveui.selPort.query(type='ReportProblem')";
+ Object res =_exe.executeScript(contentScript);
+
if (res.getClass() == String.class) {
// we received an error via the expected mechanisms:
logger.error("exception running rule: " + res);
@@ -267,19 +261,20 @@ public class BatchRunner {
* @throws IOException
*/
private String wrapRule(RuleSet ruleSet) throws IOException {
- String injected = "";
- injected += Utils.readFile(_root + JS_SRC_ROOT + SEL_INJECTED_COMPUTE_JS);
+ String injected = "fiveui = {};";
injected += Utils.readFile(_root + JS_SRC_ROOT + J_QUERY_JS);
- injected += Utils.readFile(_root + JS_SRC_ROOT + PRELUDE_JS);
injected += Utils.readFile(_root + JS_SRC_ROOT + MD5_JS);
- injected += Utils.readFile(_root + JS_SRC_ROOT + JQUERY_PLUGIN_JS);
- //injected += Utils.readFile(_root + JS_SRC_ROOT + INJECTED_COMPUTE_JS);
+ injected += Utils.readFile(_root + JS_SRC_ROOT + "fiveui/injected/prelude.js");
+ injected += Utils.readFile(_root + JS_SRC_ROOT + "fiveui/injected/jquery-plugins.js");
+ injected += Utils.readFile(_root + JS_SRC_ROOT + "selenium/selenium-injected-compute.js");
+ injected += Utils.readFile(_root + JS_SRC_ROOT + "fiveui/injected/compute.js");
- injected += "return fiveui.selPort.send('SetRules', " + ruleSet + ");";
+ //injected += "return fiveui.selPort.send('SetRules', " + ruleSet + ");";
+ injected += "fiveui.selPort.send('SetRules', " + ruleSet + ");";
return injected;
}
-
+
/**
* Build a list of webdrivers with which to run each ruleset.
*
diff --git a/src/js/selenium/selenium-injected-compute.js b/src/js/selenium/selenium-injected-compute.js
index d0327b3..dd208be 100644
--- a/src/js/selenium/selenium-injected-compute.js
+++ b/src/js/selenium/selenium-injected-compute.js
@@ -19,11 +19,6 @@
* limitations under the License.
*/
-// Init FiveUI, if necessary:
-if (typeof fiveui == 'undefined') {
- fiveui = {};
-}
-
/**
* @return {{on: function(!string, function(*)), emit: function(!string, *)}}
*/