Debian Codegraph @

util/doh/plugins/remoteRobot.js

raw symbols SCIP
1 define("doh/plugins/remoteRobot", ["doh/runner", "dojo/_base/lang"], function(runner, lang){
2
3 /*=====
4 return {
5 // summary:
6 // Plugin that bridges the doh.robot and WebDriver APIs.
7 };
8 =====*/
9
10 // read in the test and port parameters from the URL
11 var remoteRobotURL = "";
12 var paths = "";
13 var qstr = window.location.search.substr(1);
14 if(qstr.length){
15 var qparts = qstr.split("&");
16 for(var x=0; x<qparts.length; x++){
17 var tp = qparts[x].split("="), name = tp[0], value = tp[1].replace(/[<>"'\(\)]/g, ""); // replace() to avoid XSS attack
18 //Avoid URLs that use the same protocol but on other domains, for security reasons.
19 if (value.indexOf("//") === 0 || value.indexOf("\\\\") === 0) {
20 throw "Insupported URL";
21 }
22 switch(name){
23 case "remoteRobotURL":
24 remoteRobotURL = value;
25 break;
26 case "paths":
27 paths = value;
28 break;
29 }
30 }
31 }
32 // override doh runner so that it appends the remote robot url to each test
33 runner._registerUrl = (function(oi){
34 return lang.hitch(runner, function(group, url, timeout, type, dohArgs){
35 // append parameter, or specify new query string if appropriate
36 if(remoteRobotURL){
37 url += (/\?/.test(url)?"&":"?") + "remoteRobotURL=" + remoteRobotURL
38 }
39 if(paths){
40 url += (/\?/.test(url)?"&":"?") + "paths=" + paths;
41 }
42 oi.apply(runner, [group, url, timeout, type, dohArgs]);
43 });
44 })(runner._registerUrl);
45 return remoteRobotURL;
46 });