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 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Menulist value property" |
michael@0 | 6 | onload="setTimeout(runTests, 0);" |
michael@0 | 7 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <menulist id="list"> |
michael@0 | 13 | <menupopup> |
michael@0 | 14 | <menuitem id="i0" label="Zero" value="0"/> |
michael@0 | 15 | <menuitem id="i1" label="One" value="item1"/> |
michael@0 | 16 | <menuitem id="i2" label="Two" value="item2"/> |
michael@0 | 17 | <menuitem id="ifalse" label="False" value="false"/> |
michael@0 | 18 | <menuitem id="iempty" label="Empty" value=""/> |
michael@0 | 19 | </menupopup> |
michael@0 | 20 | </menulist> |
michael@0 | 21 | |
michael@0 | 22 | <script class="testbody" type="application/javascript"> |
michael@0 | 23 | <![CDATA[ |
michael@0 | 24 | |
michael@0 | 25 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 26 | |
michael@0 | 27 | function runTests() |
michael@0 | 28 | { |
michael@0 | 29 | var list = document.getElementById("list"); |
michael@0 | 30 | |
michael@0 | 31 | list.value = "item2"; |
michael@0 | 32 | is(list.value, "item2", "Check list value after setting value"); |
michael@0 | 33 | is(list.getAttribute("label"), "Two", "Check list label after setting value"); |
michael@0 | 34 | |
michael@0 | 35 | list.selectedItem = null; |
michael@0 | 36 | is(list.value, "", "Check list value after setting selectedItem to null"); |
michael@0 | 37 | is(list.getAttribute("label"), "", "Check list label after setting selectedItem to null"); |
michael@0 | 38 | |
michael@0 | 39 | // select something again to make sure the label is not already empty |
michael@0 | 40 | list.selectedIndex = 1; |
michael@0 | 41 | is(list.value, "item1", "Check list value after setting selectedIndex"); |
michael@0 | 42 | is(list.getAttribute("label"), "One", "Check list label after setting selectedIndex"); |
michael@0 | 43 | |
michael@0 | 44 | // check that an item can have the "false" value |
michael@0 | 45 | list.value = false; |
michael@0 | 46 | is(list.value, "false", "Check list value after setting it to false"); |
michael@0 | 47 | is(list.getAttribute("label"), "False", "Check list labem after setting value to false"); |
michael@0 | 48 | |
michael@0 | 49 | // check that an item can have the "0" value |
michael@0 | 50 | list.value = 0; |
michael@0 | 51 | is(list.value, "0", "Check list value after setting it to 0"); |
michael@0 | 52 | is(list.getAttribute("label"), "Zero", "Check list label after setting value to 0"); |
michael@0 | 53 | |
michael@0 | 54 | // check that an item can have the empty string value. |
michael@0 | 55 | list.value = ""; |
michael@0 | 56 | is(list.value, "", "Check list value after setting it to an empty string"); |
michael@0 | 57 | is(list.getAttribute("label"), "Empty", "Check list label after setting value to an empty string"); |
michael@0 | 58 | |
michael@0 | 59 | // select something again to make sure the label is not already empty |
michael@0 | 60 | list.selectedIndex = 1; |
michael@0 | 61 | // set the value to null and test it (bug 408940) |
michael@0 | 62 | list.value = null; |
michael@0 | 63 | is(list.value, "", "Check list value after setting value to null"); |
michael@0 | 64 | is(list.getAttribute("label"), "", "Check list label after setting value to null"); |
michael@0 | 65 | |
michael@0 | 66 | // select something again to make sure the label is not already empty |
michael@0 | 67 | list.selectedIndex = 1; |
michael@0 | 68 | // set the value to undefined and test it (bug 408940) |
michael@0 | 69 | list.value = undefined; |
michael@0 | 70 | is(list.value, "", "Check list value after setting value to undefined"); |
michael@0 | 71 | is(list.getAttribute("label"), "", "Check list label after setting value to undefined"); |
michael@0 | 72 | |
michael@0 | 73 | // select something again to make sure the label is not already empty |
michael@0 | 74 | list.selectedIndex = 1; |
michael@0 | 75 | // set the value to something that does not exist in any menuitem of the list |
michael@0 | 76 | // and make sure the previous label is removed |
michael@0 | 77 | list.value = "this does not exist"; |
michael@0 | 78 | is(list.value, "this does not exist", "Check the list value after setting it to something not associated witn an existing menuitem"); |
michael@0 | 79 | is(list.getAttribute("label"), "", "Check that the list label is empty after selecting a nonexistent item"); |
michael@0 | 80 | |
michael@0 | 81 | SimpleTest.finish(); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | ]]> |
michael@0 | 85 | </script> |
michael@0 | 86 | |
michael@0 | 87 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 88 | <p id="display"> |
michael@0 | 89 | </p> |
michael@0 | 90 | <div id="content" style="display: none"> |
michael@0 | 91 | </div> |
michael@0 | 92 | <pre id="test"> |
michael@0 | 93 | </pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | |
michael@0 | 96 | </window> |