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
24a362a9
...
24a362a9e5bddd9be8702d1fe6244c72db76b22e
authored
2012-03-13 10:14:26 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #63 - removed `fallbackToHref` option handling in `ClientUtils.click()`
1 parent
812fb5ce
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
24 deletions
CHANGELOG.md
modules/casper.js
modules/clientutils.js
tests/site/click.html
CHANGELOG.md
View file @
24a362a
...
...
@@ -6,6 +6,7 @@ XXXX-XX-XX, v0.6.5
-
**BC BREAK:**
reverted 8347278 (refs
[
#34
](
https://github.com/n1k0/casperjs/issues/34
)
and added a new
`clear()`
method to
*close*
a page
You now have to call
`casper.clear()`
if you want to stop javascript execution within the remote DOM environment.
-
**BC BREAK:**
removed
`fallbackToHref`
option handling in
`ClientUtils.click()`
(refs
[
#63
](
https://github.com/n1k0/casperjs/issues/63
)
)
-
`tester.findTestFiles()`
now returns results in predictable order
-
added
`--log-level`
and
`--direct`
options to
`casper test`
command
-
fixed 0.6.4 version number in
`bootstrap.js`
...
...
modules/casper.js
View file @
24a362a
...
...
@@ -251,7 +251,7 @@ Casper.prototype.clear = function clear() {
* @param String selector A DOM CSS3 compatible selector
* @return Boolean
*/
Casper
.
prototype
.
click
=
function
click
(
selector
,
fallbackToHref
)
{
Casper
.
prototype
.
click
=
function
click
(
selector
)
{
this
.
log
(
"Click on selector: "
+
selector
,
"debug"
);
if
(
arguments
.
length
>
1
)
{
this
.
emit
(
"deprecated"
,
"The click() method does not process the fallbackToHref argument since 0.6"
);
...
...
modules/clientutils.js
View file @
24a362a
...
...
@@ -52,11 +52,9 @@
* Clicks on the DOM element behind the provided selector.
*
* @param String selector A CSS3 selector to the element to click
* @param Boolean fallbackToHref Whether to try to relocate to the value of any href attribute (default: true)
* @return Boolean
*/
this
.
click
=
function
(
selector
,
fallbackToHref
)
{
fallbackToHref
=
typeof
fallbackToHref
===
"undefined"
?
true
:
!!
fallbackToHref
;
this
.
click
=
function
(
selector
)
{
var
elem
=
this
.
findOne
(
selector
);
if
(
!
elem
)
{
this
.
log
(
"click(): Couldn't find any element matching '"
+
selector
+
"' selector"
,
"error"
);
...
...
@@ -66,25 +64,7 @@
evt
.
initMouseEvent
(
"click"
,
true
,
true
,
window
,
1
,
1
,
1
,
1
,
1
,
false
,
false
,
false
,
false
,
0
,
elem
);
// dispatchEvent return value is false if at least one of the event
// handlers which handled this event called preventDefault
if
(
elem
.
dispatchEvent
(
evt
))
{
return
true
;
}
if
(
fallbackToHref
&&
elem
.
hasAttribute
(
'href'
))
{
var
hrefValue
=
elem
.
getAttribute
(
'href'
);
var
hrefJavascriptMatch
=
hrefValue
.
match
(
/^
\s?
javascript
\s?
:
(
.*
)
/i
);
if
(
hrefJavascriptMatch
)
{
try
{
eval
(
hrefJavascriptMatch
[
1
]);
}
catch
(
e
)
{
this
.
log
(
"click(): Unable to evaluate href javascript contents: "
+
e
,
"error"
);
return
false
;
}
}
else
{
document
.
location
=
hrefValue
;
}
return
true
;
}
return
false
;
return
elem
.
dispatchEvent
(
evt
);
};
/**
...
...
tests/site/click.html
View file @
24a362a
...
...
@@ -8,7 +8,7 @@
<a
id=
"test1"
href=
"javascript:results.test1 = true;"
>
test1
</a>
<a
id=
"test2"
href=
"#"
onclick=
"results.test2 = true;"
>
test2
</a>
<a
id=
"test3"
href=
"page1.html"
onclick=
"results.test3 = true; return false"
>
test3
</a>
<a
id=
"test4"
href=
"
page1.html
"
>
test4
</a>
<a
id=
"test4"
href=
"
http://www.google.com/
"
>
test4
</a>
<script>
(
function
(
window
)
{
window
.
results
=
{
...
...
Please
register
or
sign in
to post a comment