Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9541eb10
...
9541eb10d18e001373d9f5247c41273e4c6d4849
authored
2013-12-16 01:56:13 +0100
by
mickaelandrieu
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[WIP] Added ADD/PREPEND Tags for Events
1 parent
416f226d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
modules/events.js
modules/tester.js
modules/events.js
View file @
9541eb1
...
...
@@ -129,6 +129,51 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
}
else
if
(
isArray
(
this
.
_events
[
type
]))
{
// If we've already got an array, just append.
this
.
_events
[
type
].
push
(
listener
);
// Check for listener leak
if
(
!
this
.
_events
[
type
].
warned
)
{
var
m
;
if
(
this
.
_maxListeners
!==
undefined
)
{
m
=
this
.
_maxListeners
;
}
else
{
m
=
defaultMaxListeners
;
}
if
(
m
&&
m
>
0
&&
this
.
_events
[
type
].
length
>
m
)
{
this
.
_events
[
type
].
warned
=
true
;
console
.
error
(
'(node) warning: possible EventEmitter memory '
+
'leak detected. %d listeners added. '
+
'Use emitter.setMaxListeners() to increase limit.'
,
this
.
_events
[
type
].
length
);
console
.
trace
();
}
}
}
else
{
// Adding the second element, need to change to array.
this
.
_events
[
type
]
=
[
this
.
_events
[
type
],
listener
];
}
return
this
;
};
EventEmitter
.
prototype
.
prependListener
=
function
prependListener
(
type
,
listener
)
{
if
(
'function'
!==
typeof
listener
)
{
throw
new
CasperError
(
'addListener only takes instances of Function'
);
}
if
(
!
this
.
_events
)
this
.
_events
=
{};
// To avoid recursion in the case that type == "newListeners"! Before
// adding it to the listeners, first emit "newListeners".
this
.
emit
(
'newListener'
,
type
,
listener
);
if
(
!
this
.
_events
[
type
])
{
// Optimize the case of one listener. Don't need the extra array object.
this
.
_events
[
type
]
=
listener
;
}
else
if
(
isArray
(
this
.
_events
[
type
]))
{
// If we've already got an array, just append.
this
.
_events
[
type
].
unshift
(
listener
);
// Check for listener leak
...
...
@@ -157,7 +202,20 @@ EventEmitter.prototype.addListener = function addListener(type, listener) {
return
this
;
};
EventEmitter
.
prototype
.
on
=
EventEmitter
.
prototype
.
addListener
;
EventEmitter
.
prototype
.
on
=
function
on
(
type
,
listener
,
tag
)
{
switch
(
tag
)
{
case
"ADD"
:
return
this
.
addListener
(
type
,
listener
);
break
;
case
"PREPEND"
:
return
this
.
prependListener
;
break
;
default
:
return
this
.
addListener
(
type
,
listener
);
}
};
EventEmitter
.
prototype
.
once
=
function
once
(
type
,
listener
)
{
if
(
'function'
!==
typeof
listener
)
{
...
...
modules/tester.js
View file @
9541eb1
...
...
@@ -1532,7 +1532,7 @@ Tester.prototype.renderResults = function renderResults(exit, status, save) {
};
/**
* Runs al suites contained in the paths passed as arguments.
* Runs al
l
suites contained in the paths passed as arguments.
*
*/
Tester
.
prototype
.
runSuites
=
function
runSuites
()
{
...
...
Please
register
or
sign in
to post a comment