Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1675)

Side by Side Diff: chrome/browser/ui/webui/options/options_browsertest.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/PageTree/PageManager/, s/pageHelper/pageManager/ Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"'); 5 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"');
6 6
7 /** @const */ var MANAGED_USERS_PREF = 'profile.managed_users'; 7 /** @const */ var MANAGED_USERS_PREF = 'profile.managed_users';
8 8
9 /** 9 /**
10 * Wait for the method specified by |methodName|, on the |object| object, to be 10 * Wait for the method specified by |methodName|, on the |object| object, to be
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 * interstitial is pressed, otherwise the abort button is pressed. 159 * interstitial is pressed, otherwise the abort button is pressed.
160 * @param {boolean} confirmInterstitial Whether to confirm the Do Not Track 160 * @param {boolean} confirmInterstitial Whether to confirm the Do Not Track
161 * interstitial. 161 * interstitial.
162 */ 162 */
163 OptionsWebUITest.prototype.testDoNotTrackInterstitial = 163 OptionsWebUITest.prototype.testDoNotTrackInterstitial =
164 function(confirmInterstitial) { 164 function(confirmInterstitial) {
165 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false}}); 165 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false}});
166 var buttonToClick = confirmInterstitial ? $('do-not-track-confirm-ok') : 166 var buttonToClick = confirmInterstitial ? $('do-not-track-confirm-ok') :
167 $('do-not-track-confirm-cancel'); 167 $('do-not-track-confirm-cancel');
168 var dntCheckbox = $('do-not-track-enabled'); 168 var dntCheckbox = $('do-not-track-enabled');
169 var dntOverlay = OptionsPage.registeredOverlayPages['donottrackconfirm']; 169 var dntOverlay = PageManager.registeredOverlayPages['donottrackconfirm'];
170 assertFalse(dntCheckbox.checked); 170 assertFalse(dntCheckbox.checked);
171 171
172 var visibleChangeCounter = 0; 172 var visibleChangeCounter = 0;
173 var visibleChangeHandler = function() { 173 var visibleChangeHandler = function() {
174 ++visibleChangeCounter; 174 ++visibleChangeCounter;
175 switch (visibleChangeCounter) { 175 switch (visibleChangeCounter) {
176 case 1: 176 case 1:
177 window.setTimeout(function() { 177 window.setTimeout(function() {
178 assertTrue(dntOverlay.visible); 178 assertTrue(dntOverlay.visible);
179 buttonToClick.click(); 179 buttonToClick.click();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndCancelInterstitial', 212 TEST_F('OptionsWebUITest', 'EnableDoNotTrackAndCancelInterstitial',
213 function() { 213 function() {
214 this.testDoNotTrackInterstitial(false); 214 this.testDoNotTrackInterstitial(false);
215 }); 215 });
216 216
217 // Check that the "Do not Track" preference can be correctly disabled. 217 // Check that the "Do not Track" preference can be correctly disabled.
218 // In order to do that, we need to enable it first. 218 // In order to do that, we need to enable it first.
219 TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() { 219 TEST_F('OptionsWebUITest', 'EnableAndDisableDoNotTrack', function() {
220 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false}}); 220 Preferences.prefsFetchedCallback({'enable_do_not_track': {'value': false}});
221 var dntCheckbox = $('do-not-track-enabled'); 221 var dntCheckbox = $('do-not-track-enabled');
222 var dntOverlay = OptionsPage.registeredOverlayPages.donottrackconfirm; 222 var dntOverlay = PageManager.registeredOverlayPages.donottrackconfirm;
223 assertFalse(dntCheckbox.checked); 223 assertFalse(dntCheckbox.checked);
224 224
225 var visibleChangeCounter = 0; 225 var visibleChangeCounter = 0;
226 var visibleChangeHandler = function() { 226 var visibleChangeHandler = function() {
227 ++visibleChangeCounter; 227 ++visibleChangeCounter;
228 switch (visibleChangeCounter) { 228 switch (visibleChangeCounter) {
229 case 1: 229 case 1:
230 window.setTimeout(function() { 230 window.setTimeout(function() {
231 assertTrue(dntOverlay.visible); 231 assertTrue(dntOverlay.visible);
232 $('do-not-track-confirm-ok').click(); 232 $('do-not-track-confirm-ok').click();
(...skipping 29 matching lines...) Expand all
262 262
263 dntCheckbox.click(); 263 dntCheckbox.click();
264 }); 264 });
265 265
266 // Verify that preventDefault() is called on 'Enter' keydown events that trigger 266 // Verify that preventDefault() is called on 'Enter' keydown events that trigger
267 // the default button. If this doesn't happen, other elements that may get 267 // the default button. If this doesn't happen, other elements that may get
268 // focus (by the overlay closing for instance), will execute in addition to the 268 // focus (by the overlay closing for instance), will execute in addition to the
269 // default button. See crbug.com/268336. 269 // default button. See crbug.com/268336.
270 TEST_F('OptionsWebUITest', 'EnterPreventsDefault', function() { 270 TEST_F('OptionsWebUITest', 'EnterPreventsDefault', function() {
271 var page = HomePageOverlay.getInstance(); 271 var page = HomePageOverlay.getInstance();
272 OptionsPage.showPageByName(page.name); 272 PageManager.showPageByName(page.name);
273 var event = new KeyboardEvent('keydown', { 273 var event = new KeyboardEvent('keydown', {
274 'bubbles': true, 274 'bubbles': true,
275 'cancelable': true, 275 'cancelable': true,
276 'keyIdentifier': 'Enter' 276 'keyIdentifier': 'Enter'
277 }); 277 });
278 assertFalse(event.defaultPrevented); 278 assertFalse(event.defaultPrevented);
279 page.pageDiv.dispatchEvent(event); 279 page.pageDiv.dispatchEvent(event);
280 assertTrue(event.defaultPrevented); 280 assertTrue(event.defaultPrevented);
281 testDone(); 281 testDone();
282 }); 282 });
(...skipping 16 matching lines...) Expand all
299 299
300 document.addEventListener('webkitTransitionEnd', function(e) { 300 document.addEventListener('webkitTransitionEnd', function(e) {
301 if (e.target != overlay) 301 if (e.target != overlay)
302 return; 302 return;
303 303
304 assertFalse(overlay.classList.contains('transparent')); 304 assertFalse(overlay.classList.contains('transparent'));
305 expectEquals(numFrozenPages, frozenPages.length); 305 expectEquals(numFrozenPages, frozenPages.length);
306 testDone(); 306 testDone();
307 }); 307 });
308 308
309 OptionsPage.navigateToPage(overlayName); 309 PageManager.navigateToPage(overlayName);
310 var numFrozenPages = frozenPages.length; 310 var numFrozenPages = frozenPages.length;
311 expectGT(numFrozenPages, 0); 311 expectGT(numFrozenPages, 0);
312 }); 312 });
313 313
314 GEN('#if defined(OS_CHROMEOS)'); 314 GEN('#if defined(OS_CHROMEOS)');
315 // Verify that range inputs respond to touch events. Currently only Chrome OS 315 // Verify that range inputs respond to touch events. Currently only Chrome OS
316 // uses slider options. 316 // uses slider options.
317 TEST_F('OptionsWebUITest', 'RangeInputHandlesTouchEvents', function() { 317 TEST_F('OptionsWebUITest', 'RangeInputHandlesTouchEvents', function() {
318 this.mockHandler.expects(once()).setIntegerPref([ 318 this.mockHandler.expects(once()).setIntegerPref([
319 'settings.touchpad.sensitivity2', 1]); 319 'settings.touchpad.sensitivity2', 1]);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 * @param {!Array.<string>} expectedPages An array of page names expected to 419 * @param {!Array.<string>} expectedPages An array of page names expected to
420 * be open, with the topmost listed last. 420 * be open, with the topmost listed last.
421 * @param {string=} opt_expectedUrl The URL path, including hash, expected to 421 * @param {string=} opt_expectedUrl The URL path, including hash, expected to
422 * be open. If undefined, the topmost (last) page name in |expectedPages| 422 * be open. If undefined, the topmost (last) page name in |expectedPages|
423 * will be used. In either case, 'chrome://settings-frame/' will be 423 * will be used. In either case, 'chrome://settings-frame/' will be
424 * prepended. 424 * prepended.
425 * @private 425 * @private
426 */ 426 */
427 verifyOpenPages_: function(expectedPages, opt_expectedUrl) { 427 verifyOpenPages_: function(expectedPages, opt_expectedUrl) {
428 // Check the topmost page. 428 // Check the topmost page.
429 expectEquals(null, OptionsPage.getVisibleBubble()); 429 expectEquals(null, PageManager.getVisibleBubble());
430 var currentPage = OptionsPage.getTopmostVisiblePage(); 430 var currentPage = PageManager.getTopmostVisiblePage();
431 431
432 var lastExpected = expectedPages[expectedPages.length - 1]; 432 var lastExpected = expectedPages[expectedPages.length - 1];
433 expectEquals(lastExpected, currentPage.name); 433 expectEquals(lastExpected, currentPage.name);
434 // We'd like to check the title too, but we have to load the settings-frame 434 // We'd like to check the title too, but we have to load the settings-frame
435 // instead of the outer settings page in order to have access to 435 // instead of the outer settings page in order to have access to
436 // OptionsPage, and setting the title from within the settings-frame fails 436 // OptionsPage, and setting the title from within the settings-frame fails
437 // because of cross-origin access restrictions. 437 // because of cross-origin access restrictions.
438 // TODO(pamg): Add a test fixture that loads chrome://settings and uses 438 // TODO(pamg): Add a test fixture that loads chrome://settings and uses
439 // UI elements to access sub-pages, so we can test the titles and 439 // UI elements to access sub-pages, so we can test the titles and
440 // search-page URLs. 440 // search-page URLs.
441 var expectedUrl = (typeof opt_expectedUrl == 'undefined') ? 441 var expectedUrl = (typeof opt_expectedUrl == 'undefined') ?
442 lastExpected : opt_expectedUrl; 442 lastExpected : opt_expectedUrl;
443 var fullExpectedUrl = 'chrome://settings-frame/' + expectedUrl; 443 var fullExpectedUrl = 'chrome://settings-frame/' + expectedUrl;
444 expectEquals(fullExpectedUrl, window.location.href); 444 expectEquals(fullExpectedUrl, window.location.href);
445 445
446 // Collect open pages. 446 // Collect open pages.
447 var allPageNames = Object.keys(OptionsPage.registeredPages).concat( 447 var allPageNames = Object.keys(PageManager.registeredPages).concat(
448 Object.keys(OptionsPage.registeredOverlayPages)); 448 Object.keys(PageManager.registeredOverlayPages));
449 var openPages = []; 449 var openPages = [];
450 for (var i = 0; i < allPageNames.length; ++i) { 450 for (var i = 0; i < allPageNames.length; ++i) {
451 var name = allPageNames[i]; 451 var name = allPageNames[i];
452 var page = OptionsPage.registeredPages[name] || 452 var page = PageManager.registeredPages[name] ||
453 OptionsPage.registeredOverlayPages[name]; 453 PageManager.registeredOverlayPages[name];
454 if (page.visible) 454 if (page.visible)
455 openPages.push(page.name); 455 openPages.push(page.name);
456 } 456 }
457 457
458 this.compareArrays_(expectedPages, openPages, true, 'Open pages'); 458 this.compareArrays_(expectedPages, openPages, true, 'Open pages');
459 }, 459 },
460 460
461 /* 461 /*
462 * Verifies that the correct URLs are listed in the history. Asynchronous. 462 * Verifies that the correct URLs are listed in the history. Asynchronous.
463 * @param {!Array.<string>} expectedHistory An array of URL paths expected to 463 * @param {!Array.<string>} expectedHistory An array of URL paths expected to
(...skipping 17 matching lines...) Expand all
481 } 481 }
482 self.compareArrays_(fullExpectedHistory, results, false, 'History'); 482 self.compareArrays_(fullExpectedHistory, results, false, 'History');
483 callback(); 483 callback();
484 }; 484 };
485 485
486 // The C++ fixture will call verifyHistoryCallback with the results. 486 // The C++ fixture will call verifyHistoryCallback with the results.
487 chrome.send('optionsTestReportHistory'); 487 chrome.send('optionsTestReportHistory');
488 }, 488 },
489 489
490 /** 490 /**
491 * Overrides the page callbacks for the given OptionsPage overlay to verify 491 * Overrides the page callbacks for the given PageManager overlay to verify
492 * that they are not called. 492 * that they are not called.
493 * @param {Object} overlay The singleton instance of the overlay. 493 * @param {Object} overlay The singleton instance of the overlay.
494 * @private 494 * @private
495 */ 495 */
496 prohibitChangesToOverlay_: function(overlay) { 496 prohibitChangesToOverlay_: function(overlay) {
497 overlay.initializePage = 497 overlay.initializePage =
498 overlay.didShowPage = 498 overlay.didShowPage =
499 overlay.didClosePage = function() { 499 overlay.didClosePage = function() {
500 assertTrue(false, 500 assertTrue(false,
501 'Overlay was affected when changes were prohibited.'); 501 'Overlay was affected when changes were prohibited.');
502 }; 502 };
503 }, 503 },
504 }; 504 };
505 505
506 /** 506 /**
507 * Set by verifyHistory_ to incorporate a followup callback, then called by the 507 * Set by verifyHistory_ to incorporate a followup callback, then called by the
508 * C++ fixture with the navigation history to be verified. 508 * C++ fixture with the navigation history to be verified.
509 * @type {Function} 509 * @type {Function}
510 */ 510 */
511 OptionsWebUIExtendedTest.verifyHistoryCallback = null; 511 OptionsWebUIExtendedTest.verifyHistoryCallback = null;
512 512
513 // Show the search page with no query string, to fall back to the settings page. 513 // Show the search page with no query string, to fall back to the settings page.
514 // Test disabled because it's flaky. crbug.com/303841 514 // Test disabled because it's flaky. crbug.com/303841
515 TEST_F('OptionsWebUIExtendedTest', 'DISABLED_ShowSearchPageNoQuery', 515 TEST_F('OptionsWebUIExtendedTest', 'DISABLED_ShowSearchPageNoQuery',
516 function() { 516 function() {
517 OptionsPage.showPageByName('search'); 517 PageManager.showPageByName('search');
518 this.verifyOpenPages_(['settings']); 518 this.verifyOpenPages_(['settings']);
519 this.verifyHistory_(['settings'], testDone); 519 this.verifyHistory_(['settings'], testDone);
520 }); 520 });
521 521
522 // Show a page without updating history. 522 // Show a page without updating history.
523 TEST_F('OptionsWebUIExtendedTest', 'ShowPageNoHistory', function() { 523 TEST_F('OptionsWebUIExtendedTest', 'ShowPageNoHistory', function() {
524 this.verifyOpenPages_(['settings'], ''); 524 this.verifyOpenPages_(['settings'], '');
525 // There are only two main pages, 'settings' and 'search'. It's not possible 525 // There are only two main pages, 'settings' and 'search'. It's not possible
526 // to show the search page using OptionsPage.showPageByName, because it 526 // to show the search page using PageManager.showPageByName, because it
527 // reverts to the settings page if it has no search text set. So we show the 527 // reverts to the settings page if it has no search text set. So we show the
528 // search page by performing a search, then test showPageByName. 528 // search page by performing a search, then test showPageByName.
529 $('search-field').onsearch({currentTarget: {value: 'query'}}); 529 $('search-field').onsearch({currentTarget: {value: 'query'}});
530 530
531 // The settings page is also still "open" (i.e., visible), in order to show 531 // The settings page is also still "open" (i.e., visible), in order to show
532 // the search results. Furthermore, the URL hasn't been updated in the parent 532 // the search results. Furthermore, the URL hasn't been updated in the parent
533 // page, because we've loaded the chrome-settings frame instead of the whole 533 // page, because we've loaded the chrome-settings frame instead of the whole
534 // settings page, so the cross-origin call to set the URL fails. 534 // settings page, so the cross-origin call to set the URL fails.
535 this.verifyOpenPages_(['settings', 'search'], 'search#query'); 535 this.verifyOpenPages_(['settings', 'search'], 'search#query');
536 var self = this; 536 var self = this;
537 this.verifyHistory_(['', 'search#query'], function() { 537 this.verifyHistory_(['', 'search#query'], function() {
538 OptionsPage.showPageByName('settings', false); 538 PageManager.showPageByName('settings', false);
539 self.verifyOpenPages_(['settings'], 'search#query'); 539 self.verifyOpenPages_(['settings'], 'search#query');
540 self.verifyHistory_(['', 'search#query'], testDone); 540 self.verifyHistory_(['', 'search#query'], testDone);
541 }); 541 });
542 }); 542 });
543 543
544 TEST_F('OptionsWebUIExtendedTest', 'ShowPageWithHistory', function() { 544 TEST_F('OptionsWebUIExtendedTest', 'ShowPageWithHistory', function() {
545 // See comments for ShowPageNoHistory. 545 // See comments for ShowPageNoHistory.
546 $('search-field').onsearch({currentTarget: {value: 'query'}}); 546 $('search-field').onsearch({currentTarget: {value: 'query'}});
547 var self = this; 547 var self = this;
548 this.verifyHistory_(['', 'search#query'], function() { 548 this.verifyHistory_(['', 'search#query'], function() {
549 OptionsPage.showPageByName('settings', true); 549 PageManager.showPageByName('settings', true);
550 self.verifyOpenPages_(['settings'], '#query'); 550 self.verifyOpenPages_(['settings'], '#query');
551 self.verifyHistory_(['', 'search#query', '#query'], 551 self.verifyHistory_(['', 'search#query', '#query'],
552 testDone); 552 testDone);
553 }); 553 });
554 }); 554 });
555 555
556 TEST_F('OptionsWebUIExtendedTest', 'ShowPageReplaceHistory', function() { 556 TEST_F('OptionsWebUIExtendedTest', 'ShowPageReplaceHistory', function() {
557 // See comments for ShowPageNoHistory. 557 // See comments for ShowPageNoHistory.
558 $('search-field').onsearch({currentTarget: {value: 'query'}}); 558 $('search-field').onsearch({currentTarget: {value: 'query'}});
559 var self = this; 559 var self = this;
560 this.verifyHistory_(['', 'search#query'], function() { 560 this.verifyHistory_(['', 'search#query'], function() {
561 OptionsPage.showPageByName('settings', true, {'replaceState': true}); 561 PageManager.showPageByName('settings', true, {'replaceState': true});
562 self.verifyOpenPages_(['settings'], '#query'); 562 self.verifyOpenPages_(['settings'], '#query');
563 self.verifyHistory_(['', '#query'], testDone); 563 self.verifyHistory_(['', '#query'], testDone);
564 }); 564 });
565 }); 565 });
566 566
567 // This should be identical to ShowPageWithHisory. 567 // This should be identical to ShowPageWithHisory.
568 TEST_F('OptionsWebUIExtendedTest', 'NavigateToPage', function() { 568 TEST_F('OptionsWebUIExtendedTest', 'NavigateToPage', function() {
569 // See comments for ShowPageNoHistory. 569 // See comments for ShowPageNoHistory.
570 $('search-field').onsearch({currentTarget: {value: 'query'}}); 570 $('search-field').onsearch({currentTarget: {value: 'query'}});
571 var self = this; 571 var self = this;
572 this.verifyHistory_(['', 'search#query'], function() { 572 this.verifyHistory_(['', 'search#query'], function() {
573 OptionsPage.navigateToPage('settings'); 573 PageManager.navigateToPage('settings');
574 self.verifyOpenPages_(['settings'], '#query'); 574 self.verifyOpenPages_(['settings'], '#query');
575 self.verifyHistory_(['', 'search#query', '#query'], 575 self.verifyHistory_(['', 'search#query', '#query'],
576 testDone); 576 testDone);
577 }); 577 });
578 }); 578 });
579 579
580 // Settings overlays are much more straightforward than settings pages, opening 580 // Settings overlays are much more straightforward than settings pages, opening
581 // normally with none of the latter's quirks in the expected history or URL. 581 // normally with none of the latter's quirks in the expected history or URL.
582 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayNoHistory', function() { 582 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayNoHistory', function() {
583 // Open a layer-1 overlay, not updating history. 583 // Open a layer-1 overlay, not updating history.
584 OptionsPage.showPageByName('languages', false); 584 PageManager.showPageByName('languages', false);
585 this.verifyOpenPages_(['settings', 'languages'], ''); 585 this.verifyOpenPages_(['settings', 'languages'], '');
586 586
587 var self = this; 587 var self = this;
588 this.verifyHistory_([''], function() { 588 this.verifyHistory_([''], function() {
589 // Open a layer-2 overlay for which the layer-1 is a parent, not updating 589 // Open a layer-2 overlay for which the layer-1 is a parent, not updating
590 // history. 590 // history.
591 OptionsPage.showPageByName('addLanguage', false); 591 PageManager.showPageByName('addLanguage', false);
592 self.verifyOpenPages_(['settings', 'languages', 'addLanguage'], 592 self.verifyOpenPages_(['settings', 'languages', 'addLanguage'],
593 ''); 593 '');
594 self.verifyHistory_([''], testDone); 594 self.verifyHistory_([''], testDone);
595 }); 595 });
596 }); 596 });
597 597
598 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayWithHistory', function() { 598 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayWithHistory', function() {
599 // Open a layer-1 overlay, updating history. 599 // Open a layer-1 overlay, updating history.
600 OptionsPage.showPageByName('languages', true); 600 PageManager.showPageByName('languages', true);
601 this.verifyOpenPages_(['settings', 'languages']); 601 this.verifyOpenPages_(['settings', 'languages']);
602 602
603 var self = this; 603 var self = this;
604 this.verifyHistory_(['', 'languages'], function() { 604 this.verifyHistory_(['', 'languages'], function() {
605 // Open a layer-2 overlay, updating history. 605 // Open a layer-2 overlay, updating history.
606 OptionsPage.showPageByName('addLanguage', true); 606 PageManager.showPageByName('addLanguage', true);
607 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 607 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
608 self.verifyHistory_(['', 'languages', 'addLanguage'], testDone); 608 self.verifyHistory_(['', 'languages', 'addLanguage'], testDone);
609 }); 609 });
610 }); 610 });
611 611
612 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayReplaceHistory', function() { 612 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayReplaceHistory', function() {
613 // Open a layer-1 overlay, updating history. 613 // Open a layer-1 overlay, updating history.
614 OptionsPage.showPageByName('languages', true); 614 PageManager.showPageByName('languages', true);
615 var self = this; 615 var self = this;
616 this.verifyHistory_(['', 'languages'], function() { 616 this.verifyHistory_(['', 'languages'], function() {
617 // Open a layer-2 overlay, replacing history. 617 // Open a layer-2 overlay, replacing history.
618 OptionsPage.showPageByName('addLanguage', true, {'replaceState': true}); 618 PageManager.showPageByName('addLanguage', true, {'replaceState': true});
619 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 619 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
620 self.verifyHistory_(['', 'addLanguage'], testDone); 620 self.verifyHistory_(['', 'addLanguage'], testDone);
621 }); 621 });
622 }); 622 });
623 623
624 // Directly show an overlay further above this page, i.e. one for which the 624 // Directly show an overlay further above this page, i.e. one for which the
625 // current page is an ancestor but not a parent. 625 // current page is an ancestor but not a parent.
626 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayFurtherAbove', function() { 626 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayFurtherAbove', function() {
627 // Open a layer-2 overlay directly. 627 // Open a layer-2 overlay directly.
628 OptionsPage.showPageByName('addLanguage', true); 628 PageManager.showPageByName('addLanguage', true);
629 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 629 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
630 var self = this; 630 var self = this;
631 this.verifyHistory_(['', 'addLanguage'], testDone); 631 this.verifyHistory_(['', 'addLanguage'], testDone);
632 }); 632 });
633 633
634 // Directly show a layer-2 overlay for which the layer-1 overlay is not a 634 // Directly show a layer-2 overlay for which the layer-1 overlay is not a
635 // parent. 635 // parent.
636 TEST_F('OptionsWebUIExtendedTest', 'ShowUnrelatedOverlay', function() { 636 TEST_F('OptionsWebUIExtendedTest', 'ShowUnrelatedOverlay', function() {
637 // Open a layer-1 overlay. 637 // Open a layer-1 overlay.
638 OptionsPage.showPageByName('languages', true); 638 PageManager.showPageByName('languages', true);
639 this.verifyOpenPages_(['settings', 'languages']); 639 this.verifyOpenPages_(['settings', 'languages']);
640 640
641 var self = this; 641 var self = this;
642 this.verifyHistory_(['', 'languages'], function() { 642 this.verifyHistory_(['', 'languages'], function() {
643 // Open an unrelated layer-2 overlay. 643 // Open an unrelated layer-2 overlay.
644 OptionsPage.showPageByName('cookies', true); 644 PageManager.showPageByName('cookies', true);
645 self.verifyOpenPages_(['settings', 'content', 'cookies']); 645 self.verifyOpenPages_(['settings', 'content', 'cookies']);
646 self.verifyHistory_(['', 'languages', 'cookies'], testDone); 646 self.verifyHistory_(['', 'languages', 'cookies'], testDone);
647 }); 647 });
648 }); 648 });
649 649
650 // Close an overlay. 650 // Close an overlay.
651 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlay', function() { 651 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlay', function() {
652 // Open a layer-1 overlay, then a layer-2 overlay on top of it. 652 // Open a layer-1 overlay, then a layer-2 overlay on top of it.
653 OptionsPage.showPageByName('languages', true); 653 PageManager.showPageByName('languages', true);
654 this.verifyOpenPages_(['settings', 'languages']); 654 this.verifyOpenPages_(['settings', 'languages']);
655 OptionsPage.showPageByName('addLanguage', true); 655 PageManager.showPageByName('addLanguage', true);
656 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 656 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
657 657
658 var self = this; 658 var self = this;
659 this.verifyHistory_(['', 'languages', 'addLanguage'], function() { 659 this.verifyHistory_(['', 'languages', 'addLanguage'], function() {
660 // Close the layer-2 overlay. 660 // Close the layer-2 overlay.
661 OptionsPage.closeOverlay(); 661 PageManager.closeOverlay();
662 self.verifyOpenPages_(['settings', 'languages']); 662 self.verifyOpenPages_(['settings', 'languages']);
663 self.verifyHistory_( 663 self.verifyHistory_(
664 ['', 'languages', 'addLanguage', 'languages'], 664 ['', 'languages', 'addLanguage', 'languages'],
665 function() { 665 function() {
666 // Close the layer-1 overlay. 666 // Close the layer-1 overlay.
667 OptionsPage.closeOverlay(); 667 PageManager.closeOverlay();
668 self.verifyOpenPages_(['settings'], ''); 668 self.verifyOpenPages_(['settings'], '');
669 self.verifyHistory_( 669 self.verifyHistory_(
670 ['', 'languages', 'addLanguage', 'languages', ''], 670 ['', 'languages', 'addLanguage', 'languages', ''],
671 testDone); 671 testDone);
672 }); 672 });
673 }); 673 });
674 }); 674 });
675 675
676 // Test that closing an overlay that did not push history when opening does not 676 // Test that closing an overlay that did not push history when opening does not
677 // again push history. 677 // again push history.
678 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { 678 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() {
679 // Open the do not track confirmation prompt. 679 // Open the do not track confirmation prompt.
680 OptionsPage.showPageByName('doNotTrackConfirm', false); 680 PageManager.showPageByName('doNotTrackConfirm', false);
681 681
682 // Opening the prompt does not add to the history. 682 // Opening the prompt does not add to the history.
683 this.verifyHistory_([''], function() { 683 this.verifyHistory_([''], function() {
684 // Close the overlay. 684 // Close the overlay.
685 OptionsPage.closeOverlay(); 685 PageManager.closeOverlay();
686 // Still no history changes. 686 // Still no history changes.
687 this.verifyHistory_([''], testDone); 687 this.verifyHistory_([''], testDone);
688 }.bind(this)); 688 }.bind(this));
689 }); 689 });
690 690
691 // Make sure an overlay isn't closed (even temporarily) when another overlay is 691 // Make sure an overlay isn't closed (even temporarily) when another overlay is
692 // opened on top. 692 // opened on top.
693 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() { 693 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() {
694 // Open a layer-1 overlay. 694 // Open a layer-1 overlay.
695 OptionsPage.showPageByName('languages', true); 695 PageManager.showPageByName('languages', true);
696 this.verifyOpenPages_(['settings', 'languages']); 696 this.verifyOpenPages_(['settings', 'languages']);
697 697
698 // Open a layer-2 overlay on top. This should not close 'languages'. 698 // Open a layer-2 overlay on top. This should not close 'languages'.
699 this.prohibitChangesToOverlay_(options.LanguageOptions.getInstance()); 699 this.prohibitChangesToOverlay_(options.LanguageOptions.getInstance());
700 OptionsPage.showPageByName('addLanguage', true); 700 PageManager.showPageByName('addLanguage', true);
701 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 701 this.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
702 testDone(); 702 testDone();
703 }); 703 });
704 704
705 TEST_F('OptionsWebUIExtendedTest', 'OverlayTabNavigation', function() { 705 TEST_F('OptionsWebUIExtendedTest', 'OverlayTabNavigation', function() {
706 // Open a layer-1 overlay, then a layer-2 overlay on top of it. 706 // Open a layer-1 overlay, then a layer-2 overlay on top of it.
707 OptionsPage.showPageByName('languages', true); 707 PageManager.showPageByName('languages', true);
708 OptionsPage.showPageByName('addLanguage', true); 708 PageManager.showPageByName('addLanguage', true);
709 var self = this; 709 var self = this;
710 710
711 // Go back twice, then forward twice. 711 // Go back twice, then forward twice.
712 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 712 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
713 self.verifyHistory_(['', 'languages', 'addLanguage'], function() { 713 self.verifyHistory_(['', 'languages', 'addLanguage'], function() {
714 window.history.back(); 714 window.history.back();
715 waitForPopstate(function() { 715 waitForPopstate(function() {
716 self.verifyOpenPages_(['settings', 'languages']); 716 self.verifyOpenPages_(['settings', 'languages']);
717 self.verifyHistory_(['', 'languages'], function() { 717 self.verifyHistory_(['', 'languages'], function() {
718 window.history.back(); 718 window.history.back();
(...skipping 17 matching lines...) Expand all
736 }); 736 });
737 }); 737 });
738 }); 738 });
739 }); 739 });
740 }); 740 });
741 741
742 // Going "back" to an overlay that's a child of the current overlay shouldn't 742 // Going "back" to an overlay that's a child of the current overlay shouldn't
743 // close the current one. 743 // close the current one.
744 TEST_F('OptionsWebUIExtendedTest', 'OverlayBackToChild', function() { 744 TEST_F('OptionsWebUIExtendedTest', 'OverlayBackToChild', function() {
745 // Open a layer-1 overlay, then a layer-2 overlay on top of it. 745 // Open a layer-1 overlay, then a layer-2 overlay on top of it.
746 OptionsPage.showPageByName('languages', true); 746 PageManager.showPageByName('languages', true);
747 OptionsPage.showPageByName('addLanguage', true); 747 PageManager.showPageByName('addLanguage', true);
748 var self = this; 748 var self = this;
749 749
750 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 750 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
751 self.verifyHistory_(['', 'languages', 'addLanguage'], function() { 751 self.verifyHistory_(['', 'languages', 'addLanguage'], function() {
752 // Close the top overlay, then go back to it. 752 // Close the top overlay, then go back to it.
753 OptionsPage.closeOverlay(); 753 PageManager.closeOverlay();
754 self.verifyOpenPages_(['settings', 'languages']); 754 self.verifyOpenPages_(['settings', 'languages']);
755 self.verifyHistory_( 755 self.verifyHistory_(
756 ['', 'languages', 'addLanguage', 'languages'], 756 ['', 'languages', 'addLanguage', 'languages'],
757 function() { 757 function() {
758 // Going back to the 'addLanguage' page should not close 'languages'. 758 // Going back to the 'addLanguage' page should not close 'languages'.
759 self.prohibitChangesToOverlay_(options.LanguageOptions.getInstance()); 759 self.prohibitChangesToOverlay_(options.LanguageOptions.getInstance());
760 window.history.back(); 760 window.history.back();
761 waitForPopstate(function() { 761 waitForPopstate(function() {
762 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']); 762 self.verifyOpenPages_(['settings', 'languages', 'addLanguage']);
763 self.verifyHistory_(['', 'languages', 'addLanguage'], 763 self.verifyHistory_(['', 'languages', 'addLanguage'],
764 testDone); 764 testDone);
765 }); 765 });
766 }); 766 });
767 }); 767 });
768 }); 768 });
769 769
770 // Going back to an unrelated overlay should close the overlay and its parent. 770 // Going back to an unrelated overlay should close the overlay and its parent.
771 TEST_F('OptionsWebUIExtendedTest', 'OverlayBackToUnrelated', function() { 771 TEST_F('OptionsWebUIExtendedTest', 'OverlayBackToUnrelated', function() {
772 // Open a layer-1 overlay, then an unrelated layer-2 overlay. 772 // Open a layer-1 overlay, then an unrelated layer-2 overlay.
773 OptionsPage.showPageByName('languages', true); 773 PageManager.showPageByName('languages', true);
774 OptionsPage.showPageByName('cookies', true); 774 PageManager.showPageByName('cookies', true);
775 var self = this; 775 var self = this;
776 self.verifyOpenPages_(['settings', 'content', 'cookies']); 776 self.verifyOpenPages_(['settings', 'content', 'cookies']);
777 self.verifyHistory_(['', 'languages', 'cookies'], function() { 777 self.verifyHistory_(['', 'languages', 'cookies'], function() {
778 window.history.back(); 778 window.history.back();
779 waitForPopstate(function() { 779 waitForPopstate(function() {
780 self.verifyOpenPages_(['settings', 'languages']); 780 self.verifyOpenPages_(['settings', 'languages']);
781 testDone(); 781 testDone();
782 }); 782 });
783 }); 783 });
784 }); 784 });
785 785
786 // Verify history changes properly while the page is loading. 786 // Verify history changes properly while the page is loading.
787 TEST_F('OptionsWebUIExtendedTest', 'HistoryUpdatedAfterLoading', function() { 787 TEST_F('OptionsWebUIExtendedTest', 'HistoryUpdatedAfterLoading', function() {
788 var loc = location.href; 788 var loc = location.href;
789 789
790 document.documentElement.classList.add('loading'); 790 document.documentElement.classList.add('loading');
791 assertTrue(OptionsPage.isLoading()); 791 assertTrue(PageManager.isLoading());
792 OptionsPage.navigateToPage('searchEngines'); 792 PageManager.navigateToPage('searchEngines');
793 expectNotEquals(loc, location.href); 793 expectNotEquals(loc, location.href);
794 794
795 document.documentElement.classList.remove('loading'); 795 document.documentElement.classList.remove('loading');
796 assertFalse(OptionsPage.isLoading()); 796 assertFalse(PageManager.isLoading());
797 OptionsPage.showDefaultPage(); 797 PageManager.showDefaultPage();
798 expectEquals(loc, location.href); 798 expectEquals(loc, location.href);
799 799
800 testDone(); 800 testDone();
801 }); 801 });
802 802
803 // A tip should be shown or hidden depending on whether this profile manages any 803 // A tip should be shown or hidden depending on whether this profile manages any
804 // supervised users. 804 // supervised users.
805 TEST_F('OptionsWebUIExtendedTest', 'SupervisingUsers', function() { 805 TEST_F('OptionsWebUIExtendedTest', 'SupervisingUsers', function() {
806 // We start managing no supervised users. 806 // We start managing no supervised users.
807 assertTrue($('profiles-supervised-dashboard-tip').hidden); 807 assertTrue($('profiles-supervised-dashboard-tip').hidden);
(...skipping 25 matching lines...) Expand all
833 __proto__: OptionsWebUIExtendedTest.prototype, 833 __proto__: OptionsWebUIExtendedTest.prototype,
834 834
835 /** @override */ 835 /** @override */
836 browsePreload: 'chrome://settings-frame/nonexistantPage', 836 browsePreload: 'chrome://settings-frame/nonexistantPage',
837 }; 837 };
838 838
839 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { 839 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() {
840 assertEquals('chrome://settings-frame/', document.location.href); 840 assertEquals('chrome://settings-frame/', document.location.href);
841 this.verifyHistory_([''], testDone); 841 this.verifyHistory_([''], testDone);
842 }); 842 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698