--- a/accessible/tests/mochitest/events/test_focus_general.xul
+++ b/accessible/tests/mochitest/events/test_focus_general.xul
@@ -37,17 +37,16 @@
{
// Test focus events.
gQueue = new eventQueue();
gQueue.push(new synthFocus("textbox",
new focusChecker(getNode("textbox").inputField)));
gQueue.push(new synthFocus("textbox_multiline",
new focusChecker(getNode("textbox_multiline").inputField)));
- gQueue.push(new synthFocus("scale"));
gQueue.push(new synthFocusOnFrame("editabledoc"));
gQueue.push(new synthFocus("radioclothes",
new focusChecker("radiosweater")));
gQueue.push(new synthDownKey("radiosweater",
new focusChecker("radiojacket")));
gQueue.push(new synthFocus("checkbox"));
gQueue.push(new synthFocus("button"));
gQueue.push(new synthFocus("checkbutton"));
@@ -114,35 +113,29 @@ if (!MAC) {
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
<hbox flex="1" style="overflow: auto;">
<body xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank"
- href="https://bugzilla.mozilla.org/show_bug.cgi?id=492518"
- title="xul:slider accessible of xul:scale is accessible illegally">
- Mozilla Bug 492518
- </a>
- <a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368"
title=" fire focus event on document accessible whenever the root or body element is focused">
Mozilla Bug 552368
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
<vbox flex="1">
<textbox id="textbox" value="hello"/>
<textbox id="textbox_multiline" multiline="true" value="hello"/>
- <scale id="scale" min="0" max="9" value="5"/>
<iframe id="editabledoc" src="focus.html"/>
<radiogroup id="radioclothes">
<radio id="radiosweater" label="radiosweater"/>
<radio id="radiocap" label="radiocap" disabled="true"/>
<radio id="radiojacket" label="radiojacket"/>
</radiogroup>
<checkbox id="checkbox" label="checkbox"/>
<button id="button" label="button"/>
--- a/accessible/tests/mochitest/states/test_controls.xul
+++ b/accessible/tests/mochitest/states/test_controls.xul
@@ -65,18 +65,16 @@
testStates("combobox-disabled", STATE_UNAVAILABLE | STATE_HASPOPUP, 0, STATE_FOCUSABLE);
testStates("listbox", STATE_FOCUSABLE, 0, STATE_UNAVAILABLE);
testStates("listitem", STATE_FOCUSABLE | STATE_SELECTABLE, 0, STATE_UNAVAILABLE);
testStates("listbox-disabled", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE | STATE_SELECTABLE);
testStates("listitem-disabledlistbox", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE | STATE_SELECTABLE);
testStates("menubar", 0, 0, STATE_FOCUSABLE);
testStates("menu", STATE_FOCUSABLE, 0, STATE_UNAVAILABLE);
testStates("menu-disabled", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE | STATE_SELECTABLE);
- testStates("scale", STATE_FOCUSABLE, 0, STATE_UNAVAILABLE);
- testStates("scale-disabled", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE);
testStates("tab", STATE_FOCUSABLE | STATE_SELECTABLE | STATE_SELECTED, 0, STATE_UNAVAILABLE);
testStates("tab-disabled", STATE_UNAVAILABLE, 0, STATE_FOCUSABLE | STATE_SELECTABLE | STATE_SELECTED);
gQueue = new eventQueue();
gQueue.push(new openColorpicker("colorpicker"));
gQueue.invoke(); // Will call SimpleTest.finish()
}
@@ -155,19 +153,16 @@
<menu id="menu-disabled" label="menu2" disabled="true">
<menupopup>
<menuitem id="menu-disabled-item1" label="menuitem2.1"/>
</menupopup>
</menu>
</menubar>
</toolbox>
- <scale id="scale" min="1" max="10"/>
- <scale id="scale-disabled" min="1" max="10" disabled="true"/>
-
<tabbox>
<tabs>
<tab id="tab" label="tab1" tooltip="tooltip"/>
<tab id="tab-disabled" label="tab1" disabled="true"/>
</tabs>
<tabpanels>
<tabpanel/>
<tabpanel/>
--- a/accessible/tests/mochitest/value/test_progress.xul
+++ b/accessible/tests/mochitest/value/test_progress.xul
@@ -18,20 +18,16 @@
<![CDATA[
function doTest()
{
// progressmeter
testValue("pm1", "50%", 50, 0, 100, 0);
testValue("pm2", "50%", 500, 0, 1000, 0);
testValue("pm3", "", 0, 0, 100, 0);
- // scale
- testValue("sc1", "500", 500, 0, 1000, 10);
- testValue("sc2", "", 0, 0, 0, 0);
-
// aria progressbar
testValue("ariapb1", "500", 500, 0, 1000, 0);
testValue("ariapb2", "", 0, 0, 0, 0);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
@@ -53,20 +49,16 @@
</pre>
</body>
<!-- progressmeter -->
<progressmeter id="pm1" value="50"/>
<progressmeter id="pm2" value="500" max="1000"/>
<progressmeter id="pm3"/>
- <!-- scale -->
- <scale id="sc1" value="500" max="1000" increment="10"/>
- <scale id="sc2"/>
-
<!-- aria -->
<description id="ariapb1" role="progressbar"
aria-valuenow="500" aria-valuemin="0" aria-valuemax="1000"/>
<description id="ariapb2" role="progressbar"/>
</hbox>
</window>
--- a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-xul.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-xul.js
@@ -13,17 +13,17 @@ const TEST_URL_2 =
add_task(async function() {
const {inspector} = await openInspectorForURL(TEST_URL);
info("Check the inspector toolbar");
let button = inspector.panelDoc.querySelector("#inspector-eyedropper-toggle");
ok(isDisabled(button), "The button is hidden in the toolbar");
info("Check the color picker");
- await selectNode("#scale", inspector);
+ await selectNode("#tree", inspector);
// Find the color swatch in the rule-view.
let ruleView = inspector.getPanel("ruleview").view;
let ruleViewDocument = ruleView.styleDocument;
let swatchEl = ruleViewDocument.querySelector(".ruleview-colorswatch");
info("Open the color picker");
let cPicker = ruleView.tooltips.getTooltip("colorPicker");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-xbl.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-xbl.js
@@ -7,21 +7,21 @@
const TEST_URL = URL_ROOT + "doc_inspector_highlighter_xbl.xul";
add_task(async function() {
const {inspector, toolbox, testActor} = await openInspectorForURL(TEST_URL);
await startPicker(toolbox);
- info("Selecting the scale");
- await moveMouseOver("#scale");
+ info("Selecting the tree");
+ await moveMouseOver("#tree");
await doKeyPick({key: "VK_RETURN", options: {}});
- is(inspector.selection.nodeFront.className, "scale-slider",
- "The .scale-slider inside the scale was selected");
+ is(inspector.selection.nodeFront.className, "tree-bodybox",
+ "The .tree-bodybox inside the tree was selected");
function doKeyPick(msg) {
info("Key pressed. Waiting for element to be picked");
testActor.synthesizeKey(msg);
return promise.all([
inspector.selection.once("new-node-front"),
inspector.once("inspector-updated")
]);
--- a/devtools/client/inspector/test/doc_inspector_highlighter_xbl.xul
+++ b/devtools/client/inspector/test/doc_inspector_highlighter_xbl.xul
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window title="Test that the picker works correctly with XBL anonymous nodes"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-<scale id="scale" style="background:red"/>
+<tree id="tree"/>
</window>
--- a/toolkit/content/tests/chrome/chrome.ini
+++ b/toolkit/content/tests/chrome/chrome.ini
@@ -164,19 +164,16 @@ skip-if = (verify && (os == 'win'))
support-files = window_preferences_beforeaccept.xul
[test_preferences_onsyncfrompreference.xul]
support-files = window_preferences_onsyncfrompreference.xul
[test_progressmeter.xul]
[test_props.xul]
[test_radio.xul]
[test_richlist_direction.xul]
[test_righttoleft.xul]
-[test_scale.xul]
-[test_scaledrag.xul]
-skip-if = (verify && (os == 'win'))
[test_screenPersistence.xul]
[test_scrollbar.xul]
[test_showcaret.xul]
[test_subframe_origin.xul]
[test_tabbox.xul]
[test_tabindex.xul]
[test_textbox_dictionary.xul]
[test_textbox_emptytext.xul]
--- a/toolkit/content/tests/chrome/test_focus_anons.xul
+++ b/toolkit/content/tests/chrome/test_focus_anons.xul
@@ -6,25 +6,23 @@
onload="SimpleTest.waitForFocus(runTests);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<label accesskey="a" control="menulist"/>
<label accesskey="b" control="textbox"/>
-<label accesskey="c" control="scale"/>
<menulist id="menulist" editable="true">
<menupopup>
<menuitem label="One"/>
</menupopup>
</menulist>
<textbox id="textbox"/>
-<scale id="scale"/>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
var gBlurs = 0, gFocuses = 0;
var gExpectedBlur = "";
@@ -48,59 +46,43 @@ function runTests()
gExpectedBlur = null;
gExpectedFocus = $("menulist").inputField;
$("menulist").focus();
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
$("textbox").focus();
- gExpectedBlur = gExpectedFocus;
- gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
- $("scale").focus();
-
var accessKeyDetails = (navigator.platform.includes("Mac")) ?
{altKey: true, ctrlKey: true} :
{altKey: true, shiftKey: true};
- gExpectedBlur = document.getAnonymousNodes($("scale"))[0];
+ gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("menulist").inputField;
synthesizeKey("a", accessKeyDetails);
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
synthesizeKey("b", accessKeyDetails);
- gExpectedBlur = gExpectedFocus;
- gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
- synthesizeKey("c", accessKeyDetails);
-
if (!navigator.platform.includes("Mac")) {
gExpectedBlur = gExpectedFocus;
- gExpectedFocus = $("textbox").inputField;
- synthesizeKey("KEY_Tab", {shiftKey: true});
-
- gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("menulist").inputField;
synthesizeKey("KEY_Tab", {shiftKey: true});
gExpectedBlur = gExpectedFocus;
gExpectedFocus = $("textbox").inputField;
synthesizeKey("KEY_Tab");
- gExpectedBlur = gExpectedFocus;
- gExpectedFocus = document.getAnonymousNodes($("scale"))[0];
- synthesizeKey("KEY_Tab");
-
- is(gBlurs, 9, "correct number of blurs");
- is(gFocuses, 10, "correct number of focuses");
+ is(gBlurs, 5, "correct number of blurs");
+ is(gFocuses, 6, "correct number of focuses");
}
else {
- is(gBlurs, 5, "correct number of blurs");
- is(gFocuses, 6, "correct number of focuses");
+ is(gBlurs, 3, "correct number of blurs");
+ is(gFocuses, 4, "correct number of focuses");
}
removeEventListener("focus", focusOccurred, true);
removeEventListener("blur", blurOccurred, true);
SimpleTest.finish();
}
deleted file mode 100644
--- a/toolkit/content/tests/chrome/test_scale.xul
+++ /dev/null
@@ -1,277 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
-<!--
- XUL Widget Test for scale
- -->
-<window title="scale" width="500" height="600"
- onload="setTimeout(testtag_scale, 0);"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
-
-<hbox>
- <vbox>
- <scale id="scale-horizontal-normal"/>
- <scale id="scale-horizontal-reverse" dir="reverse"/>
- </vbox>
- <scale id="scale-vertical-normal" orient="vertical"/>
- <scale id="scale-vertical-reverse" orient="vertical" dir="reverse"/>
-</hbox>
-
-<body xmlns="http://www.w3.org/1999/xhtml">
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-</pre>
-</body>
-
-<script>
-<![CDATA[
-
-SimpleTest.waitForExplicitFinish();
-
-function testtag_scale()
-{
- testtag_scale_inner("scale-horizontal-normal", true, false);
- testtag_scale_inner("scale-horizontal-reverse", true, true);
- testtag_scale_inner("scale-vertical-normal", false, false);
- testtag_scale_inner("scale-vertical-reverse", false, true);
-
- SimpleTest.finish();
-}
-
-function testtag_scale_inner(elementid, horiz, reverse)
-{
- var testid = (horiz ? "horizontal " : "vertical ") +
- (reverse ? "reverse " : "normal ");
-
- var element = document.getElementById(elementid);
-
- testtag_scale_States(element, 0, "", 0, 100, testid + "initial");
-
- element.min = 0;
- element.max = 10;
- testtag_scale_States(element, 0, "", 0, 10, testid + "first set");
-
- element.decrease();
- is(element.value, 0, testid + "decrease");
- element.increase();
- is(element.value, 1, testid + "increase");
- element.value = 0;
- is(element.value, 0, testid + "set value");
-
- testtag_scale_Increments(element, 0, 10, 6, 7, testid + "increase decrease");
-
- // check if changing the min and max adjusts the value to fit in range
- element.min = 5;
- testtag_scale_States(element, 5, "5", 5, 10, testid + "change min");
- element.value = 15;
- is(element.value, 10, testid + "change minmax value set too high");
- element.max = 8;
- is(element.value, 8, testid + "change max");
- element.value = 2;
- is(element.value, 5, testid + "change minmax set too low");
-
- // check negative values
- element.min = -15;
- element.max = -5;
- testtag_scale_States(element, -5, "-5", -15, -5, testid + "minmax negative");
- element.value = -15;
- is(element.value, -15, testid + "change max negative");
- testtag_scale_Increments(element, -15, -5, 7, 8, testid + "increase decrease negative");
-
- // check case when min is negative and max is positive
- element.min = -10;
- element.max = 35;
- testtag_scale_States(element, -10, "-10", -10, 35, testid + "minmax mixed sign");
- testtag_scale_Increments(element, -10, 35, 25, 30, testid + "increase decrease mixed sign");
-
- testtag_scale_UI(element, testid, horiz, reverse);
-}
-
-function testtag_scale_UI(element, testid, horiz, reverse)
-{
- element.min = 0;
- element.max = 20;
- element.value = 7;
- element.increment = 2;
- element.pageIncrement = 4;
-
- element.focus();
-
- var leftIncrements = horiz && reverse;
- var upDecrements = !horiz && !reverse;
- synthesizeKeyExpectEvent("VK_LEFT", { }, element, "change", testid + "key left");
- is(element.value, leftIncrements ? 9 : 5, testid + " key left");
- synthesizeKeyExpectEvent("VK_RIGHT", { }, element, "change", testid + "key right");
- is(element.value, 7, testid + " key right");
- synthesizeKeyExpectEvent("VK_UP", { }, element, "change", testid + "key up");
- is(element.value, upDecrements ? 5 : 9, testid + " key up");
- synthesizeKeyExpectEvent("VK_DOWN", { }, element, "change", testid + "key down");
- is(element.value, 7, testid + " key down");
-
- synthesizeKeyExpectEvent("VK_PAGE_UP", { }, element, "change", testid + "key page up");
- is(element.value, upDecrements ? 3 : 11, testid + " key page up");
- synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, element, "change", testid + "key page down");
- is(element.value, 7, testid + " key page down");
-
- synthesizeKeyExpectEvent("VK_HOME", { }, element, "change", testid + "key home");
- is(element.value, reverse ? 20 : 0, testid + " key home");
- synthesizeKeyExpectEvent("VK_END", { }, element, "change", testid + "key end");
- is(element.value, reverse ? 0 : 20, testid + " key end");
-
- testtag_scale_UI_Mouse(element, testid, horiz, reverse, 4);
-
- element.min = 4;
- element.pageIncrement = 3;
- testtag_scale_UI_Mouse(element, testid + " with min", horiz, reverse, 3);
-
- element.pageIncrement = 30;
- testtag_scale_UI_Mouse(element, testid + " with min past", horiz, reverse, 30);
-}
-
-function testtag_scale_UI_Mouse(element, testid, horiz, reverse, pinc)
-{
- var initial = reverse ? 8 : 12;
- var newval = initial + (reverse ? pinc : -pinc);
- var endval = initial;
- // in the pinc == 30 case, the page increment is large enough that it would
- // just cause the thumb to reach the end of the scale. Make sure that the
- // mouse click does not go past the end.
- if (pinc == 30) {
- newval = reverse ? 20 : 4;
- endval = reverse ? 4 : 20;
- }
- element.value = initial;
-
- var hmove = horiz ? 25 : 10;
- var vmove = horiz ? 10 : 25;
-
- var leftFn = function () { return reverse ? element.value < newval + 3 : element.value > newval - 3; }
- var rightFn = function () { return reverse ? element.value < endval - 3 : element.value < endval + 3; }
-
- // check that clicking the mouse on the trough moves the thumb properly
- synthesizeMouseExpectEvent(element, hmove, vmove, { }, element, "change", testid + "mouse on left movetoclick=default");
-
- if (navigator.platform.includes("Mac")) {
- if (pinc == 30)
- ok(element.value > 4, testid + " mouse on left movetoclick=default");
- else
- ok(leftFn, testid + " mouse on left movetoclick=default");
- }
- else {
- is(element.value, newval, testid + " mouse on left movetoclick=default");
- }
-
- var rect = element.getBoundingClientRect();
- synthesizeMouseExpectEvent(element, rect.right - rect.left - hmove,
- rect.bottom - rect.top - vmove, { },
- element, "change", testid + " mouse on right movetoclick=default");
-
- if (navigator.platform.includes("Mac")) {
- if (pinc == 30)
- ok(element.value < 20, testid + " mouse on right movetoclick=default");
- else
- ok(rightFn, testid + " mouse on right movetoclick=default");
- }
- else {
- is(element.value, endval, testid + " mouse on right movetoclick=default");
- }
-
- element.setAttribute("movetoclick", "true");
- element.value = initial;
-
- synthesizeMouseExpectEvent(element, hmove, vmove, { }, element, "change", testid + "mouse on left movetoclick=true");
- if (pinc == 30)
- ok(element.value > 4, testid + " mouse on left movetoclick=true");
- else
- ok(leftFn, testid + " mouse on left movetoclick=true");
-
- var rect = element.getBoundingClientRect();
- synthesizeMouseExpectEvent(element, rect.right - rect.left - hmove,
- rect.bottom - rect.top - vmove, { },
- element, "change", testid + " mouse on right movetoclick=true");
- if (pinc == 30)
- ok(element.value < 20, testid + " mouse on right movetoclick=true");
- else
- ok(rightFn, testid + " mouse on right movetoclick=true");
-
- element.setAttribute("movetoclick", "false");
- element.value = initial;
-
- synthesizeMouseExpectEvent(element, hmove, vmove, { }, element, "change", testid + "mouse on left movetoclick=false");
- is(element.value, newval, testid + " mouse on left movetoclick=false");
-
- var rect = element.getBoundingClientRect();
- synthesizeMouseExpectEvent(element, rect.right - rect.left - hmove,
- rect.bottom - rect.top - vmove, { },
- element, "change", testid + " mouse on right movetoclick=false");
- is(element.value, endval, testid + " mouse on right movetoclick=false");
-
- element.removeAttribute("movetoclick");
-
- element.value = reverse ? element.max : element.min;
-
- synthesizeMouse(element, 8, 8, { type: "mousedown" });
- synthesizeMouse(element, horiz ? 2000 : 8, horiz ? 8 : 2000, { type: "mousemove" });
- is(element.value, reverse ? element.min : element.max, testid + " move mouse too far after end");
- synthesizeMouse(element, 2, 2, { type: "mouseup" });
-
- synthesizeMouse(element, rect.width - 8, rect.height - 8, { type: "mousedown" });
- synthesizeMouse(element, horiz ? -2000 : rect.width - 8, horiz ? rect.height - 8 : -2000, { type: "mousemove" });
- is(element.value, reverse ? element.max : element.min, testid + " move mouse too far before start");
-
- synthesizeMouse(element, 2, 2, { type: "mouseup" });
-
- // now check if moving outside in both directions works. On Windows,
- // it should snap back to the original location.
- element.value = reverse ? element.max : element.min;
-
- var expected = (navigator.platform.includes("Win")) ? element.value :
- (reverse ? element.min : element.max);
- synthesizeMouse(element, 7, 7, { type: "mousedown" });
- synthesizeMouse(element, 2000, 2000, { type: "mousemove" });
- is(element.value, expected, testid + " move mouse ouside in both directions");
- synthesizeMouse(element, 2, 2, { type: "mouseup" });
-}
-
-function testtag_scale_States(element, evalue, evalueattr, emin, emax, testid)
-{
- is(element.getAttribute("value"), evalueattr, testid + " value attribute");
- is(element.value, evalue, testid + " value");
- is(element.min, emin, testid + " min");
- is(element.max, emax, testid + " max");
-}
-
-function testtag_scale_Increments(element, min, max, increment, pageIncrement, testid)
-{
- // check the increase and decrease methods
- element.increment = increment;
- element.increase();
- is(element.value, min + increment, testid + " increase 1");
- element.increase();
- is(element.value, max, testid + " increase 2");
- element.decrease();
- is(element.value, max - increment, testid + " decrease 1");
- element.decrease();
- is(element.value, min, testid + " decrease 2");
-
- // check the increasePage and decreasePage methods
- element.pageIncrement = pageIncrement;
- element.increasePage();
- is(element.value, min + pageIncrement, testid + " increasePage 1");
- element.increasePage();
- is(element.value, max, testid + " increasePage 2");
- element.decreasePage();
- is(element.value, max - pageIncrement, testid + " decreasePage 1");
- element.decreasePage();
- is(element.value, min, testid + " decreasePage 2");
-}
-
-]]>
-
-</script>
-
-</window>
deleted file mode 100644
--- a/toolkit/content/tests/chrome/test_scaledrag.xul
+++ /dev/null
@@ -1,197 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
-<!--
-XUL <scale> dragging tests
--->
-<window title="Dragging XUL scale tests" width="500" height="600"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
-
- <hbox flex="1">
- <scale id="scale1" orient="horizontal" flex="1" min="0" max="4" value="2"/>
- <scale id="scale2" orient="vertical" flex="1" min="0" max="4" value="2"/>
- <scale id="scale3" orient="horizontal" flex="1" movetoclick="true" min="0" max="4" value="2"/>
- </hbox>
-
-<body xmlns="http://www.w3.org/1999/xhtml">
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-</pre>
-</body>
-
-<script>
-<![CDATA[
-
-SimpleTest.waitForExplicitFinish();
-function getThumb(aScale) {
- return document.getAnonymousElementByAttribute(aScale, "class", "scale-thumb");
-}
-
-function sendTouch(aType, aRect, aDX, aDY, aMods) {
- var cwu = SpecialPowers.getDOMWindowUtils(window);
- var x = aRect.left + aRect.width/2 + aDX;
- var y = aRect.top + aRect.height/2 + aDY;
- if (/mouse/.test(aType))
- cwu.sendMouseEvent(aType, x, y, 0, 1, aMods || 0, false);
- else
- cwu.sendTouchEvent(aType, [0], [x], [y], [1], [1], [0], [1], 1, aMods || 0, true);
-}
-
-function getOffset(aScale, aDir) {
- var rect = aScale.getBoundingClientRect();
- var d = aScale.orient == "horizontal" ? rect.width/4 : rect.height/4;
- switch (aDir) {
- case "right": return [ d, 0];
- case "left": return [-1*d, 0];
- case "up": return [ 0,-1*d];
- case "down": return [ 0, d];
- case "downleft": return [ -1*d, d];
- case "upleft": return [ -1*d,-1*d];
- case "downright": return [d, d];
- case "upright": return [d,-1*d];
- }
- return [0,0];
-}
-
-function testTouchDragThumb(aDesc, aId, aDir, aVal1, aVal2, aMods) {
- info(aDesc);
- var scale = document.getElementById(aId);
- var [x,y] = getOffset(scale, aDir);
-
- sendTouch("touchstart", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal1, "Touchstart on thumb has correct value");
- sendTouch("touchmove", getThumb(scale).getBoundingClientRect(), x, y, aMods);
- sendTouch("touchend", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal2, "After touch " + (aDir ? ("and drag " + aDir + " ") : "") + "on thumb, scale has correct value");
-
- scale.value = 2;
-}
-
-function testMouseDragThumb(aDesc, aId, aDir, aVal1, aVal2, aMods) {
- info(aDesc);
- var scale = document.getElementById(aId);
- var [x,y] = getOffset(scale, aDir);
-
- sendTouch("mousedown", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal1, "Mousedown on thumb has correct value");
- sendTouch("mousemove", getThumb(scale).getBoundingClientRect(), x, y, aMods);
- sendTouch("mouseup", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal2, "After mouseup " + (aDir ? ("and drag " + aDir + " ") : "") + "on thumb, scale has correct value");
-
- scale.value = 2;
-}
-
-function testTouchDragSlider(aDesc, aId, aDir, aVal1, aVal2, aMods) {
- info(aDesc);
- var scale = document.getElementById(aId);
- var [x,y] = getOffset(scale, aDir);
-
- sendTouch("touchstart", getThumb(scale).getBoundingClientRect(), x, y, aMods);
- is(scale.value, aVal1, "Touchstart on slider has correct value");
- sendTouch("touchmove", getThumb(scale).getBoundingClientRect(), -x, -y, aMods);
- sendTouch("touchend", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal2, "After touch " + (aDir ? ("and drag " + aDir + " ") : "") + "on slider, scale has correct value");
-
- scale.value = 2;
-}
-
-function testMouseDragSlider(aDesc, aId, aDir, aVal1, aVal2, aMods) {
- info(aDesc);
- var scale = document.getElementById(aId);
- var [x,y] = getOffset(scale, aDir);
-
- sendTouch("mousedown", getThumb(scale).getBoundingClientRect(), x, y, aMods);
- is(scale.value, aVal1, "Mousedown on slider has correct value");
- sendTouch("mousemove", getThumb(scale).getBoundingClientRect(), -x, -y, aMods);
- sendTouch("mouseup", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
- is(scale.value, aVal2, "After mouseup " + (aDir ? ("and drag " + aDir + " ") : "") + "on slider, scale has correct value");
-
- scale.value = 2;
-}
-
-function runTests() {
- // test dragging a horizontal slider with touch events by tapping on the thumb
- testTouchDragThumb("Touch Horizontal Thumb", "scale1", "", 2, 2);
- testTouchDragThumb("TouchDrag Horizontal Thumb Left", "scale1", "left", 2, 1);
- testTouchDragThumb("TouchDrag Horizontal Thumb Right", "scale1", "right", 2, 3);
- testTouchDragThumb("TouchDrag Horizontal Thumb Up", "scale1", "up", 2, 2);
- testTouchDragThumb("TouchDrag Horizontal Thumb Down", "scale1", "down", 2, 2);
- testTouchDragThumb("TouchDrag Horizontal Thumb Downleft", "scale1", "downleft", 2, 1);
- testTouchDragThumb("TouchDrag Horizontal Thumb Upleft", "scale1", "upleft", 2, 1);
- testTouchDragThumb("TouchDrag Horizontal Thumb Upright", "scale1", "upright", 2, 3);
- testTouchDragThumb("TouchDrag Horizontal Thumb Downright", "scale1", "downright", 2, 3);
-
- // test dragging a horizontal slider with mouse events by clicking on the thumb
- testMouseDragThumb("Click Horizontal Thumb", "scale1", "", 2, 2);
- testMouseDragThumb("MouseDrag Horizontal Thumb Left", "scale1", "left", 2, 1);
- testMouseDragThumb("MouseDrag Horizontal Thumb Right", "scale1", "right", 2, 3);
- testMouseDragThumb("MouseDrag Horizontal Thumb Up", "scale1", "up", 2, 2);
- testMouseDragThumb("MouseDrag Horizontal Thumb Down", "scale1", "down", 2, 2);
- testMouseDragThumb("MouseDrag Horizontal Thumb Downleft", "scale1", "downleft", 2, 1);
- testMouseDragThumb("MouseDrag Horizontal Thumb Upleft", "scale1", "upleft", 2, 1);
- testMouseDragThumb("MouseDrag Horizontal Thumb Upright", "scale1", "upright", 2, 3);
- testMouseDragThumb("MouseDrag Horizontal Thumb Downright", "scale1", "downright", 2, 3);
-
- // test dragging a vertical slider with touch events by tapping on the thumb
- testTouchDragThumb("Touch Vertical Thumb", "scale2", "", 2, 2);
- testTouchDragThumb("TouchDrag Vertical Thumb Left", "scale2", "left", 2, 2);
- testTouchDragThumb("TouchDrag Vertical Thumb Right", "scale2", "right", 2, 2);
- testTouchDragThumb("TouchDrag Vertical Thumb Up", "scale2", "up", 2, 1);
- testTouchDragThumb("TouchDrag Vertical Thumb Down", "scale2", "down", 2, 3);
- testTouchDragThumb("TouchDrag Vertical Thumb Downleft", "scale2", "downleft", 2, 3);
- testTouchDragThumb("TouchDrag Vertical Thumb Upleft", "scale2", "upleft", 2, 1);
- testTouchDragThumb("TouchDrag Vertical Thumb Upright", "scale2", "upright", 2, 1);
- testTouchDragThumb("TouchDrag Vertical Thumb Downright", "scale2", "downright", 2, 3);
-
- // test dragging a vertical slider with mouse events by clicking on the thumb
- testMouseDragThumb("Click Vertical Thumb", "scale2", "", 2, 2);
- testMouseDragThumb("MouseDrag Vertical Thumb Left", "scale2", "left", 2, 2);
- testMouseDragThumb("MouseDrag Vertical Thumb Right", "scale2", "right", 2, 2);
- testMouseDragThumb("MouseDrag Vertical Thumb Up", "scale2", "up", 2, 1);
- testMouseDragThumb("MouseDrag Vertical Thumb Down", "scale2", "down", 2, 3);
- testMouseDragThumb("MouseDrag Vertical Thumb Downleft", "scale2", "downleft", 2, 3);
- testMouseDragThumb("MouseDrag Vertical Thumb Upleft", "scale2", "upleft", 2, 1);
- testMouseDragThumb("MouseDrag Vertical Thumb Upright", "scale2", "upright", 2, 1);
- testMouseDragThumb("MouseDrag Vertical Thumb Downright", "scale2", "downright", 2, 3);
-
- var isMac = /Mac/.test(navigator.platform);
-
- // test dragging a slider by tapping off the thumb
- testTouchDragSlider("TouchDrag Slider Left", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0);
- testTouchDragSlider("TouchDrag Slider Right", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4);
- testMouseDragSlider("MouseDrag Slider Left", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0);
- testMouseDragSlider("MouseDrag Slider Right", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4);
-
- // test dragging a slider by tapping off the thumb and holding shift
- // modifiers don't affect touch events
- var mods = /Mac/.test(navigator.platform) ? Ci.nsIDOMWindowUtils.MODIFIER_ALT :
- Ci.nsIDOMWindowUtils.MODIFIER_SHIFT;
- testTouchDragSlider("TouchDrag Slider Left+Shift", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0, mods);
- testTouchDragSlider("TouchDrag Slider Right+Shift", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4, mods);
- testMouseDragSlider("MouseDrag Slider Left+Shift", "scale1", "left", isMac ? 0 : 1, isMac ? 0 : 2, mods);
- testMouseDragSlider("MouseDrag Slider Right+Shift", "scale1", "right", isMac ? 4 : 3, isMac ? 4 : 2, mods);
-
- // test dragging a slider with movetoclick="true" by tapping off the thumb
- testTouchDragSlider("TouchDrag Slider Left+MoveToClick", "scale3", "left", 1, 2);
- testTouchDragSlider("TouchDrag Slider Right+MoveToClick", "scale3", "right", 3, 2);
- testMouseDragSlider("MouseDrag Slider Left+MoveToClick", "scale3", "left", 1, 2);
- testMouseDragSlider("MouseDrag Slider Right+MoveToClick", "scale3", "right", 3, 2);
-
- // test dragging a slider by tapping off the thumb and holding shift
- // modifiers don't affect touch events
- testTouchDragSlider("MouseDrag Slider Left+MoveToClick+Shift", "scale3", "left", 1, 2, mods);
- testTouchDragSlider("MouseDrag Slider Right+MoveToClick+Shift", "scale3", "right", 3, 2, mods);
- testMouseDragSlider("MouseDrag Slider Left+MoveToClick+Shift", "scale3", "left", 0, 0, mods);
- testMouseDragSlider("MouseDrag Slider Right+MoveToClick+Shift", "scale3", "right", 4, 4, mods);
-
- SimpleTest.finish();
-}
-
-addLoadEvent(function() { SimpleTest.executeSoon(runTests); });
-]]></script>
-
-</window>