Commit 3ce4adb7 authored by davidben@chromium.org's avatar davidben@chromium.org

Settings: do the same-path check after the main page special-case.

This fixes a bug where overlays that don't push history entries still did when
closing them. Add a browser test to test this case.

BUG=379055
TEST=see bug

Review URL: https://codereview.chromium.org/306993006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274340 0039d316-1c4b-4281-b951-d872f2087c98
parent 8eae080f
...@@ -236,12 +236,11 @@ cr.define('options', function() { ...@@ -236,12 +236,11 @@ cr.define('options', function() {
// The page is already in history (the user may have clicked the same link // The page is already in history (the user may have clicked the same link
// twice). Do nothing. // twice). Do nothing.
if (path == page.name && !OptionsPage.isLoading())
return;
var hash = opt_params && opt_params.ignoreHash ? '' : window.location.hash; var hash = opt_params && opt_params.ignoreHash ? '' : window.location.hash;
var newPath = (page == this.getDefaultPage() ? '' : page.name) + hash; var newPath = (page == this.getDefaultPage() ? '' : page.name) + hash;
if (path == newPath && !OptionsPage.isLoading())
return;
var historyFunction = replace ? uber.replaceState : uber.pushState; var historyFunction = replace ? uber.replaceState : uber.pushState;
historyFunction.call(uber, {pageName: page.name}, newPath); historyFunction.call(uber, {pageName: page.name}, newPath);
}; };
......
...@@ -636,6 +636,21 @@ TEST_F('OptionsWebUIExtendedTest', 'CloseOverlay', function() { ...@@ -636,6 +636,21 @@ TEST_F('OptionsWebUIExtendedTest', 'CloseOverlay', function() {
}); });
}); });
// Test that closing an overlay that did not push history when opening does not
// again push history.
TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() {
// Open the do not track confirmation prompt.
OptionsPage.showPageByName('doNotTrackConfirm', false);
// Opening the prompt does not add to the history.
this.verifyHistory_([''], function() {
// Close the overlay.
OptionsPage.closeOverlay();
// Still no history changes.
this.verifyHistory_([''], testDone);
}.bind(this));
});
// Make sure an overlay isn't closed (even temporarily) when another overlay is // Make sure an overlay isn't closed (even temporarily) when another overlay is
// opened on top. // opened on top.
TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() { TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment