Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for Bug 477700</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | </div> |
michael@0 | 12 | |
michael@0 | 13 | <textarea id="textarea" style="-moz-appearance: none; border: 2px solid black; padding: 3px; box-sizing: border-box; min-width: 15px; min-height: 15px;">Text</textarea> |
michael@0 | 14 | |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | |
michael@0 | 18 | /** Test for textbox resizing **/ |
michael@0 | 19 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 20 | addLoadEvent(function() SimpleTest.executeSoon(doTheTest)); |
michael@0 | 21 | |
michael@0 | 22 | // -1 means use the default value which is 'both', then test explicitly |
michael@0 | 23 | // setting each possible value. |
michael@0 | 24 | var currentResize = -1; |
michael@0 | 25 | var currentBoxSizing = 0; |
michael@0 | 26 | var currentPointer = 0; |
michael@0 | 27 | var resizeTypes = [ "horizontal", "vertical", "none", "inherit", "both" ]; |
michael@0 | 28 | var boxSizingTypes = [ "", "border-box", "padding-box" ]; |
michael@0 | 29 | var pointerTypes = [ synthesizeMouse, synthesizeTouch] |
michael@0 | 30 | |
michael@0 | 31 | function doTheTest() { |
michael@0 | 32 | runTest(pointerTypes[currentPointer]); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function runTest(aPointerFunc) { |
michael@0 | 36 | var boxSizingText = " with box sizing " + (currentBoxSizing ? boxSizingTypes[currentBoxSizing] : "content-box"); |
michael@0 | 37 | |
michael@0 | 38 | var textarea = $("textarea"); |
michael@0 | 39 | var rect = textarea.getBoundingClientRect(); |
michael@0 | 40 | var touch = aPointerFunc.name.match(/Touch/); |
michael@0 | 41 | // -1 means use the default value of resize, i.e. "both" |
michael@0 | 42 | var type = (currentResize == -1) ? "both" : resizeTypes[currentResize]; |
michael@0 | 43 | // assume that the resizer is in the lower right corner |
michael@0 | 44 | |
michael@0 | 45 | aPointerFunc(textarea, rect.width - 10, rect.height - 10, { type: touch ? "touchstart" : "mousedown" }); |
michael@0 | 46 | aPointerFunc(textarea, rect.width + 40, rect.height + 40, { type: touch ? "touchmove" : "mousemove" }); |
michael@0 | 47 | |
michael@0 | 48 | var newrect = textarea.getBoundingClientRect(); |
michael@0 | 49 | var hchange = (type == "both" || type == "horizontal"); |
michael@0 | 50 | var vchange = (type == "both" || type == "vertical"); |
michael@0 | 51 | |
michael@0 | 52 | is(Math.round(newrect.width), Math.round(rect.width + (hchange ? 50 : 0)), |
michael@0 | 53 | type + " width has increased" + boxSizingText + " using " + aPointerFunc.name); |
michael@0 | 54 | is(Math.round(newrect.height), Math.round(rect.height + (vchange ? 50 : 0)), |
michael@0 | 55 | type + " height has increased" + boxSizingText + " using " + aPointerFunc.name); |
michael@0 | 56 | |
michael@0 | 57 | aPointerFunc(textarea, rect.width - 20, rect.height - 20, { type: touch ? "touchmove" : "mousemove" }); |
michael@0 | 58 | |
michael@0 | 59 | newrect = textarea.getBoundingClientRect(); |
michael@0 | 60 | |
michael@0 | 61 | is(Math.round(newrect.width), Math.round(rect.width - (hchange ? 10 : 0)), |
michael@0 | 62 | type + " width has decreased" + boxSizingText + " using " + aPointerFunc.name); |
michael@0 | 63 | is(Math.round(newrect.height), Math.round(rect.height - (vchange ? 10 : 0)), |
michael@0 | 64 | type + " height has decreased" + boxSizingText + " using " + aPointerFunc.name); |
michael@0 | 65 | |
michael@0 | 66 | aPointerFunc(textarea, rect.width - 220, rect.height - 220, { type: touch ? "touchmove" : "mousemove" }); |
michael@0 | 67 | |
michael@0 | 68 | newrect = textarea.getBoundingClientRect(); |
michael@0 | 69 | ok(hchange ? newrect.width >= 15 : Math.round(newrect.width) == Math.round(rect.width), |
michael@0 | 70 | type + " width decreased below minimum" + boxSizingText + " using " + newrect.width); |
michael@0 | 71 | ok(vchange ? newrect.height >= 15 : Math.round(newrect.height) == Math.round(rect.height), |
michael@0 | 72 | type + " height decreased below minimum" + boxSizingText + " using " + aPointerFunc.name); |
michael@0 | 73 | |
michael@0 | 74 | aPointerFunc(textarea, rect.width - 8, rect.height - 8, { type: touch ? "touchend" : "mouseup" }); |
michael@0 | 75 | |
michael@0 | 76 | textarea.style.width = "auto"; |
michael@0 | 77 | textarea.style.height = "auto"; |
michael@0 | 78 | |
michael@0 | 79 | if (currentBoxSizing++ <= boxSizingTypes.length) { |
michael@0 | 80 | textarea.style.MozBoxSizing = boxSizingTypes[currentBoxSizing]; |
michael@0 | 81 | SimpleTest.executeSoon(doTheTest); |
michael@0 | 82 | } else { |
michael@0 | 83 | currentBoxSizing = 0; |
michael@0 | 84 | if (++currentResize < resizeTypes.length) { |
michael@0 | 85 | textarea.style.resize = resizeTypes[currentResize]; |
michael@0 | 86 | SimpleTest.executeSoon(doTheTest); |
michael@0 | 87 | } else { |
michael@0 | 88 | currentResize = -1; |
michael@0 | 89 | textarea.style.resize = ""; |
michael@0 | 90 | if (++currentPointer < pointerTypes.length) { |
michael@0 | 91 | SimpleTest.executeSoon(doTheTest); |
michael@0 | 92 | } else { |
michael@0 | 93 | SimpleTest.finish(); |
michael@0 | 94 | } |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | </script> |
michael@0 | 100 | </pre> |
michael@0 | 101 | </body> |
michael@0 | 102 | </html> |