test_bug583533.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 type="application/javascript" 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. /** Test for Bug 583533 **/
  21. var sbs = SpecialPowers.Cc['@mozilla.org/intl/stringbundle;1'].
  22. getService(SpecialPowers.Ci.nsIStringBundleService);
  23. var bundle = sbs.createBundle("chrome://global-platform/locale/platformKeys.properties");
  24. var shiftText = bundle.GetStringFromName("VK_SHIFT");
  25. var altText = bundle.GetStringFromName("VK_ALT");
  26. var controlText = bundle.GetStringFromName("VK_CONTROL");
  27. var metaText = bundle.GetStringFromName("VK_META");
  28. var separatorText = bundle.GetStringFromName("MODIFIER_SEPARATOR");
  29. var modifier = SpecialPowers.getIntPref("ui.key.contentAccess");
  30. var isShift;
  31. var isAlt;
  32. var isControl;
  33. var isMeta;
  34. is(modifier < 16 && modifier >= 0, true, "Modifier in range");
  35. // There are no consts for the mask of this prefs.
  36. if (modifier & 8) {
  37. isMeta = true;
  38. }
  39. if (modifier & 1) {
  40. isShift = true;
  41. }
  42. if (modifier & 2) {
  43. isControl = true;
  44. }
  45. if (modifier & 4) {
  46. isAlt = true;
  47. }
  48. var label = "";
  49. if (isControl)
  50. label += controlText + separatorText;
  51. if (isMeta)
  52. label += metaText + separatorText;
  53. if (isAlt)
  54. label += altText + separatorText;
  55. if (isShift)
  56. label += shiftText + separatorText;
  57. label += document.getElementById("e").accessKey;
  58. is(label, document.getElementById("e").accessKeyLabel, "JS and C++ agree on accessKeyLabel");
  59. /** Test for Bug 808964 **/
  60. var div = document.createElement("div");
  61. document.body.appendChild(div);
  62. is(div.accessKeyLabel, "", "accessKeyLabel should be empty string");
  63. </script>
  64. </pre>
  65. </body>
  66. </html>