morgan pushed to branch mullvad-browser-153.0esr-16.0-1 at The Tor Project / Applications / Mullvad Browser

Commits:

2 changed files:

Changes:

  • toolkit/content/widgets/moz-message-bar/moz-message-bar.mjs
    ... ... @@ -65,8 +65,9 @@ export default class MozMessageBar extends MozLitElement {
    65 65
         supportPage: { type: String },
    
    66 66
         messageL10nId: { type: String },
    
    67 67
         messageL10nArgs: { type: String },
    
    68
    -    role: { type: String, reflect: true },
    
    69
    -    useAlertRole: { type: Boolean },
    
    68
    +    // Move the role from the widget to its shadow root, where we can apply
    
    69
    +    // aria-labelledby and aria-describedby. tor-browser#45186.
    
    70
    +    role: { type: String, mapped: true },
    
    70 71
       };
    
    71 72
     
    
    72 73
       constructor() {
    
    ... ... @@ -127,8 +128,6 @@ export default class MozMessageBar extends MozLitElement {
    127 128
          * @type {string}
    
    128 129
          */
    
    129 130
         this.role = "alert";
    
    130
    -
    
    131
    -    this.useAlertRole = true;
    
    132 131
       }
    
    133 132
     
    
    134 133
       onActionSlotchange() {
    
    ... ... @@ -170,17 +169,6 @@ export default class MozMessageBar extends MozLitElement {
    170 169
         ></slot>`;
    
    171 170
       }
    
    172 171
     
    
    173
    -  setAlertRole() {
    
    174
    -    // Wait a little for this to render before setting the role for more
    
    175
    -    // consistent alerts to screen readers.
    
    176
    -    this.useAlertRole = false;
    
    177
    -    window.requestAnimationFrame(() => {
    
    178
    -      window.requestAnimationFrame(() => {
    
    179
    -        this.useAlertRole = true;
    
    180
    -      });
    
    181
    -    });
    
    182
    -  }
    
    183
    -
    
    184 172
       iconTemplate() {
    
    185 173
         let iconData = messageTypeToIconData[this.type];
    
    186 174
         if (iconData) {
    
    ... ... @@ -224,6 +212,16 @@ export default class MozMessageBar extends MozLitElement {
    224 212
       }
    
    225 213
     
    
    226 214
       render() {
    
    215
    +    let ariaLabelledBy;
    
    216
    +    let ariaDescribedBy;
    
    217
    +    if (this.role === "alert") {
    
    218
    +      if (this.heading) {
    
    219
    +        ariaLabelledBy = "heading";
    
    220
    +        ariaDescribedBy = "content";
    
    221
    +      } else {
    
    222
    +        ariaLabelledBy = "content";
    
    223
    +      }
    
    224
    +    }
    
    227 225
         return html`
    
    228 226
           <link
    
    229 227
             rel="stylesheet"
    
    ... ... @@ -231,9 +229,9 @@ export default class MozMessageBar extends MozLitElement {
    231 229
           />
    
    232 230
           <div
    
    233 231
             class="container"
    
    234
    -        role=${ifDefined(this.useAlertRole ? "alert" : undefined)}
    
    235
    -        aria-labelledby=${this.heading ? "heading" : "content"}
    
    236
    -        aria-describedby=${ifDefined(this.heading ? "content" : undefined)}
    
    232
    +        role=${ifDefined(this.role || undefined)}
    
    233
    +        aria-labelledby=${ifDefined(ariaLabelledBy)}
    
    234
    +        aria-describedby=${ifDefined(ariaDescribedBy)}
    
    237 235
           >
    
    238 236
             ${this.iconTemplate()}
    
    239 237
             <div class="content">
    

  • toolkit/content/widgets/notificationbox.js
    ... ... @@ -492,6 +492,20 @@
    492 492
             this.control.removeNotification(this);
    
    493 493
           }
    
    494 494
     
    
    495
    +      setAlertRole() {
    
    496
    +        // Wait a little for this to render before setting the role for more
    
    497
    +        // consistent alerts to screen readers.
    
    498
    +        // tor-browser#45186: "role" is a mapped attribute, so `removeAttribute`
    
    499
    +        // will go undetected by the moz-message-bar widget. Instead we set the
    
    500
    +        // role property directly.
    
    501
    +        this.role = undefined;
    
    502
    +        window.requestAnimationFrame(() => {
    
    503
    +          window.requestAnimationFrame(() => {
    
    504
    +            this.role = "alert";
    
    505
    +          });
    
    506
    +        });
    
    507
    +      }
    
    508
    +
    
    495 509
           handleEvent(e) {
    
    496 510
             // If clickjacking delay is active, prevent any "click"/"command" from
    
    497 511
             // going through. Also restart the delay if the user tries to click too early.