Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | "use strict"; |
michael@0 | 4 | |
michael@0 | 5 | // from MouseEvents.h |
michael@0 | 6 | const leftButtonFlag = 1; |
michael@0 | 7 | const rightButtonFlag = 2; |
michael@0 | 8 | |
michael@0 | 9 | gTests.push({ |
michael@0 | 10 | desc: "Test native mouse events", |
michael@0 | 11 | run: function () { |
michael@0 | 12 | let tab = yield addTab("about:mozilla"); |
michael@0 | 13 | |
michael@0 | 14 | // Mousemove. |
michael@0 | 15 | let waitForMove = waitForEvent(document, "mousemove"); |
michael@0 | 16 | synthesizeNativeMouseMove(tab.browser, 1, 1); |
michael@0 | 17 | synthesizeNativeMouseMove(tab.browser, 100, 100); |
michael@0 | 18 | let mousemove = yield waitForMove; |
michael@0 | 19 | is(mousemove.cancelable, false, "mousemove is not cancelable"); |
michael@0 | 20 | is(mousemove.buttons, 0, "no buttons are down"); |
michael@0 | 21 | |
michael@0 | 22 | // Left button down. |
michael@0 | 23 | let waitForDown1 = waitForEvent(document, "mousedown"); |
michael@0 | 24 | synthesizeNativeMouseLDown(tab.browser, 100, 100); |
michael@0 | 25 | let mousedown1 = yield waitForDown1; |
michael@0 | 26 | is(mousedown1.cancelable, true, "mousedown is cancelable"); |
michael@0 | 27 | is(mousedown1.buttons, leftButtonFlag, "left button is down"); |
michael@0 | 28 | |
michael@0 | 29 | // Right button down. |
michael@0 | 30 | let waitForDown2 = waitForEvent(document, "mousedown"); |
michael@0 | 31 | synthesizeNativeMouseRDown(tab.browser, 100, 100); |
michael@0 | 32 | let mousedown2 = yield waitForDown2; |
michael@0 | 33 | is(mousedown2.buttons, leftButtonFlag | rightButtonFlag, "both buttons are down"); |
michael@0 | 34 | |
michael@0 | 35 | // Left button up. |
michael@0 | 36 | let waitForUp1 = waitForEvent(document, "mouseup"); |
michael@0 | 37 | synthesizeNativeMouseLUp(tab.browser, 100, 100); |
michael@0 | 38 | let mouseup1 = yield waitForUp1; |
michael@0 | 39 | is(mouseup1.buttons, rightButtonFlag, "right button is down"); |
michael@0 | 40 | |
michael@0 | 41 | // Right button up. |
michael@0 | 42 | let waitForUp2 = waitForEvent(document, "mouseup"); |
michael@0 | 43 | synthesizeNativeMouseRUp(tab.browser, 100, 100); |
michael@0 | 44 | let mouseup2 = yield waitForUp2; |
michael@0 | 45 | is(mouseup2.buttons, 0, "no buttons are down"); |
michael@0 | 46 | |
michael@0 | 47 | Browser.closeTab(tab, { forceClose: true }); |
michael@0 | 48 | } |
michael@0 | 49 | }); |
michael@0 | 50 | |
michael@0 | 51 | let test = runTests; |