Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(pwa): revamp and move short_name_length audit #4860

Merged
merged 10 commits into from
Jun 28, 2018

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Mar 23, 2018

Two separate, but related changes in here:

  1. webapp-install-banner audit doesn't check for a defined short_name any more. It's never technically been required, so we shouldn't assert it.
  2. Just straight up remove short-name-length. The length of 12 characters was picked out of the air. And having a whole audit to verify str.length <= 12 is kinda annoying.
    • If we didn't remove it, I'd move it to PWA, set weight to 0, and flip it to notApplicable: true if no manifest is present. But honestly I don't think it's worth keeping it around. Open to arguments tho.

Fixes #2698. See also #23 (comment)
Fixes #686 (comment)
Fixes #4860

Doesn't fix #348 because it makes a different conclusion.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the checklist perspective, I appreciated a helpful reminder to provide an alternative to long names. I'd propose turning it informative and marking not applicable when no manifest rather than killing it off entirely.

If others never found it useful I can live with it gone though :)

@paulirish
Copy link
Member Author

I'd propose turning it informative and marking not applicable when no manifest rather than killing it off entirely.

I did have this at first, fwiw.

@brendankenny thoughts?

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I like keeping it personally.

How did its requirement in wepapp-install-banner make it through the last round of culling?

@paulirish
Copy link
Member Author

paulirish commented Apr 25, 2018

Welcome back!

  • Now it's in PWA section
  • Weight of 0 always, since it isn't included in PWA checklist requirements
  • Failure of no manifest is communicated

screenshot where there's no manifest at all

image

screenshot where there's a failing manifest

image

If you hypothetically have a manifest name that's under 12 characters we will still fail you. (We prefer you just add a short_name with the same value).

@paulirish paulirish changed the title core(pwa): don't require short_name. remove short_name_length audit core(pwa): revamp and move short_name_length audit Apr 25, 2018
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm 👍

aside: is it just me or could multicheckaudit and byteefficiencyaudit use a bit of a refresh cleanup post I/O :)

@patrickhulce
Copy link
Collaborator

got some lint failures though

@paulirish
Copy link
Member Author

aside: is it just me or could multicheckaudit and byteefficiencyaudit use a bit of a refresh cleanup post I/O :)

yUPPPPPPPPP

}
const shortNameCheckIds = ['hasShortName', 'shortNameLength'];
manifestValues.allChecks.filter(item => shortNameCheckIds.includes(item.id)).forEach(item => {
if (!item.passing) failures.push(item.failureText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this have the other problem where if you don't have a short name you'll get both 'Manifest does not have `short_name`' and 'Manifest `short_name` will be truncated when displayed on the homescreen'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good call. thx.

@paulirish
Copy link
Member Author

has no manifest

image

has manifest, has no shortname:

image

has manifest, shortname length is <= 12

image

has manifest, shortname length is > 12

image

@glittle
Copy link

glittle commented Apr 26, 2018

As for the limit of 12, does this consider that Android word-wraps the text and shows on two lines? So, two words, both 12 long, would be fine.

@paulirish
Copy link
Member Author

does this consider that Android word-wraps the text and shows on two lines?

It doesn't, but I don't see this on my phone. Android 8.1.0 on a Pixel 2. I've never seen the text below an icon get word-wrapping. :/

@glittle
Copy link

glittle commented Apr 26, 2018

Hmm... it looks like on the desktop it does not, but in a folder it does! I keep almost everything in folders, so didn't notice. (Sorry these screen captures are so big!) Probably dependent on the home screen app being used too.

screenshot_20180426-134730
screenshot_20180426-134953

validate: manifest => !!manifest.value.short_name.value &&
failureText: `Manifest's \`short_name\` is too long (>${SUGGESTED_SHORTNAME_LENGTH} ` +
`characters) to be displayed on a homescreen without truncation`,
// Pass if there's no short_name. Don't want to report a non-existent string is too long
Copy link
Contributor

@JoelEinbinder JoelEinbinder Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should fail if there is no short_name and the name is longer than SUGGESTED_SHORTNAME_LENGTH. Or another audit like hasSomeShortName should fail. I wouldn't know that short_name exists without this audit.

@paulirish paulirish added the 3.0 label Jun 27, 2018
@paulirish
Copy link
Member Author

@patrickhulce @brendankenny ptal

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@brendankenny
Copy link
Member

should update the PR description (looks like you ended up doing the opposite)

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shrtnm

const failures = [];
/** @type {Array<string>} */
const warnings = [];

return artifacts.requestManifestValues(artifacts.Manifest).then(manifestValues => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await!

return {
rawValue: !!isShortEnough && isShortEnough.passing,
};
return result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no warnings and only one possible failure, so why not drop mulitcheckAudit and do like

const manifestValues = await artifacts.requestManifestValues(artifacts.Manifest);
// If there's no valid manifest, this audit is not applicable
if (manifestValues.isParseFailure) {
  return {
    rawValue: true,
    notApplicable: true,
  };
}

const shortNameCheck = manifestValues.allChecks.find(i => i.id === 'hasShortName');
const shortNameLengthCheck = manifestValues.allChecks.find(i => i.id === 'shortNameLength');

// If there's no short_name present, this audit is not applicable
if (shortNameCheck && !shortNameCheck.passing) {
  return {
    rawValue: true,
    notApplicable: true,
  };
}

if (shortNameLengthCheck && !shortNameLengthCheck.passing) {
  return {
    rawValue: false,
    explanation: `Failure: ${shortNameLengthCheck.failureText}.`,
  };
}

return {
  rawValue: true,
};

@@ -30,29 +30,30 @@ describe('Manifest: short_name_length audit', () => {
artifacts.Manifest = null;

return ManifestShortNameLengthAudit.audit(artifacts).then(result => {
assert.strictEqual(result.rawValue, false);
assert.strictEqual(result.explanation, undefined);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update test description (doesn't fail)

});
});

it('fails when an empty manifest is present', () => {
const artifacts = generateMockArtifacts();
artifacts.Manifest = manifestParser('{}', EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL);
return ManifestShortNameLengthAudit.audit(artifacts).then(result => {
assert.equal(result.rawValue, false);
assert.equal(result.explanation, 'No short_name found in manifest.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sames

});
});

it('fails when a manifest contains no short_name and too long name', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sames

@@ -66,6 +67,8 @@ describe('Manifest: short_name_length audit', () => {
artifacts.Manifest = manifestParser(manifestSrc, EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL);
return ManifestShortNameLengthAudit.audit(artifacts).then(result => {
assert.equal(result.rawValue, false);
assert.ok(result.explanation.includes('without truncation'), result.explanation);
assert.ok(!result.explanation.includes('Manifest does not have `short_name`'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this line as it's not a possibility any longer? Want to assert not not applicable, though?

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@patrickhulce
Copy link
Collaborator

:shipit:

@noyainrain
Copy link

noyainrain commented Oct 10, 2019

Thanks for fixing this @paulirish 😊

I know it's been over a year, just a quick question related to this change. From the description of the PR, the original goal was to remove the hasShortName check:

1. webapp-install-banner audit doesn't check for a defined `short_name` any more. It's never technically been required, so we shouldn't assert it.

If I understand the discussion correctly, it was then agreed to make it informative instead:

I'd propose turning it informative and marking not applicable when no manifest rather than killing it off entirely.

But in the end, the check still is mandatory:

      // Technically shortname isn't required (if name is defined):
      //   https://cs.chromium.org/chromium/src/chrome/browser/installable/installable_manager.cc?type=cs&q=IsManifestValidForWebApp+f:cc+-f:test&sq=package:chromium&l=473
      // Despite this, we think it's better to require it anyway.
      // short_name is preferred for the homescreen icon, but a longer name can be used in
      // the splash screen and app title. Given the different usecases, we'd like to make it clearer
      // that the developer has two possible strings to work with.
      'hasShortName',

Is there a particular reason for keeping it required in the installable-manifest audit, instead of making it informative somehow?

(Problem background: Most PWA directories use the result of lighthouse pwa-installable to inform the user if a PWA is installable. For a manifest with a short name and no (redundant) shortname, a PWA is incorrectly labeled as non-installable.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants