test_bug583533.html (2278B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=583533 5 --> 6 <head> 7 <title>Test for Bug 583514</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583533">Mozilla Bug 583533</a> 13 <p id="display"></p> 14 <div id="content"> 15 <div id="e" accesskey="a"> 16 </div> 17 </div> 18 <pre id="test"> 19 <script type="application/javascript"> 20 21 /** Test for Bug 583533 */ 22 23 var sbs = SpecialPowers.Cc['@mozilla.org/intl/stringbundle;1']. 24 getService(SpecialPowers.Ci.nsIStringBundleService); 25 var bundle = sbs.createBundle("chrome://global-platform/locale/platformKeys.properties"); 26 27 var shiftText = bundle.GetStringFromName("VK_SHIFT"); 28 var altText = bundle.GetStringFromName("VK_ALT"); 29 var controlText = bundle.GetStringFromName("VK_CONTROL"); 30 var metaText = bundle.GetStringFromName("VK_COMMAND_OR_WIN"); 31 var separatorText = bundle.GetStringFromName("MODIFIER_SEPARATOR"); 32 33 var modifier = SpecialPowers.getIntPref("ui.key.contentAccess"); 34 35 var isShift; 36 var isAlt; 37 var isControl; 38 var isMeta; 39 40 is(modifier < 16 && modifier >= 0, true, "Modifier in range"); 41 42 // There are no consts for the mask of this prefs. 43 if (modifier & 8) { 44 isMeta = true; 45 } 46 if (modifier & 1) { 47 isShift = true; 48 } 49 if (modifier & 2) { 50 isControl = true; 51 } 52 if (modifier & 4) { 53 isAlt = true; 54 } 55 56 var label = ""; 57 58 if (isControl) 59 label += controlText + separatorText; 60 if (isMeta) 61 label += metaText + separatorText; 62 if (isAlt) 63 label += altText + separatorText; 64 if (isShift) 65 label += shiftText + separatorText; 66 67 label += document.getElementById("e").accessKey; 68 69 is(label, document.getElementById("e").accessKeyLabel, "JS and C++ agree on accessKeyLabel"); 70 71 /** Test for Bug 808964 */ 72 73 var div = document.createElement("div"); 74 document.body.appendChild(div); 75 76 is(div.accessKeyLabel, "", "accessKeyLabel should be empty string"); 77 78 </script> 79 </pre> 80 </body> 81 </html>