Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions selbench-fx-xpi/chrome/content/extensions/selbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ function $d() { return selenium.browserbot.getDocument(); }

// selbench name-space
(function($$){

if(typeof storedVarsGlobal !== 'object') {
// intentional global
storedVarsGlobal = storedVars;
}
if(typeof storedVarsLocal !== 'object') {
// intentional global
storedVarsLocal = storedVars;
}

function evalWithVars(expr) {
return eval("with (storedVars) {" + expr + "}");
}
Expand All @@ -46,7 +54,7 @@ function $d() { return selenium.browserbot.getDocument(); }
catch (err) {
throw new Error("In " + err.fileName + " @" + err.lineNumber + ": " + err);
}
storedVars.emitted = "";
storedVarsGlobal.emitted = "";
};
})();

Expand Down Expand Up @@ -76,11 +84,6 @@ function $d() { return selenium.browserbot.getDocument(); }
// ================================================================================
// emit execution tracing

function evalWithVars(expr) {
return eval("with (storedVars) {" + expr + "}");
}


// ================================================================================
Selenium.prototype.doExpectError = function(target) {
$$.expectedError = eval(target);
Expand All @@ -92,9 +95,9 @@ function $d() { return selenium.browserbot.getDocument(); }
// appends the given string to current emitted state, (a ~ is inserted between each append)
Selenium.prototype.doEmit = function(target)
{
if (storedVars.emitted)
storedVars.emitted += "~";
storedVars.emitted += evalWithVars(target);
if (storedVarsGlobal.emitted)
storedVarsGlobal.emitted += "~";
storedVarsGlobal.emitted += evalWithVars(target);
};
// verifies that the accumulated emit state matches the given string
// if an array is specified, then matches for a ~ between each element
Expand All @@ -104,16 +107,16 @@ function $d() { return selenium.browserbot.getDocument(); }
if (expectedValue instanceof Array) {
expectedValue = expectedValue.join("~");
}
if (expectedValue != storedVars.emitted) {
var errmsg = " expected: " + expectedValue + "\nbut found: " + storedVars.emitted;
if (expectedValue != storedVarsGlobal.emitted) {
var errmsg = " expected: " + expectedValue + "\nbut found: " + storedVarsGlobal.emitted;
alert(errmsg);
throw new Error(errmsg);
}
};
// clears the accumulated emitted state
Selenium.prototype.doResetEmitted = function()
{
storedVars.emitted = "";
storedVarsGlobal.emitted = "";
};

// ================================================================================
Expand All @@ -132,17 +135,19 @@ function $d() { return selenium.browserbot.getDocument(); }
Selenium.prototype.doAlert = function(expr) {
alert(evalWithVars(expr));
};

// remove selenium variable
Selenium.prototype.doDeleteVar = function(name) {
delete storedVars[name];
function deleteVar(name) {
delete storedVarsLocal[name];
delete storedVarsGlobal[name]
};
Selenium.prototype.doDeleteVar = deleteVar;

// remove selenium variable
Selenium.prototype.doDeleteVars = function(namesSpec) {
var names = namesSpec.split(",");
for (var i = 0; i < names.length; i++) {
delete storedVars[names[i].trim()];
deleteVar(names[i].trim());
}
};

Expand Down Expand Up @@ -174,7 +179,7 @@ function $d() { return selenium.browserbot.getDocument(); }
Selenium.prototype.doTimerElapsed = function(name, script)
{
if (script) {
storedVars._elapsed = timers[name].elapsed();
storedVarsGlobal._elapsed = timers[name].elapsed();
eval(script);
}
else
Expand Down