2011-07-17 08:05:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2010-10-28 02:06:40 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
/**
|
2010-10-19 22:34:58 +00:00
|
|
|
* Setup file for the Scenario.
|
2010-10-08 23:43:40 +00:00
|
|
|
* Must be first in the compilation/bootstrap list.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Public namespace
|
2010-10-19 23:14:16 +00:00
|
|
|
angular.scenario = angular.scenario || {};
|
2010-10-08 23:43:40 +00:00
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
/**
|
|
|
|
|
* Defines a new output format.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name the name of the new output format
|
2011-11-10 05:18:34 +00:00
|
|
|
* @param {function()} fn function(context, runner) that generates the output
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.output = angular.scenario.output || function(name, fn) {
|
|
|
|
|
angular.scenario.output[name] = fn;
|
|
|
|
|
};
|
2010-10-08 23:43:40 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Defines a new DSL statement. If your factory function returns a Future
|
|
|
|
|
* it's returned, otherwise the result is assumed to be a map of functions
|
|
|
|
|
* for chaining. Chained functions are subject to the same rules.
|
|
|
|
|
*
|
|
|
|
|
* Note: All functions on the chain are bound to the chain scope so values
|
|
|
|
|
* set on "this" in your statement function are available in the chained
|
|
|
|
|
* functions.
|
|
|
|
|
*
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
* @param {string} name The name of the statement
|
2011-11-10 05:18:34 +00:00
|
|
|
* @param {function()} fn Factory function(), return a function for
|
2010-10-08 23:43:40 +00:00
|
|
|
* the statement.
|
|
|
|
|
*/
|
2010-10-19 23:25:23 +00:00
|
|
|
angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
|
2010-10-08 23:43:40 +00:00
|
|
|
angular.scenario.dsl[name] = function() {
|
|
|
|
|
function executeStatement(statement, args) {
|
|
|
|
|
var result = statement.apply(this, args);
|
|
|
|
|
if (angular.isFunction(result) || result instanceof angular.scenario.Future)
|
|
|
|
|
return result;
|
|
|
|
|
var self = this;
|
|
|
|
|
var chain = angular.extend({}, result);
|
2011-01-08 06:02:23 +00:00
|
|
|
angular.forEach(chain, function(value, name) {
|
2010-10-08 23:43:40 +00:00
|
|
|
if (angular.isFunction(value)) {
|
2010-10-19 20:17:49 +00:00
|
|
|
chain[name] = function() {
|
2010-10-08 23:43:40 +00:00
|
|
|
return executeStatement.call(self, value, arguments);
|
2010-10-19 20:17:49 +00:00
|
|
|
};
|
2010-10-08 23:43:40 +00:00
|
|
|
} else {
|
|
|
|
|
chain[name] = value;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return chain;
|
|
|
|
|
}
|
|
|
|
|
var statement = fn.apply(this, arguments);
|
|
|
|
|
return function() {
|
|
|
|
|
return executeStatement.call(this, statement, arguments);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Defines a new matcher for use with the expects() statement. The value
|
2010-10-19 22:34:58 +00:00
|
|
|
* this.actual (like in Jasmine) is available in your matcher to compare
|
2010-10-08 23:43:40 +00:00
|
|
|
* against. Your function should return a boolean. The future is automatically
|
|
|
|
|
* created for you.
|
|
|
|
|
*
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
* @param {string} name The name of the matcher
|
2011-11-10 05:18:34 +00:00
|
|
|
* @param {function()} fn The matching function(expected).
|
2010-10-08 23:43:40 +00:00
|
|
|
*/
|
2010-10-19 23:25:23 +00:00
|
|
|
angular.scenario.matcher = angular.scenario.matcher || function(name, fn) {
|
2010-10-08 23:43:40 +00:00
|
|
|
angular.scenario.matcher[name] = function(expected) {
|
|
|
|
|
var prefix = 'expect ' + this.future.name + ' ';
|
|
|
|
|
if (this.inverse) {
|
|
|
|
|
prefix += 'not ';
|
|
|
|
|
}
|
2010-10-19 20:17:49 +00:00
|
|
|
var self = this;
|
2010-10-21 06:17:59 +00:00
|
|
|
this.addFuture(prefix + name + ' ' + angular.toJson(expected),
|
2010-10-19 20:17:49 +00:00
|
|
|
function(done) {
|
|
|
|
|
var error;
|
|
|
|
|
self.actual = self.future.value;
|
|
|
|
|
if ((self.inverse && fn.call(self, expected)) ||
|
|
|
|
|
(!self.inverse && !fn.call(self, expected))) {
|
|
|
|
|
error = 'expected ' + angular.toJson(expected) +
|
|
|
|
|
' but was ' + angular.toJson(self.actual);
|
2010-10-08 23:43:40 +00:00
|
|
|
}
|
2010-10-19 20:17:49 +00:00
|
|
|
done(error);
|
|
|
|
|
});
|
2010-10-08 23:43:40 +00:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
/**
|
2011-05-19 15:33:25 +00:00
|
|
|
* Initialize the scenario runner and run !
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
*
|
2011-05-19 15:33:25 +00:00
|
|
|
* Access global window and document object
|
|
|
|
|
* Access $runner through closure
|
|
|
|
|
*
|
|
|
|
|
* @param {Object=} config Config options
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
*/
|
2011-10-07 18:27:49 +00:00
|
|
|
angular.scenario.setUpAndRun = function(config) {
|
2010-11-02 01:03:52 +00:00
|
|
|
var href = window.location.href;
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
var body = _jQuery(document.body);
|
|
|
|
|
var output = [];
|
2011-05-19 15:33:25 +00:00
|
|
|
var objModel = new angular.scenario.ObjectModel($runner);
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
|
2011-05-19 15:33:25 +00:00
|
|
|
if (config && config.scenario_output) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
output = config.scenario_output.split(',');
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-08 06:02:23 +00:00
|
|
|
angular.forEach(angular.scenario.output, function(fn, name) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
if (!output.length || indexOf(output,name) != -1) {
|
|
|
|
|
var context = body.append('<div></div>').find('div:last');
|
|
|
|
|
context.attr('id', name);
|
2011-05-19 15:33:25 +00:00
|
|
|
fn.call({}, context, $runner, objModel);
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2010-11-02 01:03:52 +00:00
|
|
|
if (!/^http/.test(href) && !/^https/.test(href)) {
|
|
|
|
|
body.append('<p id="system-error"></p>');
|
|
|
|
|
body.find('#system-error').text(
|
|
|
|
|
'Scenario runner must be run using http or https. The protocol ' +
|
|
|
|
|
href.split(':')[0] + ':// is not supported.'
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
var appFrame = body.append('<div id="application"></div>').find('#application');
|
|
|
|
|
var application = new angular.scenario.Application(appFrame);
|
|
|
|
|
|
2011-05-19 15:33:25 +00:00
|
|
|
$runner.on('RunnerEnd', function() {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
appFrame.css('display', 'none');
|
|
|
|
|
appFrame.find('iframe').attr('src', 'about:blank');
|
|
|
|
|
});
|
|
|
|
|
|
2011-05-19 15:33:25 +00:00
|
|
|
$runner.on('RunnerError', function(error) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
if (window.console) {
|
|
|
|
|
console.log(formatException(error));
|
|
|
|
|
} else {
|
|
|
|
|
// Do something for IE
|
|
|
|
|
alert(error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-05-19 15:33:25 +00:00
|
|
|
$runner.run(application);
|
|
|
|
|
};
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
|
2010-10-08 23:43:40 +00:00
|
|
|
/**
|
|
|
|
|
* Iterates through list with iterator function that must call the
|
|
|
|
|
* continueFunction to continute iterating.
|
|
|
|
|
*
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
* @param {Array} list list to iterate over
|
2011-11-10 05:18:34 +00:00
|
|
|
* @param {function()} iterator Callback function(value, continueFunction)
|
|
|
|
|
* @param {function()} done Callback function(error, result) called when
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
* iteration finishes or an error occurs.
|
2010-10-08 23:43:40 +00:00
|
|
|
*/
|
|
|
|
|
function asyncForEach(list, iterator, done) {
|
|
|
|
|
var i = 0;
|
2010-10-19 20:17:49 +00:00
|
|
|
function loop(error, index) {
|
|
|
|
|
if (index && index > i) {
|
|
|
|
|
i = index;
|
|
|
|
|
}
|
2010-10-08 23:43:40 +00:00
|
|
|
if (error || i >= list.length) {
|
|
|
|
|
done(error);
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
iterator(list[i++], loop);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
done(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
loop();
|
|
|
|
|
}
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
/**
|
|
|
|
|
* Formats an exception into a string with the stack trace, but limits
|
|
|
|
|
* to a specific line length.
|
|
|
|
|
*
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
* @param {Object} error The exception to format, can be anything throwable
|
2012-04-10 21:29:49 +00:00
|
|
|
* @param {Number=} [maxStackLines=5] max lines of the stack trace to include
|
2010-10-19 20:17:49 +00:00
|
|
|
* default is 5.
|
|
|
|
|
*/
|
|
|
|
|
function formatException(error, maxStackLines) {
|
|
|
|
|
maxStackLines = maxStackLines || 5;
|
|
|
|
|
var message = error.toString();
|
|
|
|
|
if (error.stack) {
|
|
|
|
|
var stack = error.stack.split('\n');
|
|
|
|
|
if (stack[0].indexOf(message) === -1) {
|
|
|
|
|
maxStackLines++;
|
|
|
|
|
stack.unshift(error.message);
|
|
|
|
|
}
|
|
|
|
|
message = stack.slice(0, maxStackLines).join('\n');
|
|
|
|
|
}
|
|
|
|
|
return message;
|
|
|
|
|
}
|
2010-10-19 22:34:58 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
/**
|
2010-10-21 06:17:59 +00:00
|
|
|
* Returns a function that gets the file name and line number from a
|
2010-10-19 20:17:49 +00:00
|
|
|
* location in the stack if available based on the call site.
|
|
|
|
|
*
|
|
|
|
|
* Note: this returns another function because accessing .stack is very
|
|
|
|
|
* expensive in Chrome.
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
*
|
|
|
|
|
* @param {Number} offset Number of stack lines to skip
|
2010-10-19 20:17:49 +00:00
|
|
|
*/
|
|
|
|
|
function callerFile(offset) {
|
|
|
|
|
var error = new Error();
|
2010-10-21 06:17:59 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
return function() {
|
|
|
|
|
var line = (error.stack || '').split('\n')[offset];
|
2010-10-21 06:17:59 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
// Clean up the stack trace line
|
|
|
|
|
if (line) {
|
|
|
|
|
if (line.indexOf('@') !== -1) {
|
|
|
|
|
// Firefox
|
|
|
|
|
line = line.substring(line.indexOf('@')+1);
|
|
|
|
|
} else {
|
|
|
|
|
// Chrome
|
|
|
|
|
line = line.substring(line.indexOf('(')+1).replace(')', '');
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-21 06:17:59 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
return line || '';
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Triggers a browser event. Attempts to choose the right event if one is
|
|
|
|
|
* not specified.
|
|
|
|
|
*
|
2011-10-12 20:57:09 +00:00
|
|
|
* @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement
|
|
|
|
|
* @param {string} type Optional event type.
|
|
|
|
|
* @param {Array.<string>=} keys Optional list of pressed keys
|
|
|
|
|
* (valid values: 'alt', 'meta', 'shift', 'ctrl')
|
2010-10-19 20:17:49 +00:00
|
|
|
*/
|
2011-10-12 20:57:09 +00:00
|
|
|
function browserTrigger(element, type, keys) {
|
2010-10-19 23:14:16 +00:00
|
|
|
if (element && !element.nodeName) element = element[0];
|
|
|
|
|
if (!element) return;
|
2010-10-19 22:34:58 +00:00
|
|
|
if (!type) {
|
|
|
|
|
type = {
|
|
|
|
|
'text': 'change',
|
|
|
|
|
'textarea': 'change',
|
|
|
|
|
'hidden': 'change',
|
|
|
|
|
'password': 'change',
|
|
|
|
|
'button': 'click',
|
|
|
|
|
'submit': 'click',
|
|
|
|
|
'reset': 'click',
|
|
|
|
|
'image': 'click',
|
|
|
|
|
'checkbox': 'click',
|
|
|
|
|
'radio': 'click',
|
|
|
|
|
'select-one': 'change',
|
|
|
|
|
'select-multiple': 'change'
|
2011-09-08 20:56:29 +00:00
|
|
|
}[lowercase(element.type)] || 'click';
|
2010-10-19 22:34:58 +00:00
|
|
|
}
|
2011-01-06 07:56:57 +00:00
|
|
|
if (lowercase(nodeName_(element)) == 'option') {
|
2010-10-19 22:34:58 +00:00
|
|
|
element.parentNode.value = element.value;
|
|
|
|
|
element = element.parentNode;
|
|
|
|
|
type = 'change';
|
|
|
|
|
}
|
2011-10-12 20:57:09 +00:00
|
|
|
|
|
|
|
|
keys = keys || [];
|
|
|
|
|
function pressed(key) {
|
|
|
|
|
return indexOf(keys, key) !== -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-09 07:16:40 +00:00
|
|
|
if (msie < 9) {
|
2010-10-21 06:17:59 +00:00
|
|
|
switch(element.type) {
|
2010-10-22 21:26:18 +00:00
|
|
|
case 'radio':
|
|
|
|
|
case 'checkbox':
|
|
|
|
|
element.checked = !element.checked;
|
|
|
|
|
break;
|
2010-10-21 06:17:59 +00:00
|
|
|
}
|
2011-02-10 19:20:49 +00:00
|
|
|
// WTF!!! Error: Unspecified error.
|
|
|
|
|
// Don't know why, but some elements when detached seem to be in inconsistent state and
|
|
|
|
|
// calling .fireEvent() on them will result in very unhelpful error (Error: Unspecified error)
|
|
|
|
|
// forcing the browser to compute the element position (by reading its CSS)
|
|
|
|
|
// puts the element in consistent state.
|
|
|
|
|
element.style.posLeft;
|
2011-10-12 20:57:09 +00:00
|
|
|
|
|
|
|
|
// TODO(vojta): create event objects with pressed keys to get it working on IE<9
|
2011-07-19 18:02:50 +00:00
|
|
|
var ret = element.fireEvent('on' + type);
|
2010-10-26 22:35:58 +00:00
|
|
|
if (lowercase(element.type) == 'submit') {
|
|
|
|
|
while(element) {
|
|
|
|
|
if (lowercase(element.nodeName) == 'form') {
|
|
|
|
|
element.fireEvent('onsubmit');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
element = element.parentNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-19 18:02:50 +00:00
|
|
|
return ret;
|
2010-10-19 22:34:58 +00:00
|
|
|
} else {
|
2011-09-21 12:10:34 +00:00
|
|
|
var evnt = document.createEvent('MouseEvents'),
|
|
|
|
|
originalPreventDefault = evnt.preventDefault,
|
|
|
|
|
iframe = _jQuery('#application iframe')[0],
|
|
|
|
|
appWindow = iframe ? iframe.contentWindow : window,
|
|
|
|
|
fakeProcessDefault = true,
|
2012-09-08 04:46:24 +00:00
|
|
|
finalProcessDefault,
|
|
|
|
|
angular = appWindow.angular || {};
|
2011-09-21 12:10:34 +00:00
|
|
|
|
|
|
|
|
// igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208
|
2012-09-08 04:46:24 +00:00
|
|
|
angular['ff-684208-preventDefault'] = false;
|
2011-09-21 12:10:34 +00:00
|
|
|
evnt.preventDefault = function() {
|
|
|
|
|
fakeProcessDefault = false;
|
|
|
|
|
return originalPreventDefault.apply(evnt, arguments);
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-12 20:57:09 +00:00
|
|
|
evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, pressed('ctrl'), pressed('alt'),
|
|
|
|
|
pressed('shift'), pressed('meta'), 0, element);
|
2011-09-21 12:10:34 +00:00
|
|
|
|
|
|
|
|
element.dispatchEvent(evnt);
|
2012-09-08 04:46:24 +00:00
|
|
|
finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault);
|
2011-09-21 12:10:34 +00:00
|
|
|
|
2012-09-08 04:46:24 +00:00
|
|
|
delete angular['ff-684208-preventDefault'];
|
2011-09-21 12:10:34 +00:00
|
|
|
|
|
|
|
|
return finalProcessDefault;
|
2010-10-19 22:34:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
/**
|
|
|
|
|
* Don't use the jQuery trigger method since it works incorrectly.
|
|
|
|
|
*
|
|
|
|
|
* jQuery notifies listeners and then changes the state of a checkbox and
|
2010-10-21 06:17:59 +00:00
|
|
|
* does not create a real browser event. A real click changes the state of
|
2010-10-19 20:17:49 +00:00
|
|
|
* the checkbox and then notifies listeners.
|
2010-10-21 06:17:59 +00:00
|
|
|
*
|
2010-10-19 20:17:49 +00:00
|
|
|
* To work around this we instead use our own handler that fires a real event.
|
|
|
|
|
*/
|
2010-10-22 21:26:18 +00:00
|
|
|
(function(fn){
|
|
|
|
|
var parentTrigger = fn.trigger;
|
|
|
|
|
fn.trigger = function(type) {
|
2012-03-30 19:07:19 +00:00
|
|
|
if (/(click|change|keydown|blur|input)/.test(type)) {
|
2011-08-30 11:14:55 +00:00
|
|
|
var processDefaults = [];
|
|
|
|
|
this.each(function(index, node) {
|
|
|
|
|
processDefaults.push(browserTrigger(node, type));
|
2010-10-22 21:26:18 +00:00
|
|
|
});
|
2011-08-30 11:14:55 +00:00
|
|
|
|
|
|
|
|
// this is not compatible with jQuery - we return an array of returned values,
|
|
|
|
|
// so that scenario runner know whether JS code has preventDefault() of the event or not...
|
|
|
|
|
return processDefaults;
|
2010-10-22 21:26:18 +00:00
|
|
|
}
|
|
|
|
|
return parentTrigger.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
})(_jQuery.fn);
|
2010-10-23 05:46:51 +00:00
|
|
|
|
2010-11-09 07:26:36 +00:00
|
|
|
/**
|
|
|
|
|
* Finds all bindings with the substring match of name and returns an
|
|
|
|
|
* array of their values.
|
|
|
|
|
*
|
2011-11-23 05:28:39 +00:00
|
|
|
* @param {string} bindExp The name to match
|
2010-11-09 07:26:36 +00:00
|
|
|
* @return {Array.<string>} String of binding values
|
|
|
|
|
*/
|
2011-11-23 05:28:39 +00:00
|
|
|
_jQuery.fn.bindings = function(windowJquery, bindExp) {
|
|
|
|
|
var result = [], match,
|
|
|
|
|
bindSelector = '.ng-binding:visible';
|
|
|
|
|
if (angular.isString(bindExp)) {
|
|
|
|
|
bindExp = bindExp.replace(/\s/g, '');
|
|
|
|
|
match = function (actualExp) {
|
|
|
|
|
if (actualExp) {
|
|
|
|
|
actualExp = actualExp.replace(/\s/g, '');
|
|
|
|
|
if (actualExp == bindExp) return true;
|
|
|
|
|
if (actualExp.indexOf(bindExp) == 0) {
|
|
|
|
|
return actualExp.charAt(bindExp.length) == '|';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (bindExp) {
|
|
|
|
|
match = function(actualExp) {
|
|
|
|
|
return actualExp && bindExp.exec(actualExp);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
match = function(actualExp) {
|
|
|
|
|
return !!actualExp;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
var selection = this.find(bindSelector);
|
|
|
|
|
if (this.is(bindSelector)) {
|
|
|
|
|
selection = selection.add(this);
|
2010-11-09 07:26:36 +00:00
|
|
|
}
|
2011-11-23 05:28:39 +00:00
|
|
|
|
|
|
|
|
function push(value) {
|
|
|
|
|
if (value == undefined) {
|
|
|
|
|
value = '';
|
|
|
|
|
} else if (typeof value != 'string') {
|
|
|
|
|
value = angular.toJson(value);
|
|
|
|
|
}
|
|
|
|
|
result.push('' + value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selection.each(function() {
|
|
|
|
|
var element = windowJquery(this),
|
|
|
|
|
binding;
|
|
|
|
|
if (binding = element.data('$binding')) {
|
|
|
|
|
if (typeof binding == 'string') {
|
|
|
|
|
if (match(binding)) {
|
|
|
|
|
push(element.scope().$eval(binding));
|
|
|
|
|
}
|
2010-11-09 07:26:36 +00:00
|
|
|
} else {
|
2011-11-23 05:28:39 +00:00
|
|
|
if (!angular.isArray(binding)) {
|
|
|
|
|
binding = [binding];
|
|
|
|
|
}
|
|
|
|
|
for(var fns, j=0, jj=binding.length; j<jj; j++) {
|
|
|
|
|
fns = binding[j];
|
|
|
|
|
if (fns.parts) {
|
|
|
|
|
fns = fns.parts;
|
|
|
|
|
} else {
|
|
|
|
|
fns = [fns];
|
|
|
|
|
}
|
|
|
|
|
for (var scope, fn, i = 0, ii = fns.length; i < ii; i++) {
|
|
|
|
|
if(match((fn = fns[i]).exp)) {
|
|
|
|
|
push(fn(scope = scope || element.scope()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-09 07:26:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
};
|