Index: chrome/test/data/webui/options.js |
diff --git a/chrome/test/data/webui/options.js b/chrome/test/data/webui/options.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0bd980576cc63362d4577ae0073a606ee680f087 |
--- /dev/null |
+++ b/chrome/test/data/webui/options.js |
@@ -0,0 +1,116 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// 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.
|
+var util = { |
+ '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.
|
+ window.location.reload(); |
+ }, |
+ '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.
|
+ var item = $('advancedPageNav'); |
+ 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.
|
+ assertTrue(item.onclick != null); |
+ item.onclick(); |
+ }, |
+}; |
+ |
+(function() { |
James Hawkins
2011/07/08 00:03:33
Documentation.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
|
+ function MockHandler() { |
+ this.__proto__ = MockHandler.prototype; |
+ } |
+ |
+ MockHandler.prototype = { |
+ 'called': {}, |
James Hawkins
2011/07/08 00:03:33
Documentation.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
|
+ 'coreOptionsInitialize': function() { |
+ console.log('coreOptionsInitialize'); |
+ }, |
+ 'fetchPrefs': function() { |
+ console.log('fetchPrefs'); |
+ }, |
+ 'observePrefs': function() { |
+ console.log('observePrefs'); |
+ }, |
+ 'setBooleanPref': function(inlist) { |
+ ++this.called['setBooleanPref']; |
+ console.log('setBooleanPref'); |
+ var true_list_value = ['browser.show_home_button', |
+ true, |
+ 'Options_Homepage_HomeButton']; |
+ assertEqualsArray(true_list_value, inlist); |
+ }, |
+ 'setIntegerPref': function() { |
+ console.log('setIntegerPref'); |
+ }, |
+ 'setDoublePref': function() { |
+ console.log('setDoublePref'); |
+ }, |
+ 'setStringPref': function() { |
+ console.log('setStringPref'); |
+ }, |
+ 'setObjectPref': function() { |
+ console.log('setObjectPref'); |
+ }, |
+ 'clearPref': function() { |
+ console.log('clearPref'); |
+ }, |
+ 'coreOptionsUserMetricsAction': function() { |
+ console.log('coreOptionsUserMetricsAction'); |
+ }, |
+ }; |
+ |
+ function registerCallbacks() { |
+ console.log('registeringCallbacks'); |
James Hawkins
2011/07/08 00:03:33
Remove logging.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
|
+ var mock_handler = new MockHandler(); |
+ for (func in MockHandler.prototype) { |
+ if (typeof(mock_handler[func]) == 'function') |
+ registerMessageCallback(func, |
+ mock_handler, |
+ mock_handler[func]); |
+ } |
+ }; |
+ |
+ 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
|
+ registerCallbacks(); |
+})(); |
+ |
+ |
+// Tests. |
James Hawkins
2011/07/08 00:03:33
Remove useless comment.
Sheridan Rawlins
2011/07/08 22:45:49
Done.
|
+function testSetBooleanPrefTriggers() { |
+ // TODO(dtseng): make generic to click all buttons. |
+ var showHomeButton = $('toolbarShowHomeButton'); |
+ assertTrue(showHomeButton != null); |
+ showHomeButton.click(); |
+ showHomeButton.blur(); |
+} |
+ |
+// Crashes on Mac only. See http://crbug.com/79181 |
+if (this['OS_MACOSX'] !== undefined) { |
+ this['DISABLED_testSetBooleanPrefTriggers'] = testSetBooleanPrefTriggers; |
+ delete testSetBooleanPrefTriggers; |
+} |
+ |
+function testPageIsUnderTheHood() { |
+ util.openUnderTheHood(); |
+ 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
|
+ var pageInstance = AdvancedOptions.getInstance(); |
+ var topPage = OptionsPage.getTopmostVisiblePage(); |
+ var expectedTitle = pageInstance.title; |
+ var actualTitle = document.title; |
+ assertEquals("chrome://settings/advanced", document.location.href); |
+ assertEquals(expectedTitle, actualTitle); |
+ assertEquals(pageInstance, topPage); |
+} |
+ |
+// Not meant to run on ChromeOS at this time. |
+// Not finishing in windows. http://crbug.com/81723 |
+if (this['OS_CHROMEOS'] !== undefined || |
+ this['OS_MACOSX'] !== undefined || |
+ this['OS_WIN'] !== undefined || |
+ this['TOUCH_UI'] !== undefined) { |
+ this['DISABLED_testPageIsUnderTheHood'] = testPageIsUnderTheHood; |
+ delete testPageIsUnderTheHood; |
+} |
+ |
+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
|
+var testBrowsePreload = 'chrome://settings'; |