Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=547996 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 547996</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547996">Mozilla Bug 547996</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 547996 **/ |
michael@0 | 21 | /* mouseEvent.mozInputSource attribute */ |
michael@0 | 22 | |
michael@0 | 23 | function prepareListener(eventName, expectedValue) { |
michael@0 | 24 | return function(event) { |
michael@0 | 25 | is(event.mozInputSource, expectedValue, "Correct .mozInputSource value in " + eventName); |
michael@0 | 26 | }; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | const INPUT_SOURCE_UNKNOWN = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN; |
michael@0 | 30 | const INPUT_SOURCE_KEYBOARD = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD; |
michael@0 | 31 | |
michael@0 | 32 | function doTest() { |
michael@0 | 33 | var eventNames = [ |
michael@0 | 34 | "mousedown", |
michael@0 | 35 | "mouseup", |
michael@0 | 36 | "click", |
michael@0 | 37 | "dblclick", |
michael@0 | 38 | "contextmenu", |
michael@0 | 39 | "DOMMouseScroll", |
michael@0 | 40 | "dragdrop", |
michael@0 | 41 | "dragstart", |
michael@0 | 42 | "dragend", |
michael@0 | 43 | "dragenter", |
michael@0 | 44 | "dragleave", |
michael@0 | 45 | "dragover" |
michael@0 | 46 | ]; |
michael@0 | 47 | |
michael@0 | 48 | var target = document.getElementById("testTarget"); |
michael@0 | 49 | |
michael@0 | 50 | for (var i in eventNames) { |
michael@0 | 51 | for(var value = INPUT_SOURCE_UNKNOWN; value <= INPUT_SOURCE_KEYBOARD; value++) { |
michael@0 | 52 | var eventName = eventNames[i]; |
michael@0 | 53 | var listener = prepareListener(eventName, value); |
michael@0 | 54 | |
michael@0 | 55 | target.addEventListener(eventName, listener, false); |
michael@0 | 56 | |
michael@0 | 57 | var newEvent = document.createEvent("MouseEvent"); |
michael@0 | 58 | newEvent.initNSMouseEvent(eventName, true, true, window, 0, 0, 0, 0, 0, |
michael@0 | 59 | false, false, false, false, 0, null, 0, value); |
michael@0 | 60 | target.dispatchEvent(newEvent); |
michael@0 | 61 | target.removeEventListener(eventName, listener, false); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | // Events created by script that do not initialize the mozInputSource |
michael@0 | 65 | // value should have the value MOZ_SOURCE_UNKNOWN |
michael@0 | 66 | var listener = prepareListener(eventName, INPUT_SOURCE_UNKNOWN); |
michael@0 | 67 | target.addEventListener(eventName, listener, false); |
michael@0 | 68 | |
michael@0 | 69 | var newEvent = document.createEvent("MouseEvent"); |
michael@0 | 70 | newEvent.initMouseEvent(eventName, true, true, window, 0, 0, 0, 0, 0, |
michael@0 | 71 | false, false, false, false, 0, null); |
michael@0 | 72 | target.dispatchEvent(newEvent); |
michael@0 | 73 | target.removeEventListener(eventName, listener, false); |
michael@0 | 74 | |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | SimpleTest.finish(); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 81 | addLoadEvent(doTest); |
michael@0 | 82 | |
michael@0 | 83 | </script> |
michael@0 | 84 | </pre> |
michael@0 | 85 | <span id="testTarget" style="border: 1px solid black;">testTarget</span> |
michael@0 | 86 | </body> |
michael@0 | 87 | </html> |