Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Feb 25, 2017
1 parent 33c6994 commit 1853bcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lighthouse-core/lib/url-shim.js
Expand Up @@ -95,12 +95,12 @@ URL.getDisplayName = function getDisplayName(url) {
};

// There is fancy URL rewriting logic for the chrome://settings page that we need to work around.
// Why? It was to be able to swap from chrome://settings to chrome://extensions with a JavaScript
// Why? It was to be able to swap from chrome://settings to chrome://extensions with a JavaScript
// pushState call without forcing a page reload. :)
// As a result, the final document URL doesn't match the URL that network layer surfaces.
function rewriteChromeInternalUrl(url){
function rewriteChromeInternalUrl(url) {
if (!url.startsWith('chrome://')) return url;
return url.replace(/^chrome:\/\/chrome\//,'chrome://');
return url.replace(/^chrome:\/\/chrome\//, 'chrome://');
}

/**
Expand Down
8 changes: 8 additions & 0 deletions lighthouse-core/test/lib/url-shim-test.js
Expand Up @@ -111,5 +111,13 @@ describe('URL Shim', () => {
];
unequalPairs.forEach(pair => assert.ok(!URL.equalWithExcludedFragments(...pair)));
});

it('rewrites chrome://settings urls', () => {
const pair = [
'chrome://settings/',
'chrome://chrome/settings/',
];
assert.ok(URL.equalWithExcludedFragments(...pair));
});
});
});

0 comments on commit 1853bcf

Please sign in to comment.