Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Utility functions for settings WebUI page. | |
|
James Hawkins
2011/07/08 00:03:33
s/settings/options/ here and elsewhere. We don't c
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 6 var util = { | |
| 7 'refreshPage': function() { | |
|
James Hawkins
2011/07/08 00:03:33
Why can't callers just call window.location.reload
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 8 window.location.reload(); | |
| 9 }, | |
| 10 'openUnderTheHood': function() { | |
|
James Hawkins
2011/07/08 00:03:33
Why is this in |util|?
Sheridan Rawlins
2011/07/08 22:45:49
Because of original generate all global functions.
| |
| 11 var item = $('advancedPageNav'); | |
| 12 assertTrue(item != null); | |
|
James Hawkins
2011/07/08 00:03:33
Are these asserts needed? If either of these condi
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 13 assertTrue(item.onclick != null); | |
| 14 item.onclick(); | |
| 15 }, | |
| 16 }; | |
| 17 | |
| 18 (function() { | |
|
James Hawkins
2011/07/08 00:03:33
Documentation.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 19 function MockHandler() { | |
| 20 this.__proto__ = MockHandler.prototype; | |
| 21 } | |
| 22 | |
| 23 MockHandler.prototype = { | |
| 24 'called': {}, | |
|
James Hawkins
2011/07/08 00:03:33
Documentation.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 25 'coreOptionsInitialize': function() { | |
| 26 console.log('coreOptionsInitialize'); | |
| 27 }, | |
| 28 'fetchPrefs': function() { | |
| 29 console.log('fetchPrefs'); | |
| 30 }, | |
| 31 'observePrefs': function() { | |
| 32 console.log('observePrefs'); | |
| 33 }, | |
| 34 'setBooleanPref': function(inlist) { | |
| 35 ++this.called['setBooleanPref']; | |
| 36 console.log('setBooleanPref'); | |
| 37 var true_list_value = ['browser.show_home_button', | |
| 38 true, | |
| 39 'Options_Homepage_HomeButton']; | |
| 40 assertEqualsArray(true_list_value, inlist); | |
| 41 }, | |
| 42 'setIntegerPref': function() { | |
| 43 console.log('setIntegerPref'); | |
| 44 }, | |
| 45 'setDoublePref': function() { | |
| 46 console.log('setDoublePref'); | |
| 47 }, | |
| 48 'setStringPref': function() { | |
| 49 console.log('setStringPref'); | |
| 50 }, | |
| 51 'setObjectPref': function() { | |
| 52 console.log('setObjectPref'); | |
| 53 }, | |
| 54 'clearPref': function() { | |
| 55 console.log('clearPref'); | |
| 56 }, | |
| 57 'coreOptionsUserMetricsAction': function() { | |
| 58 console.log('coreOptionsUserMetricsAction'); | |
| 59 }, | |
| 60 }; | |
| 61 | |
| 62 function registerCallbacks() { | |
| 63 console.log('registeringCallbacks'); | |
|
James Hawkins
2011/07/08 00:03:33
Remove logging.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 64 var mock_handler = new MockHandler(); | |
| 65 for (func in MockHandler.prototype) { | |
| 66 if (typeof(mock_handler[func]) == 'function') | |
| 67 registerMessageCallback(func, | |
| 68 mock_handler, | |
| 69 mock_handler[func]); | |
| 70 } | |
| 71 }; | |
| 72 | |
| 73 if ('window' in this && 'registerMessageCallback' in window) | |
|
James Hawkins
2011/07/08 00:03:33
What's with this line?
Sheridan Rawlins
2011/07/08 22:45:49
Not needed with subclassing of testing::Test - Can
| |
| 74 registerCallbacks(); | |
| 75 })(); | |
| 76 | |
| 77 | |
| 78 // Tests. | |
|
James Hawkins
2011/07/08 00:03:33
Remove useless comment.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
| |
| 79 function testSetBooleanPrefTriggers() { | |
| 80 // TODO(dtseng): make generic to click all buttons. | |
| 81 var showHomeButton = $('toolbarShowHomeButton'); | |
| 82 assertTrue(showHomeButton != null); | |
| 83 showHomeButton.click(); | |
| 84 showHomeButton.blur(); | |
| 85 } | |
| 86 | |
| 87 // Crashes on Mac only. See http://crbug.com/79181 | |
| 88 if (this['OS_MACOSX'] !== undefined) { | |
| 89 this['DISABLED_testSetBooleanPrefTriggers'] = testSetBooleanPrefTriggers; | |
| 90 delete testSetBooleanPrefTriggers; | |
| 91 } | |
| 92 | |
| 93 function testPageIsUnderTheHood() { | |
| 94 util.openUnderTheHood(); | |
| 95 util.refreshPage(); | |
|
James Hawkins
2011/07/08 00:03:33
Why do you have to refresh the page after opening
Sheridan Rawlins
2011/07/08 22:45:49
The test is to ensure that refresh stays on the cu
| |
| 96 var pageInstance = AdvancedOptions.getInstance(); | |
| 97 var topPage = OptionsPage.getTopmostVisiblePage(); | |
| 98 var expectedTitle = pageInstance.title; | |
| 99 var actualTitle = document.title; | |
| 100 assertEquals("chrome://settings/advanced", document.location.href); | |
| 101 assertEquals(expectedTitle, actualTitle); | |
| 102 assertEquals(pageInstance, topPage); | |
| 103 } | |
| 104 | |
| 105 // Not meant to run on ChromeOS at this time. | |
| 106 // Not finishing in windows. http://crbug.com/81723 | |
| 107 if (this['OS_CHROMEOS'] !== undefined || | |
| 108 this['OS_MACOSX'] !== undefined || | |
| 109 this['OS_WIN'] !== undefined || | |
| 110 this['TOUCH_UI'] !== undefined) { | |
| 111 this['DISABLED_testPageIsUnderTheHood'] = testPageIsUnderTheHood; | |
| 112 delete testPageIsUnderTheHood; | |
| 113 } | |
| 114 | |
| 115 var testFixture = 'SettingsWebUITest'; | |
|
James Hawkins
2011/07/08 00:03:33
Move these vars to the top of the file and documen
Sheridan Rawlins
2011/07/08 22:45:49
Not needed now that we have test_fixture to hold t
| |
| 116 var testBrowsePreload = 'chrome://settings'; | |
| OLD | NEW |