Sorry, I was wrong about not "triggering the default action". I forgot that
I use hidden iframes to direct the content of the default action, i.e.,
<iframe name="iframeA"></iframe>
...
<iframe name="iframeZ"></iframe>
<a id="clickA" href="http://example.org/A" target="iframeA">A</a>
...
<a id="clickZ" href="http://example.org/Z" target="iframeZ">Z</a>
With real browsers, the content loads into the iframe.
With WebTest, the simulated click changes the current response. Is there a
setting to disable following frames?
On Thu, Mar 17, 2011 at 10:58 AM, Anthon Pang <[email protected]> wrote:
> I searched the forum (and Jira is locked), so my apologies if this is a
> dupe.
>
> We're using jQuery's QUnit for our JavaScript unit tests. With a browser
> (e.g., Firefox, IE, Safari, Chrome, etc.), the following code in QUnit can
> be used to simulate mouse click events and test the click event handlers
> without triggering the default action, e.g., QUnit.triggerEvent( elem,
> 'click' );
>
> triggerEvent: function( elem, type, event ) {
> if ( document.createEvent ) {
> event = document.createEvent("MouseEvents");
> event.initMouseEvent(type, true, true,
> elem.ownerDocument.defaultView,
> 0, 0, 0, 0, 0, false, false, false, false,
> 0, null);
> elem.dispatchEvent( event );
>
> } else if ( elem.fireEvent ) {
> elem.fireEvent("on"+type);
> }
> },
>
> But with R_1810, the default action is also triggered. Moreover, it
> doesn't appear that I can stop this behavior using something like this in my
> click event handler:
>
> if(!e) var e = window.event;
> e.cancelBubble = true;
> e.returnValue = false;
> if (e.stopPropagation) {
> e.stopPropagation();
> e.preventDefault();
> }
> return false;
>
> I'd appreciate some tips. Thanks.
>