diff --git a/docshell/test/test_bug369814.html b/docshell/test/test_bug369814.html new file mode 100644 --- /dev/null +++ b/docshell/test/test_bug369814.html @@ -0,0 +1,204 @@ + + + + + Test for Bug 369814 + + + + + + +Mozilla Bug 369814 + +

+ + + +

+
+
+ + + diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -10,30 +10,34 @@ /** * Send a mouse event to the node with id aTarget. The "event" passed in to * aEvent is just a JavaScript object with the properties set that the real * mouse event object should have. This includes the type of the mouse event. * E.g. to send an click event to the node with id 'node' you might do this: * * sendMouseEvent({type:'click'}, 'node'); */ -function sendMouseEvent(aEvent, aTarget) { +function sendMouseEvent(aEvent, aTarget, aWindow) { if (['click', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) { throw new Error("sendMouseEvent doesn't know about event type '"+aEvent.type+"'"); + } + + if (!aWindow) { + aWindow = window; } // For events to trigger the UA's default actions they need to be "trusted" netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite'); - var event = document.createEvent('MouseEvent'); + var event = aWindow.document.createEvent('MouseEvent'); var typeArg = aEvent.type; var canBubbleArg = true; var cancelableArg = true; - var viewArg = window; + var viewArg = aWindow; var detailArg = aEvent.detail || (aEvent.type == 'click' || aEvent.type == 'mousedown' || aEvent.type == 'mouseup' ? 1 : 0); var screenXArg = aEvent.screenX || 0; var screenYArg = aEvent.screenY || 0; var clientXArg = aEvent.clientX || 0; var clientYArg = aEvent.clientY || 0; var ctrlKeyArg = aEvent.ctrlKey || false; @@ -43,17 +47,17 @@ function sendMouseEvent(aEvent, aTarget) var buttonArg = aEvent.button || 0; var relatedTargetArg = aEvent.relatedTarget || null; event.initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg); - document.getElementById(aTarget).dispatchEvent(event); + aWindow.document.getElementById(aTarget).dispatchEvent(event); } /** * Send the char aChar to the node with id aTarget. If aTarget is not * provided, use "target". This method handles casing of chars (sends the * right charcode, and sends a shift key for uppercase chars). No other * modifiers are handled at this point. *