summaryrefslogtreecommitdiffstats
path: root/dom/xul/test/test_bug486990.xul
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/xul/test/test_bug486990.xul
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/xul/test/test_bug486990.xul')
-rw-r--r--dom/xul/test/test_bug486990.xul155
1 files changed, 155 insertions, 0 deletions
diff --git a/dom/xul/test/test_bug486990.xul b/dom/xul/test/test_bug486990.xul
new file mode 100644
index 000000000..fb375a4cc
--- /dev/null
+++ b/dom/xul/test/test_bug486990.xul
@@ -0,0 +1,155 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
+<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=486990
+-->
+<window title="Mozilla Bug 486990"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="setTimeout(runTests, 0);">
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=486990"
+ target="_blank">Mozilla Bug 486990</a>
+
+ </body>
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <select size="5" id="select">
+ <option>1</option>
+ <option>2</option>
+ <option>3</option>
+ <option>4</option>
+ <option>5</option>
+ <option>6</option>
+ <option>7</option>
+ <option>8</option>
+ <option>9</option>
+ <option>10</option>
+ </select>
+ </div>
+ <menupopup id="cm" onpopupshowing="popupShowing(event);">
+ <menuitem label="Mozilla" value="http://mozilla.org"/>
+ <menuitem label="Slashdot" value="http://slashdot.org"/>
+ <menuitem label="Sourceforge" value="http://sf.net"/>
+ <menuitem label="Freshmeat" value="http://freshmeat.net"/>
+ </menupopup>
+ <button label="test button" contextmenu="cm" id="testbutton"/>
+
+ <!-- test code goes here -->
+ <script type="application/javascript">
+ <![CDATA[
+
+ /** Test for Bug 486990 **/
+
+ SimpleTest.waitForExplicitFinish();
+
+ var prevented = false;
+ var eventCount = 0;
+
+ function fooListener(evt) {
+ evt.preventDefault();
+ prevented = evt.defaultPrevented;
+ ++eventCount;
+ };
+
+ var clickCount = 0;
+ var mouseDownCount = 0;
+ var mouseUpCount = 0;
+ function clickListener(evt) {
+ ++clickCount;
+ }
+
+ function mouseDownListener(evt) {
+ ++mouseDownCount;
+ }
+
+ function mouseUpListener(evt) {
+ ++mouseUpCount;
+ }
+
+ var popupshowingcount = 0;
+
+ function popupShowing(evt) {
+ ++popupshowingcount;
+ evt.preventDefault();
+ }
+
+ function contextMenuStopper(evt) {
+ evt.stopPropagation();
+ }
+
+ function contextMenuPreventer(evt) {
+ evt.preventDefault();
+ }
+
+ var tb;
+ function runTests() {
+ document.addEventListener("foo", fooListener, true);
+ var e1 = document.createEvent("Event");
+ e1.initEvent("foo", true, true);
+ document.dispatchEvent(e1);
+ is(eventCount, 1, "Wrong event count");
+ ok(prevented, "Default handling should have been prevented.");
+
+ prevented = false;
+ var e2 = document.createEvent("Event");
+ e2.initEvent("foo", false, false);
+ document.dispatchEvent(e1);
+ is(eventCount, 2, "Wrong event count");
+ ok(prevented, "Default handling should have been prevented.");
+
+ tb = document.getElementById("testbutton");
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 1, "Should have got 'popupShowing' event!");
+
+ tb.addEventListener("contextmenu", contextMenuStopper, true);
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 2, "Should have got 'popupShowing' event!");
+
+ tb.addEventListener("contextmenu", contextMenuPreventer, true);
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 2, "Should not have got 'popupShowing' event!");
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.event.contextmenu.enabled", false]]}, test2);
+ }
+
+ function test2() {
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 3, "Should have got 'popupShowing' event!");
+
+ SpecialPowers.pushPrefEnv({"set": [["dom.event.contextmenu.enabled", true]]}, test3);
+ }
+
+ function test3() {
+ dispatchTrustedContextMenuEvent(tb);
+ is(popupshowingcount, 3, "Should not have got 'popupshowing' event!");
+
+ var s = document.getElementById("select");
+ s.addEventListener("click", clickListener, true);
+ s.addEventListener("mousedown", mouseDownListener, true);
+ s.addEventListener("mouseup", mouseUpListener, true);
+
+ synthesizeMouse(s, 1, 10, {}, window);
+ is(clickCount, 1, "Should have got click event!");
+ is(mouseDownCount, 1, "Should have got mousedown event!");
+ is(mouseUpCount, 1, "Should have got mouseup event!");
+
+ // Dispatch to scrollbar.
+ synthesizeMouse(s, s.getBoundingClientRect().right - 3, 10, {}, window);
+ is(clickCount, 1, "Should not have got click event!");
+ is(mouseDownCount, 2, "Should have got mousedown event!");
+ is(mouseUpCount, 2, "Should have got mouseup event!");
+
+ SimpleTest.finish();
+ }
+
+ function dispatchTrustedContextMenuEvent(target) {
+ return sendMouseEvent({type:"contextmenu"}, target, window);
+ }
+
+ ]]>
+ </script>
+</window>