| OLD | NEW |
| 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 SUPERVISED_USERS_PREF = 'profile.managed_users'; | 7 /** @const */ var SUPERVISED_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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 | 513 |
| 514 // Show the search page with no query string, to fall back to the settings page. | 514 // Show the search page with no query string, to fall back to the settings page. |
| 515 // Test disabled because it's flaky. crbug.com/303841 | 515 // Test disabled because it's flaky. crbug.com/303841 |
| 516 TEST_F('OptionsWebUIExtendedTest', 'DISABLED_ShowSearchPageNoQuery', | 516 TEST_F('OptionsWebUIExtendedTest', 'DISABLED_ShowSearchPageNoQuery', |
| 517 function() { | 517 function() { |
| 518 PageManager.showPageByName('search'); | 518 PageManager.showPageByName('search'); |
| 519 this.verifyOpenPages_(['settings']); | 519 this.verifyOpenPages_(['settings']); |
| 520 this.verifyHistory_(['settings'], testDone); | 520 this.verifyHistory_(['settings'], testDone); |
| 521 }); | 521 }); |
| 522 | 522 |
| 523 // Manipulate the search page via the search field. |
| 524 TEST_F('OptionsWebUIExtendedTest', 'ShowSearchFromField', function() { |
| 525 $('search-field').onsearch({currentTarget: {value: 'query'}}); |
| 526 this.verifyOpenPages_(['settings', 'search'], 'search#query'); |
| 527 this.verifyHistory_(['', 'search#query'], function() { |
| 528 $('search-field').onsearch({currentTarget: {value: 'query2'}}); |
| 529 this.verifyOpenPages_(['settings', 'search'], 'search#query2'); |
| 530 this.verifyHistory_(['', 'search#query', 'search#query2'], function() { |
| 531 $('search-field').onsearch({currentTarget: {value: ''}}); |
| 532 this.verifyOpenPages_(['settings'], ''); |
| 533 this.verifyHistory_(['', 'search#query', 'search#query2', ''], testDone); |
| 534 }.bind(this)); |
| 535 }.bind(this)); |
| 536 }); |
| 537 |
| 523 // Show a page without updating history. | 538 // Show a page without updating history. |
| 524 TEST_F('OptionsWebUIExtendedTest', 'ShowPageNoHistory', function() { | 539 TEST_F('OptionsWebUIExtendedTest', 'ShowPageNoHistory', function() { |
| 525 this.verifyOpenPages_(['settings'], ''); | 540 this.verifyOpenPages_(['settings'], ''); |
| 526 // There are only two main pages, 'settings' and 'search'. It's not possible | 541 PageManager.showPageByName('search', true, {hash: '#query'}); |
| 527 // to show the search page using PageManager.showPageByName, because it | |
| 528 // reverts to the settings page if it has no search text set. So we show the | |
| 529 // search page by performing a search, then test showPageByName. | |
| 530 $('search-field').onsearch({currentTarget: {value: 'query'}}); | |
| 531 | 542 |
| 532 // The settings page is also still "open" (i.e., visible), in order to show | 543 // The settings page is also still "open" (i.e., visible), in order to show |
| 533 // the search results. Furthermore, the URL hasn't been updated in the parent | 544 // the search results. Furthermore, the URL hasn't been updated in the parent |
| 534 // page, because we've loaded the chrome-settings frame instead of the whole | 545 // page, because we've loaded the chrome-settings frame instead of the whole |
| 535 // settings page, so the cross-origin call to set the URL fails. | 546 // settings page, so the cross-origin call to set the URL fails. |
| 536 this.verifyOpenPages_(['settings', 'search'], 'search#query'); | 547 this.verifyOpenPages_(['settings', 'search'], 'search#query'); |
| 537 var self = this; | 548 var self = this; |
| 538 this.verifyHistory_(['', 'search#query'], function() { | 549 this.verifyHistory_(['', 'search#query'], function() { |
| 539 PageManager.showPageByName('settings', false); | 550 PageManager.showPageByName('settings', false); |
| 540 self.verifyOpenPages_(['settings'], 'search#query'); | 551 self.verifyOpenPages_(['settings'], 'search#query'); |
| 541 self.verifyHistory_(['', 'search#query'], testDone); | 552 self.verifyHistory_(['', 'search#query'], testDone); |
| 542 }); | 553 }); |
| 543 }); | 554 }); |
| 544 | 555 |
| 545 TEST_F('OptionsWebUIExtendedTest', 'ShowPageWithHistory', function() { | 556 TEST_F('OptionsWebUIExtendedTest', 'ShowPageWithHistory', function() { |
| 546 // See comments for ShowPageNoHistory. | 557 PageManager.showPageByName('search', true, {hash: '#query'}); |
| 547 $('search-field').onsearch({currentTarget: {value: 'query'}}); | |
| 548 var self = this; | 558 var self = this; |
| 549 this.verifyHistory_(['', 'search#query'], function() { | 559 this.verifyHistory_(['', 'search#query'], function() { |
| 550 PageManager.showPageByName('settings', true); | 560 PageManager.showPageByName('settings', true); |
| 551 self.verifyOpenPages_(['settings'], '#query'); | 561 self.verifyOpenPages_(['settings'], ''); |
| 552 self.verifyHistory_(['', 'search#query', '#query'], | 562 self.verifyHistory_(['', 'search#query', ''], |
| 553 testDone); | 563 testDone); |
| 554 }); | 564 }); |
| 555 }); | 565 }); |
| 556 | 566 |
| 557 TEST_F('OptionsWebUIExtendedTest', 'ShowPageReplaceHistory', function() { | 567 TEST_F('OptionsWebUIExtendedTest', 'ShowPageReplaceHistory', function() { |
| 558 // See comments for ShowPageNoHistory. | 568 PageManager.showPageByName('search', true, {hash: '#query'}); |
| 559 $('search-field').onsearch({currentTarget: {value: 'query'}}); | |
| 560 var self = this; | 569 var self = this; |
| 561 this.verifyHistory_(['', 'search#query'], function() { | 570 this.verifyHistory_(['', 'search#query'], function() { |
| 562 PageManager.showPageByName('settings', true, {'replaceState': true}); | 571 PageManager.showPageByName('settings', true, {'replaceState': true}); |
| 563 self.verifyOpenPages_(['settings'], '#query'); | 572 self.verifyOpenPages_(['settings'], ''); |
| 564 self.verifyHistory_(['', '#query'], testDone); | 573 self.verifyHistory_(['', ''], testDone); |
| 565 }); | 574 }); |
| 566 }); | 575 }); |
| 567 | 576 |
| 568 // This should be identical to ShowPageWithHisory. | 577 // This should be identical to ShowPageWithHisory. |
| 569 TEST_F('OptionsWebUIExtendedTest', 'NavigateToPage', function() { | 578 TEST_F('OptionsWebUIExtendedTest', 'NavigateToPage', function() { |
| 570 // See comments for ShowPageNoHistory. | 579 PageManager.showPageByName('search', true, {hash: '#query'}); |
| 571 $('search-field').onsearch({currentTarget: {value: 'query'}}); | |
| 572 var self = this; | 580 var self = this; |
| 573 this.verifyHistory_(['', 'search#query'], function() { | 581 this.verifyHistory_(['', 'search#query'], function() { |
| 574 PageManager.showPageByName('settings'); | 582 PageManager.showPageByName('settings'); |
| 575 self.verifyOpenPages_(['settings'], '#query'); | 583 self.verifyOpenPages_(['settings'], ''); |
| 576 self.verifyHistory_(['', 'search#query', '#query'], | 584 self.verifyHistory_(['', 'search#query', ''], testDone); |
| 577 testDone); | |
| 578 }); | 585 }); |
| 579 }); | 586 }); |
| 580 | 587 |
| 581 // Settings overlays are much more straightforward than settings pages, opening | 588 // Settings overlays are much more straightforward than settings pages, opening |
| 582 // normally with none of the latter's quirks in the expected history or URL. | 589 // normally with none of the latter's quirks in the expected history or URL. |
| 583 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayNoHistory', function() { | 590 TEST_F('OptionsWebUIExtendedTest', 'ShowOverlayNoHistory', function() { |
| 584 // Open a layer-1 overlay, not updating history. | 591 // Open a layer-1 overlay, not updating history. |
| 585 PageManager.showPageByName('languages', false); | 592 PageManager.showPageByName('languages', false); |
| 586 this.verifyOpenPages_(['settings', 'languages'], ''); | 593 this.verifyOpenPages_(['settings', 'languages'], ''); |
| 587 | 594 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 // Close the layer-1 overlay. | 674 // Close the layer-1 overlay. |
| 668 PageManager.closeOverlay(); | 675 PageManager.closeOverlay(); |
| 669 self.verifyOpenPages_(['settings'], ''); | 676 self.verifyOpenPages_(['settings'], ''); |
| 670 self.verifyHistory_( | 677 self.verifyHistory_( |
| 671 ['', 'languages', 'addLanguage', 'languages', ''], | 678 ['', 'languages', 'addLanguage', 'languages', ''], |
| 672 testDone); | 679 testDone); |
| 673 }); | 680 }); |
| 674 }); | 681 }); |
| 675 }); | 682 }); |
| 676 | 683 |
| 684 // Hashes are maintained separately for each page and are preserved when |
| 685 // overlays close. |
| 686 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayWithHashes', function() { |
| 687 // Open an overlay on top of the search page. |
| 688 PageManager.showPageByName('search', true, {hash: '#1'}); |
| 689 this.verifyOpenPages_(['settings', 'search'], 'search#1'); |
| 690 PageManager.showPageByName('languages', true, {hash: '#2'}); |
| 691 this.verifyOpenPages_(['settings', 'search', 'languages'], |
| 692 'languages#2'); |
| 693 PageManager.showPageByName('addLanguage', true, {hash: '#3'}); |
| 694 this.verifyOpenPages_(['settings', 'search', 'languages', 'addLanguage'], |
| 695 'addLanguage#3'); |
| 696 |
| 697 this.verifyHistory_(['', 'search#1', 'languages#2', 'addLanguage#3'], |
| 698 function() { |
| 699 // Close the layer-2 overlay. |
| 700 PageManager.closeOverlay(); |
| 701 this.verifyOpenPages_(['settings', 'search', 'languages'], 'languages#2'); |
| 702 this.verifyHistory_( |
| 703 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2'], |
| 704 function() { |
| 705 // Close the layer-1 overlay. |
| 706 PageManager.closeOverlay(); |
| 707 this.verifyOpenPages_(['settings', 'search'], 'search#1'); |
| 708 this.verifyHistory_( |
| 709 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2', |
| 710 'search#1'], |
| 711 testDone); |
| 712 }.bind(this)); |
| 713 }.bind(this)); |
| 714 }); |
| 715 |
| 677 // Test that closing an overlay that did not push history when opening does not | 716 // Test that closing an overlay that did not push history when opening does not |
| 678 // again push history. | 717 // again push history. |
| 679 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { | 718 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { |
| 680 // Open the do not track confirmation prompt. | 719 // Open the do not track confirmation prompt. |
| 681 PageManager.showPageByName('doNotTrackConfirm', false); | 720 PageManager.showPageByName('doNotTrackConfirm', false); |
| 682 | 721 |
| 683 // Opening the prompt does not add to the history. | 722 // Opening the prompt does not add to the history. |
| 684 this.verifyHistory_([''], function() { | 723 this.verifyHistory_([''], function() { |
| 685 // Close the overlay. | 724 // Close the overlay. |
| 686 PageManager.closeOverlay(); | 725 PageManager.closeOverlay(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 __proto__: OptionsWebUIExtendedTest.prototype, | 873 __proto__: OptionsWebUIExtendedTest.prototype, |
| 835 | 874 |
| 836 /** @override */ | 875 /** @override */ |
| 837 browsePreload: 'chrome://settings-frame/nonexistantPage', | 876 browsePreload: 'chrome://settings-frame/nonexistantPage', |
| 838 }; | 877 }; |
| 839 | 878 |
| 840 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { | 879 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { |
| 841 assertEquals('chrome://settings-frame/', document.location.href); | 880 assertEquals('chrome://settings-frame/', document.location.href); |
| 842 this.verifyHistory_([''], testDone); | 881 this.verifyHistory_([''], testDone); |
| 843 }); | 882 }); |
| OLD | NEW |