Commit 7bdbb376 authored by Gordon Seto's avatar Gordon Seto Committed by Chromium LUCI CQ

Reland "[Nearby] Update subpage visibility text and fix dialog a11y."

This reverts commit c641fdaa.

Reason for revert: Fix tests that were failing due to
nearby_contact_visibility.html being loaded directly in the test at
nearby_share_browsertest.js:171. This caused V1 tests to fail because
loading the source directly skips loading the strings that are
required. In this CL we remove the browsePreload() override so that
the nearby_contact_visibility.html source is not loaded directly.
This is the same logic NearbyOnboardingPageTest does, which also
needs to use string-loading during its tests.

Original change's description:
> Revert "[Nearby] Update subpage visibility text and fix dialog a11y."
>
> This reverts commit dc4eea24.
>
> Reason for revert: It looks like this is causing test failures --> https://ci.chromium.org/ui/p/chromium/builders/ci/linux-chromeos-dbg/21664/

Change-Id: I0e503980ce97d8b8fe3740bba81697c7ed453801
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583115Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Gordon Seto <gordonseto@google.com>
Cr-Commit-Position: refs/heads/master@{#835859}
parent 9fb57981
......@@ -14,7 +14,7 @@
<!-- Contact visibility component -->
<message name="IDS_NEARBY_CONTACT_VISIBILITY_DOWNLOAD_FAILED" desc="Message shown when downloading contacts failed when trying to load contacts to show the user a list of who they will be able to share with.">
Unable to download contact list. Please check your network connection, or &lt;a href="#" id="tryAgainLink"&gt;try again&lt;/a&gt;.
Unable to download contact list. Please check your network connection, or <ph name="LINK_BEGIN">&lt;a&gt;</ph>try again<ph name="LINK_END">&lt;/a&gt;</ph>.
</message>
<message name="IDS_NEARBY_CONTACT_VISIBILITY_DOWNLOADING" desc="Message shown when contacts are being downloaded to show the user a list of who they will be able to share with.">
Downloading contact list...
......
9904c5861c938fed7929997a10b3b3ebf74e3f75
\ No newline at end of file
7311385562a11d2b530a450317e76be46a121443
\ No newline at end of file
......@@ -160,7 +160,7 @@
Device visibility
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_EDIT_VISIBILITY" desc="Label for the button that opens the dialog which allows a user to set their preference for the visibility of their device with their contacts for the Nearby Share feature.">
View device visibility
Change visibility
</message>
<message name="IDS_SETTINGS_NEARBY_SHARE_VISIBILITY_DIALOG_TITLE" desc="Title for the dialog which allows a user to set their preference for the visibility of their device with their contacts for the Nearby Share feature.">
Device visibility
......
1ab039c9f2960ce64f40f57e7c096124d91e1b07
\ No newline at end of file
ecb4065349ab3a22321096d5d579c667c31680f8
\ No newline at end of file
......@@ -351,6 +351,7 @@ Polymer({
* and setting the href of the link to |linkUrl|. This function is largely
* copied from getAriaLabelledContent_ in <settings-localized-link>, which
* can't be used directly because this isn't part of settings.
* TODO(crbug.com/1154718): Extract this logic into a general method.
* @param {string} linkUrl
* @return {string}
* @private
......
......@@ -309,9 +309,7 @@
<iron-icon id="contactsFailedImage"
icon="nearby-images:contacts-download-failed">
</iron-icon>
<div>
$i18nRaw{nearbyShareContactVisibilityDownloadFailed}
</div>
<div id="contactsFailedMessage"></div>
</div>
</template>
......
......@@ -423,19 +423,66 @@ Polymer({
},
/**
* Because the "failed" state contains an i18n string with a link in it, we
* need to add an event listener. We do that here because the link doesn't
* exist when the dialog loads, only once the template is added to the DOM.
* Builds the html for the download retry message, applying the appropriate
* aria labels, and adding an event listener to the link. This function is
* largely copied from getAriaLabelledHelpText_ in <nearby-discovery-page>,
* and should be generalized in the future. We do this here because the div
* doesn't exist when the dialog loads, only once the template is added to the
* DOM.
* TODO(crbug.com/1154718): Extract this logic into a general method.
*
* @private
*/
domChangeDownloadFailed_() {
const tryAgainLink = this.$$('#tryAgainLink');
if (!tryAgainLink) {
const contactsFailedMessage = this.$$('#contactsFailedMessage');
if (!contactsFailedMessage) {
return;
}
const localizedString =
this.i18nAdvanced('nearbyShareContactVisibilityDownloadFailed');
contactsFailedMessage.innerHTML = localizedString;
const ariaLabelledByIds = [];
contactsFailedMessage.childNodes.forEach((node, index) => {
// Text nodes should be aria-hidden and associated with an element id
// that the anchor element can be aria-labelledby.
if (node.nodeType == Node.TEXT_NODE) {
const spanNode = document.createElement('span');
spanNode.textContent = node.textContent;
spanNode.id = `contactsFailedMessage${index}`;
ariaLabelledByIds.push(spanNode.id);
spanNode.setAttribute('aria-hidden', true);
node.replaceWith(spanNode);
return;
}
// The single element node with anchor tags should also be aria-labelledby
// itself in-order with respect to the entire string.
if (node.nodeType == Node.ELEMENT_NODE && node.nodeName == 'A') {
node.id = `tryAgainLink`;
ariaLabelledByIds.push(node.id);
return;
}
// Only text and <a> nodes are allowed.
assertNotReached(
'nearbyShareContactVisibilityDownloadFailed has invalid node types');
});
const anchorTags = contactsFailedMessage.getElementsByTagName('a');
// In the event the localizedString contains only text nodes, populate the
// contents with the localizedString.
if (anchorTags.length == 0) {
contactsFailedMessage.innerHTML = localizedString;
return;
}
assert(
anchorTags.length == 1, 'string should contain exactly one anchor tag');
const anchorTag = anchorTags[0];
anchorTag.setAttribute('aria-labelledby', ariaLabelledByIds.join(' '));
anchorTag.href = '#';
tryAgainLink.addEventListener('click', event => {
anchorTag.addEventListener('click', event => {
event.preventDefault();
this.downloadContacts_();
});
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
// clang-format off
// #import 'chrome://nearby/strings.m.js';
// #import 'chrome://nearby/shared/nearby_contact_visibility.m.js';
// #import {setContactManagerForTesting} from 'chrome://nearby/shared/nearby_contact_manager.m.js';
// #import {setNearbyShareSettingsForTesting} from 'chrome://nearby/shared/nearby_share_settings.m.js';
......
......@@ -166,11 +166,6 @@ TEST_F('NearbyProgressTest', 'All', () => mocha.run());
* @extends {NearbySharedBrowserTest}
*/
var NearbyContactVisibilityTest = class extends NearbySharedBrowserTest {
/** @override */
get browsePreload() {
return super.browsePreload + 'shared/nearby_contact_visibility.html';
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment