Skip to content

Commit

Permalink
DevTools: Prevent the ARIA alert from obscuring DevTools
Browse files Browse the repository at this point in the history
The alert element must be visible for a screen reader to read it,
so we place it far off the left edge of the screen. However extremely
large text could cause it to overflow onto the page. This patch
limits the width of the element, and also limits the max text length
of the alerts for better performance.

Bug: 845766
Change-Id: I79aadcf863f09ebfdaf2bcb3ba579b891fec2351
Reviewed-on: https://chromium-review.googlesource.com/1067690
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561490}
  • Loading branch information
JoelEinbinder authored and Commit Bot committed May 24, 2018
1 parent 48711ad commit 803cc98
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ UI.ARIAUtils.alert = function(message, element) {
const alertElement = document.body.createChild('div');
alertElement.style.position = 'absolute';
alertElement.style.left = '-999em';
alertElement.style.width = '100em';
alertElement.style.overflow = 'hidden';
alertElement.setAttribute('role', 'alert');
alertElement.setAttribute('aria-atomic', 'true');
document[UI.ARIAUtils.AlertElementSymbol] = alertElement;
}
document[UI.ARIAUtils.AlertElementSymbol].textContent = message;
document[UI.ARIAUtils.AlertElementSymbol].textContent = message.trimEnd(10000);
};

UI.ARIAUtils.AlertElementSymbol = Symbol('AlertElementSybmol');

0 comments on commit 803cc98

Please sign in to comment.