Since we couldn't wait, I have found a workaround. I am posting it here in
case it helps someone when using an unsupported JS function.
In flotr.js I just made a small modification:
---
this.ctx = c.getContext('2d');
this.octx = oc.getContext('2d');
// add these lines:
if (!(this.ctx.scale)) {
this.ctx.scale=function(x,y) {};
this.octx.scale=function(x,y) {};
this.ctx.translate=function(x,y) {};
this.octx.translate=function(x,y) {};
}
// then all is well:
if(!Prototype.Browser.IE){
this.ctx.scale(o.resolution, o.resolution);
this.octx.scale(o.resolution, o.resolution);
}
---
So the trick was to add the missing function through JS if they were not
available.
I am still curious about AJAX and <sleep> though?
Kind regards,
Anze
On Friday 12 February 2010, Anze wrote:
> Hi Ahmed!
>
> Thanks for the fast response, I really appreciate it!
>
> It looks like the library needs functions scale(x,y) and translate(x,y) (I
> have added them dynamically, through JS, and the tests started working).
>
> So i guess this should be added to
> host/canvas/CanvasRenderingContext2D.java: -----
> /**
> * Scale the user coordinate system of the canvas
> * @param x the x
> * @param y the y
> */
> public void jsxFunction_scale(final double x, final double y) {
> //empty
> }
>
> /**
> * Translate the user coordinate system of the canvas
> * @param x the x
> * @param y the y
> */
> public void jsxFunction_translate(final double x, final double y) {
> //empty
> }
> -----
>
> Any chance someone could add this to trunk?
>
> Also, how about adding full CanvasRenderingContext2D support? I can make
> the stubs if it helps... The list is here: (for instance)
> http://developer.apple.com/safari/library/documentation/AppleApplications/R
> eference/WebKitDOMRef/CanvasRenderingContext2D_idl/Classes/CanvasRenderingC
> ontext2D/index.html
>
> Thanks!
>
> Anze
>
> On Friday 12 February 2010, Ahmed Ashour wrote:
> > Hi Anze,
> >
> > Regarding "Cannot find function scale in object [object
> > CanvasRenderingContext2D]", this can be easily fixed in HtmlUnit be
> > empty implementation.
> >
> > Please have a look in the current implementation [1] and list all
> > functions you need to skip.
> >
> > [1]
> >
> > http://htmlunit.svn.sf.net/viewvc/htmlunit/trunk/htmlunit/src/main/java/c
> >o
> > m/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext
> >2D .java?view=markup#l_22
> >
> > Yours,
> > Ahmed
> > ----
> > Blog: http://asashour.blogspot.com
> >
> > ________________________________
> > From: Anze <[email protected]>
> > To: [email protected]
> > Sent: Fri, February 12, 2010 1:14:31 PM
> > Subject: [Webtest] Prototype AJAX
> >
> > Hi all!
> >
> > We are starting out with WebTest and would appreciate some help... :)
> >
> > 1) we are making AJAX calls and found that you had to use <sleep> to wait
> > for the call to finish. Now, this is awkward - why would someone ever
> > want to do something in a test before AJAX finished? Is there any wait to
> > say "wait for all AJAX to finish"?
> >
> > 2) we are using Flotr library for drawing graphs. However, it doesn't
> > play nicely with WebTest:
> > TypeError: Cannot find function scale in object [object
> > CanvasRenderingContext2D].
> > Since we do not intend to test Flotr charts at this point, we would like
> > WebTest to skip Flotr.draw() JS function. The only way I can think of is
> > to set a cookie in test files and then check for cookie before calling
> > Flotr.draw. Is there a nicer way to do it?
> > Of course, tips on how to fix JS support for Flotr would be even
> > better...
> >
> > :)
> >
> > Thanks,
> >
> > Anze
> > _______________________________________________
> > WebTest mailing list
> > [email protected]
> > http://lists.canoo.com/mailman/listinfo/webtest
>
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest
>
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest