Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into open-devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Sep 19, 2020
2 parents 534ae7b + 99df40a commit 8c0743c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions lighthouse-core/lib/page-functions.js
Expand Up @@ -466,6 +466,7 @@ module.exports = {
getNodeDetailsString,
getNodePathString: getNodePath.toString(),
getNodeSelectorString: getNodeSelector.toString(),
getNodePath,
getNodeSelector: getNodeSelector,
getNodeLabel: getNodeLabel,
getNodeLabelString: getNodeLabel.toString(),
Expand Down
32 changes: 31 additions & 1 deletion lighthouse-core/test/lib/page-functions-test.js
Expand Up @@ -16,13 +16,15 @@ describe('Page Functions', () => {
let dom;

beforeAll(() => {
const {document, ShadowRoot} = new jsdom.JSDOM().window;
const {document, ShadowRoot, Node} = new jsdom.JSDOM().window;
global.ShadowRoot = ShadowRoot;
global.Node = Node;
dom = new DOM(document);
});

afterAll(() => {
global.ShadowRoot = undefined;
global.Node = undefined;
});

describe('get outer HTML snippets', () => {
Expand Down Expand Up @@ -126,4 +128,32 @@ describe('Page Functions', () => {
assert.equal(pageFunctions.getNodeLabel(el), 'div');
});
});

describe('getNodePath', () => {
it('returns basic node path', () => {
const el = dom.createElement('div');
el.innerHTML = `
<section>
<span>Sup</span>
<img src="#">
</section>
`;
const img = el.querySelector('img');
// The img is index 1 of section's children (excluding some whitespace only text nodes).
assert.equal(pageFunctions.getNodePath(img), '0,SECTION,1,IMG');
});

it('returns node path through shadow root', () => {
const el = dom.createElement('div');
const main = el.appendChild(dom.createElement('main'));
const shadowRoot = main.attachShadow({mode: 'open'});
const sectionEl = dom.createElement('section');
const img = dom.createElement('img');
img.src = '#';
sectionEl.append(img);
shadowRoot.append(sectionEl);

assert.equal(pageFunctions.getNodePath(img), '0,MAIN,a,#document-fragment,0,SECTION,0,IMG');
});
});
});
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -147,7 +147,7 @@
},
"dependencies": {
"axe-core": "3.5.5",
"chrome-launcher": "^0.13.3",
"chrome-launcher": "^0.13.4",
"configstore": "^5.0.1",
"cssstyle": "1.2.1",
"details-element-polyfill": "^2.4.0",
Expand Down
12 changes: 6 additions & 6 deletions types/audit.d.ts
Expand Up @@ -115,12 +115,12 @@ declare global {
score: number|null;
/**
* A string identifying how the score should be interpreted:
* 'binary': pass/fail audit (0 and 1 are only possible scores).
* 'numeric': scores of 0-1 (map to displayed scores of 0-100).
* 'informative': the audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored.
* 'notApplicable': the audit turned out to not apply to the page. Score is null and should be ignored.
* 'manual': The audit exists only to tell you to review something yourself. Score is null and should be ignored.
* 'error': There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored.
* - 'binary': pass/fail audit (0 and 1 are only possible scores).
* - 'numeric': scores of 0-1 (map to displayed scores of 0-100).
* - 'informative': the audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored.
* - 'notApplicable': the audit turned out to not apply to the page. Score is null and should be ignored.
* - 'manual': The audit exists only to tell you to review something yourself. Score is null and should be ignored.
* - 'error': There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored.
*/
scoreDisplayMode: ScoreDisplayMode;
/** Short, user-visible title for the audit. The text can change depending on if the audit passed or failed. */
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -1709,10 +1709,10 @@ chrome-devtools-frontend@1.0.727089:
resolved "https://registry.yarnpkg.com/chrome-devtools-frontend/-/chrome-devtools-frontend-1.0.727089.tgz#5663edd32b445826c51a0d6332f5072b21f7b895"
integrity sha512-+dK4dgS3Phib4SPAaF29Vn5NxoKCnyuDNh9IRxjGk+u4P09o3IQyvQKA+43zTtV2q+HmORLJUS6F1SXqfUSpfQ==

chrome-launcher@^0.13.3:
version "0.13.3"
resolved "https://registry.yarnpkg.com/chrome-launcher/-/chrome-launcher-0.13.3.tgz#5dd72ae4e9b3de19ce3fe1941f89551c0ceb1d30"
integrity sha512-ovrDuFXgXS96lzeDqFPQRsczkxla+6QMvzsF+1u0mKlD1KE8EuhjdLwiDfIFedb0FSLz18RK3y6IbKu8oqA0qw==
chrome-launcher@^0.13.4:
version "0.13.4"
resolved "https://registry.yarnpkg.com/chrome-launcher/-/chrome-launcher-0.13.4.tgz#4c7d81333c98282899c4e38256da23e00ed32f73"
integrity sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==
dependencies:
"@types/node" "*"
escape-string-regexp "^1.0.5"
Expand Down

0 comments on commit 8c0743c

Please sign in to comment.