Subject: | several mechanize + javascript bugs |
Date: | Tue, 24 Feb 2009 17:55:49 +0100 |
To: | bug-WWW-Mechanize-Plugin-JavaScript [...] rt.cpan.org |
From: | Imre Rad <radimre [...] freemail.hu> |
Hi,
thanks for the latest bugfix, here are the next ones:
teszt2.pl:
#!/usr/bin/perl
use warnings;
use strict;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->use_plugin('JavaScript');
$mech->get("http://localhost/je/teszt.htm");
# perl teszt2.pl
SyntaxError: Expected statement or function declaration but found '<!--
wind' at http://localhost/je/teszt.js, line 1.
the failing web page is the following:
teszt.htm:
<html>
<head>
<script type="text/javascript" src="teszt.js"></script>
</head>
<body>
</body>
</html>
teszt.js:
<!--
window.alert("hello wrodl");
//-->
i know this syntax is probably incorrect as comments are used in the
external file not in the embedded html code within the script tags,
but i ran into this bug while developing a script for a real website
and also decent browsers can deal with this syntax.
teszt3.pl:
#!/usr/bin/perl
use warnings;
use strict;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->use_plugin('JavaScript');
$mech->get("http://localhost/je/teszt2.htm");
# perl teszt3.pl
TypeError: undefined has no properties, not even one named length at http://localhost/je/teszt2.htm, line 7.
teszt2.htm is basicly the standard dreamweaver generated mm_preload function:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
<body onLoad="MM_preloadImages('pic1.gif','pic2.gif')" >
</body>
</html>
3rd:
<script>
<!--
window.alert("foobar");
-->
</script>
SyntaxError: Expected expression but found '>
' at http://localhost/je/teszt3.htm, line 4.
if i close the comment block with //--> in line 4, error disappears.
I am using v0.08. I can send you several more bug reports if yuo want :)
Are you going to add frames support one day? It would kick ass.
best regards
imre rad