[go: nahoru, domu]

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

tests(tags-blocking-first-paint): alternate stylesheets are not blocking #9248

Merged
merged 7 commits into from
Jul 11, 2019

Conversation

connorjclark
Copy link
Collaborator

While investigating #2065, I learned alternate stylesheets are never considered blocking. We do handle these correctly, but we had no test cases, so I added one.

Must be in the smoke test, as the unit test completely mocks out the code under test (it's mostly in a page function).

fyi: apparently, you must install an extension in Chrome to use alternate stylesheets. Firefox has it built in.

@@ -16,6 +16,9 @@ module.exports = [
}, {
id: 'wordpress',
}],
TagsBlockingFirstPaint: {
length: 7,
Copy link
Collaborator Author
@connorjclark connorjclark Jun 21, 2019

Choose a reason for hiding this comment

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

should i be more explicit here?

[
        {
          "tag": {
            "tagName": "LINK",
            "url": "http://localhost:10200/dobetterweb/dobetterweb/dbw_tester.css?delay=100",
            "href": "http://localhost:10200/dobetterweb/dobetterweb/dbw_tester.css?delay=100",
            "rel": "stylesheet",
            "media": "",
            "disabled": false,
            "mediaChanges": []
          },
        },
        {
          "tag": {
            "tagName": "LINK",
            "url": "http://localhost:10200/dobetterweb/unknown404.css?delay=200",
            "href": "http://localhost:10200/dobetterweb/unknown404.css?delay=200",
            "rel": "stylesheet",
            "media": "",
            "disabled": false,
            "mediaChanges": []
          },
        },
        {
          "tag": {
            "tagName": "LINK",
            "url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200",
            "href": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=2200",
            "rel": "stylesheet",
            "media": "",
            "disabled": false,
            "mediaChanges": []
          },

        },
        {
          "tag": {
            "tagName": "LINK",
            "url": "http://localhost:10200/dobetterweb/dbw_partial_a.html?delay=200",
            "href": "http://localhost:10200/dobetterweb/dbw_partial_a.html?delay=200",
            "rel": "import",
            "media": "",
            "disabled": false,
            "mediaChanges": []
          },
        },
        {
          "tag": {
            "tagName": "LINK",
            "url": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped",
            "href": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped",
            "rel": "stylesheet",
            "media": "screen",
            "disabled": false,
            "mediaChanges": [
              {
                "href": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped",
                "media": "not-matching",
                "matches": false
              },
              {
                "href": "http://localhost:10200/dobetterweb/dbw_tester.css?delay=3000&capped",
                "media": "screen",
                "matches": true
              }
            ]
          },
        },
        {
          "tag": {
            "tagName": "SCRIPT",
            "url": "http://localhost:10200/dobetterweb/dbw_tester.js",
            "src": "http://localhost:10200/dobetterweb/dbw_tester.js",
            "mediaChanges": []
          },
        },
        {
          "tag": {
            "tagName": "SCRIPT",
            "url": "http://localhost:10200/dobetterweb/fcp-delayer.js?delay=5000",
            "src": "http://localhost:10200/dobetterweb/fcp-delayer.js?delay=5000",
            "mediaChanges": []
          },
        }
      ]

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should include the URL at least otherwise debugging this is going to be a nightmare, are they in a predictable order? should we sort by URL or something?

Copy link
Member

Choose a reason for hiding this comment

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

we do have an existing assertion for the tags blocking first paint, in the render-blocking-resources audit, and that's probably a better one to sort (I'm kind of surprised it's not sorted by wastedMs already)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using that audit for the assertion is problematic b/c it also ignores resources that don't meet a minimum threshold.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah I agree with @connorjclark it's worth asserting these artifacts directly, and if we're asserting the length we should make it debuggable by asserting the URLs

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough! I guess should say the audit(s) should also be updated, then, so we aren't neglecting the "to end" part of end-to-end testing :)

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.

always love more tests! ❤️

@@ -16,6 +16,9 @@ module.exports = [
}, {
id: 'wordpress',
}],
TagsBlockingFirstPaint: {
length: 7,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should include the URL at least otherwise debugging this is going to be a nightmare, are they in a predictable order? should we sort by URL or something?

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.

you must install an extension in Chrome to use alternate stylesheets. Firefox has it built in.

like, it won't load at all? Or there's no UI support? Or...?

@@ -16,6 +16,9 @@ module.exports = [
}, {
id: 'wordpress',
}],
TagsBlockingFirstPaint: {
length: 7,
Copy link
Member

Choose a reason for hiding this comment

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

we do have an existing assertion for the tags blocking first paint, in the render-blocking-resources audit, and that's probably a better one to sort (I'm kind of surprised it's not sorted by wastedMs already)

@connorjclark
Copy link
Collaborator Author

like, it won't load at all? Or there's no UI support? Or...?

Oops, I forgot to share the surge I made: https://lh-alt-styles.surge.sh/

Chrome offers no UI. it still downloads the stylesheet. Firefox allows you to select which alternate to use (View -> Page Style).

},
undefined, // marks end of array
],
// TagsBlockingFirstPaint: {
Copy link
Collaborator Author
@connorjclark connorjclark Jun 24, 2019

Choose a reason for hiding this comment

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

which one?

I very much dislike both, but I dislike the first one less, even though it would technically pass something like [Object,Object,Object,undefined,Object,Object] ...

Was considering doing something like [..., Symbol('end')] instead of [..., undefined] and adding a customer checker in the assertions, but that would be too far for just this one thing.

Copy link
Collaborator
@patrickhulce patrickhulce Jun 24, 2019

Choose a reason for hiding this comment

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

option c: we could start asserting the array length in our smokes :)

I'm fine with the first one though, definitely not a huge fan of option 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i like c. I can follow up after this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cool beans want to remove the dead weight ones for now then? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@connorjclark connorjclark changed the title tests(tags-blocking-first-paint): ensure alternate stylesheets are not considered blocking tests(tags-blocking-first-paint): alternate stylesheets are not blocking Jun 24, 2019
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

@@ -16,6 +16,64 @@ module.exports = [
}, {
id: 'wordpress',
}],
TagsBlockingFirstPaint: [
Copy link
Member

Choose a reason for hiding this comment

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

the user-observable behavior here is in the render-blocking-resources audit (though TagsBlockingFirstPaint will enter our PublicGathererArtifacts someday).

There is a balance to strike when testing internal state when it's difficult to test otherwise, so I understand the argument for capturing it here, but if we accept that and that this data is important to assert, then we should assert it in the audit as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

would you prefer I change the alternate request to a large stylesheet so we can assert in the audit too?

Copy link
Member

Choose a reason for hiding this comment

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

would you prefer I change the alternate request to a large stylesheet so we can assert in the audit too?

that might make the alternate stylesheet test more realistic, but not being included there is also a signal that the audit is working as expected

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sorry, but what's the requested change here?

Copy link
Member

Choose a reason for hiding this comment

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

sorry, but what's the requested change here?

if whatever items you don't want to see regress (e.g. the urls, etc) are important enough to add to a smoke test, they should be asserted where they are actually observable by a user? The artifact can be asserted all day but that doesn't matter if the audit is mismatched to it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

talked offline - didn't realize his suggestions are independent of the specific alternate-stylesheet I added. should expand the render-blocking-resources audit expectation to be more than "detail.items is array of 7 items".

Copy link
Member

Choose a reason for hiding this comment

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

yeah, sorry, we were having two different conversations :)

@connorjclark
Copy link
Collaborator Author

FYI the reason I want this test is to avoid regressions from any action taken on #2065

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

@vercel vercel bot temporarily deployed to staging July 11, 2019 02:05 Inactive
@connorjclark connorjclark merged commit a36d263 into master Jul 11, 2019
@paulirish paulirish deleted the tags-blocking-alternate-testcase branch July 11, 2019 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants