michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: // from MouseEvents.h michael@0: const leftButtonFlag = 1; michael@0: const rightButtonFlag = 2; michael@0: michael@0: gTests.push({ michael@0: desc: "Test native mouse events", michael@0: run: function () { michael@0: let tab = yield addTab("about:mozilla"); michael@0: michael@0: // Mousemove. michael@0: let waitForMove = waitForEvent(document, "mousemove"); michael@0: synthesizeNativeMouseMove(tab.browser, 1, 1); michael@0: synthesizeNativeMouseMove(tab.browser, 100, 100); michael@0: let mousemove = yield waitForMove; michael@0: is(mousemove.cancelable, false, "mousemove is not cancelable"); michael@0: is(mousemove.buttons, 0, "no buttons are down"); michael@0: michael@0: // Left button down. michael@0: let waitForDown1 = waitForEvent(document, "mousedown"); michael@0: synthesizeNativeMouseLDown(tab.browser, 100, 100); michael@0: let mousedown1 = yield waitForDown1; michael@0: is(mousedown1.cancelable, true, "mousedown is cancelable"); michael@0: is(mousedown1.buttons, leftButtonFlag, "left button is down"); michael@0: michael@0: // Right button down. michael@0: let waitForDown2 = waitForEvent(document, "mousedown"); michael@0: synthesizeNativeMouseRDown(tab.browser, 100, 100); michael@0: let mousedown2 = yield waitForDown2; michael@0: is(mousedown2.buttons, leftButtonFlag | rightButtonFlag, "both buttons are down"); michael@0: michael@0: // Left button up. michael@0: let waitForUp1 = waitForEvent(document, "mouseup"); michael@0: synthesizeNativeMouseLUp(tab.browser, 100, 100); michael@0: let mouseup1 = yield waitForUp1; michael@0: is(mouseup1.buttons, rightButtonFlag, "right button is down"); michael@0: michael@0: // Right button up. michael@0: let waitForUp2 = waitForEvent(document, "mouseup"); michael@0: synthesizeNativeMouseRUp(tab.browser, 100, 100); michael@0: let mouseup2 = yield waitForUp2; michael@0: is(mouseup2.buttons, 0, "no buttons are down"); michael@0: michael@0: Browser.closeTab(tab, { forceClose: true }); michael@0: } michael@0: }); michael@0: michael@0: let test = runTests;