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(page-functions): don't try to clone a ShadowRoot #9079

Merged
merged 9 commits into from
Jun 7, 2019

Conversation

NickolasBenakis
Copy link
Contributor

@NickolasBenakis NickolasBenakis commented May 29, 2019

Summary
This PR fixes the #9048 issue .
image

It is a bug fix.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@NickolasBenakis
Copy link
Contributor Author

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.

What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@NickolasBenakis NickolasBenakis changed the title #9048 Fix Avoid an excess DOM size error Bugfix Avoid an excess DOM size error May 29, 2019
@NickolasBenakis NickolasBenakis changed the title Bugfix Avoid an excess DOM size error Bug-fix: Avoid an excess DOM size error May 29, 2019
@NickolasBenakis NickolasBenakis changed the title Bug-fix: Avoid an excess DOM size error bug-fix: Avoid an excess DOM size error May 29, 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.

Thanks so much for jumping on this @NickolasBenakis!

Do you think you could add a test case and remove the package-lock.json?

A good test case would be adding error-prone element from the bug report to our accessibility smoke test HTML.

https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-cli/test/fixtures/a11y/a11y_tester.html#L198

yarn smoke a11y should fail without your fix, and pass with it! 🎉

const match = clone.outerHTML.match(reOpeningTag);
return (match && match[0]) || '';
} catch (error) {
return element.localName;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return element.localName;
return `<${element.localName}>`;

Copy link
Collaborator

Choose a reason for hiding this comment

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

just to match the expected output of this function under normal conditions

Copy link
Contributor Author

@NickolasBenakis NickolasBenakis May 29, 2019

Choose a reason for hiding this comment

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

Thanks a lot for the feedback @patrickhulce .
I 'll remove it , my bad.
I am checking the a11y tester case now, I 've never done this before :)
But I am trying to figure out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
It seems that it pass,
but I didnt add any error-prone element inside the a11y_tester.html.

Copy link
Collaborator

@patrickhulce patrickhulce May 30, 2019

Choose a reason for hiding this comment

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

That's expected :)

Steps:

  1. Run yarn smoke a11y, it should pass (you've already done this ✅)
  2. Temporarily comment out your fix
  3. Add an error-prone element inside a11y_tester.html
  4. Run yarn smoke a11y, it should fail
  5. Uncomment your fix
  6. Run yarn smoke a11y, it should pass
  7. Commit the changes! 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean something like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meh either way,
I run the test with npm run test
and it crashes...
well :'(

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant something like

it('should handle dom nodes that cannot be inspected', () => {
  const element = dom.createElement('div');
  element.cloneNode = () => { throw new Erorr('oops!') };
  assert.equal(pageFunctions.getOuterHTMLSnippet(element), '<div>');
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickhulce I commited the test case :)

const reOpeningTag = /^[\s\S]*?>/;
const match = clone.outerHTML.match(reOpeningTag);
return (match && match[0]) || '';
} catch (error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
} catch (error) {
} catch (_) {

we name our unused variables _ :)

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@codecov
Copy link

codecov bot commented May 31, 2019

Codecov Report

Merging #9079 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9079      +/-   ##
==========================================
- Coverage   91.43%   91.42%   -0.02%     
==========================================
  Files         291      291              
  Lines        9917     9917              
==========================================
- Hits         9068     9067       -1     
- Misses        849      850       +1
Flag Coverage Δ
#smoke 84.2% <ø> (-0.09%) ⬇️
#unit 89.53% <ø> (-0.02%) ⬇️
Impacted Files Coverage Δ
lighthouse-core/lib/page-functions.js 100% <ø> (ø) ⬆️
lighthouse-core/audits/user-timings.js 96% <0%> (-4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff4f486...51449a0. Read the comment docs.

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, thanks @NickolasBenakis!

@hoten want to take a look at this for another pair of eyes? I'm somewhat biased on some of these parts :)

@exterkamp exterkamp added cla: yes and removed cla: no labels Jun 3, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@exterkamp
Copy link
Member

Just updating the CLA

Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
@GoogleChrome GoogleChrome deleted a comment from googlebot Jun 5, 2019
@exterkamp exterkamp added cla: yes and removed cla: no labels Jun 5, 2019
@brendankenny brendankenny changed the title bug-fix: Avoid an excess DOM size error core(page-functions): don't try to clone a ShadowRoot Jun 7, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@GoogleChrome GoogleChrome deleted a comment from googlebot Jun 7, 2019
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! Good to go when the build is green.

Thanks for sticking with this, @NickolasBenakis!

@patrickhulce patrickhulce merged commit 212b6ac into GoogleChrome:master Jun 7, 2019
@NickolasBenakis
Copy link
Contributor Author

LGTM! Good to go when the build is green.

Thanks for sticking with this, @NickolasBenakis!

My pleasure...
This is one of my first steps in open source and I had fun doing this.
I will keep my eyes open for any future issue that I could help.
=)

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

Successfully merging this pull request may close these issues.

6 participants