constants.js (5934B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Constants used in various panels, shared between client and the server. 9 */ 10 11 /* Accessibility Panel ====================================================== */ 12 13 // List of audit types. 14 const AUDIT_TYPE = { 15 CONTRAST: "CONTRAST", 16 KEYBOARD: "KEYBOARD", 17 TEXT_LABEL: "TEXT_LABEL", 18 }; 19 20 // Types of issues grouped by audit types. 21 const ISSUE_TYPE = { 22 [AUDIT_TYPE.KEYBOARD]: { 23 // Focusable accessible objects have no semantics. 24 FOCUSABLE_NO_SEMANTICS: "FOCUSABLE_NO_SEMANTICS", 25 // Tab index greater than 0 is provided. 26 FOCUSABLE_POSITIVE_TABINDEX: "FOCUSABLE_POSITIVE_TABINDEX", 27 // Interactive accesible objects do not have an associated action. 28 INTERACTIVE_NO_ACTION: "INTERACTIVE_NO_ACTION", 29 // Interative accessible objcets are not focusable. 30 INTERACTIVE_NOT_FOCUSABLE: "INTERACTIVE_NOT_FOCUSABLE", 31 // Accessible objects can only be interacted with a mouse. 32 MOUSE_INTERACTIVE_ONLY: "MOUSE_INTERACTIVE_ONLY", 33 // Focusable accessible objects have no focus styling. 34 NO_FOCUS_VISIBLE: "NO_FOCUS_VISIBLE", 35 }, 36 [AUDIT_TYPE.TEXT_LABEL]: { 37 // <AREA> name is provided via "alt" attribute. 38 AREA_NO_NAME_FROM_ALT: "AREA_NO_NAME_FROM_ALT", 39 // Dialog name is not provided. 40 DIALOG_NO_NAME: "DIALOG_NO_NAME", 41 // Document title is not provided. 42 DOCUMENT_NO_TITLE: "DOCUMENT_NO_TITLE", 43 // <EMBED> name is not provided. 44 EMBED_NO_NAME: "EMBED_NO_NAME", 45 // <FIGURE> name is not provided. 46 FIGURE_NO_NAME: "FIGURE_NO_NAME", 47 // <FIELDSET> name is not provided. 48 FORM_FIELDSET_NO_NAME: "FORM_FIELDSET_NO_NAME", 49 // <FIELDSET> name is not provided via <LEGEND> element. 50 FORM_FIELDSET_NO_NAME_FROM_LEGEND: "FORM_FIELDSET_NO_NAME_FROM_LEGEND", 51 // Form element's name is not provided. 52 FORM_NO_NAME: "FORM_NO_NAME", 53 // Form element's name is not visible. 54 FORM_NO_VISIBLE_NAME: "FORM_NO_VISIBLE_NAME", 55 // <OPTGROUP> name is not provided via "label" attribute. 56 FORM_OPTGROUP_NO_NAME_FROM_LABEL: "FORM_OPTGROUP_NO_NAME_FROM_LABEL", 57 // <FRAME> name is not provided. 58 FRAME_NO_NAME: "FRAME_NO_NAME", 59 // <H{1, 2, ...}> has no content. 60 HEADING_NO_CONTENT: "HEADING_NO_CONTENT", 61 // <H{1, 2, ...}> name is not provided. 62 HEADING_NO_NAME: "HEADING_NO_NAME", 63 // <IFRAME> name is not provided via "title" attribute. 64 IFRAME_NO_NAME_FROM_TITLE: "IFRAME_NO_NAME_FROM_TITLE", 65 // <IMG> name is not provided (including empty name). 66 IMAGE_NO_NAME: "IMAGE_NO_NAME", 67 // Interactive element's name is not provided. 68 INTERACTIVE_NO_NAME: "INTERACTIVE_NO_NAME", 69 // <MGLYPH> name is no provided. 70 MATHML_GLYPH_NO_NAME: "MATHML_GLYPH_NO_NAME", 71 // Toolbar's name is not provided when more than one toolbar is present. 72 TOOLBAR_NO_NAME: "TOOLBAR_NO_NAME", 73 }, 74 }; 75 76 // Constants associated with WCAG guidelines score system. 77 const SCORES = { 78 // Satisfies WCAG AA guidelines. 79 AA: "AA", 80 // Satisfies WCAG AAA guidelines. 81 AAA: "AAA", 82 // Elevates accessibility experience. 83 BEST_PRACTICES: "BEST_PRACTICES", 84 // Does not satisfy the baseline WCAG guidelines. 85 FAIL: "FAIL", 86 // Partially satisfies the WCAG AA guidelines. 87 WARNING: "WARNING", 88 }; 89 90 // List of simulation types. 91 const SIMULATION_TYPE = { 92 // No red color blindness 93 PROTANOPIA: "PROTANOPIA", 94 // No green color blindness 95 DEUTERANOPIA: "DEUTERANOPIA", 96 // No blue color blindness 97 TRITANOPIA: "TRITANOPIA", 98 // Absense of color vision 99 ACHROMATOPSIA: "ACHROMATOPSIA", 100 // Low contrast 101 CONTRAST_LOSS: "CONTRAST_LOSS", 102 }; 103 104 /* Compatibility Panel ====================================================== */ 105 106 const COMPATIBILITY_ISSUE_TYPE = { 107 CSS_PROPERTY: "CSS_PROPERTY", 108 CSS_PROPERTY_ALIASES: "CSS_PROPERTY_ALIASES", 109 }; 110 111 /* Style Editor ============================================================= */ 112 113 // The PageStyle actor flattens the DOM CSS objects a little bit, merging 114 // Rules and their Styles into one actor. For elements (which have a style 115 // but no associated rule) we fake a rule with the following style id. 116 // This `id` is intended to be used instead of a regular CSSRule Type constant. 117 // See https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants 118 const ELEMENT_STYLE = 100; 119 const PRES_HINTS = 200; 120 121 /* WebConsole Panel ========================================================= */ 122 123 const MESSAGE_CATEGORY = { 124 CSS_PARSER: "CSS Parser", 125 }; 126 127 /* Debugger ============================================================= */ 128 129 // Map protocol pause "why" reason to a valid L10N key (in devtools/shared/locales/en-US/debugger-paused-reasons.ftl) 130 const DEBUGGER_PAUSED_REASONS_L10N_MAPPING = { 131 debuggerStatement: "whypaused-debugger-statement", 132 breakpoint: "whypaused-breakpoint", 133 exception: "whypaused-exception", 134 resumeLimit: "whypaused-resume-limit", 135 breakpointConditionThrown: "whypaused-breakpoint-condition-thrown", 136 eventBreakpoint: "whypaused-event-breakpoint", 137 getWatchpoint: "whypaused-get-watchpoint", 138 setWatchpoint: "whypaused-set-watchpoint", 139 mutationBreakpoint: "whypaused-mutation-breakpoint", 140 interrupted: "whypaused-interrupted", 141 142 // V8 143 DOM: "whypaused-breakpoint", 144 EventListener: "whypaused-pause-on-dom-events", 145 XHR: "whypaused-xhr", 146 promiseRejection: "whypaused-promise-rejection", 147 assert: "whypaused-assert", 148 debugCommand: "whypaused-debug-command", 149 other: "whypaused-other", 150 }; 151 152 /* Exports ============================================================= */ 153 154 module.exports = { 155 accessibility: { 156 AUDIT_TYPE, 157 ISSUE_TYPE, 158 SCORES, 159 SIMULATION_TYPE, 160 }, 161 COMPATIBILITY_ISSUE_TYPE, 162 DEBUGGER_PAUSED_REASONS_L10N_MAPPING, 163 MESSAGE_CATEGORY, 164 style: { 165 ELEMENT_STYLE, 166 PRES_HINTS, 167 }, 168 };