summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/instant.html77
-rw-r--r--chrome/test/functional/PYAUTO_TESTS14
-rwxr-xr-xchrome/test/functional/instant.py101
3 files changed, 83 insertions, 109 deletions
diff --git a/chrome/test/data/instant.html b/chrome/test/data/instant.html
index 513a007..189d056 100644
--- a/chrome/test/data/instant.html
+++ b/chrome/test/data/instant.html
@@ -1,50 +1,45 @@
-<html>
-<body>
-<h1>Instant</h1>
-<script>
-window.chrome.sv = true;
-
-window.onsubmitcalls = 0;
-window.onchangecalls = 0;
-window.oncancelcalls = 0;
-window.onresizecalls = 0;
-
-Object.prototype.clone = function() {
- var copy = {};
- for (var prop in this) copy[prop] = this[prop];
- return copy;
+<html><body><h1>Instant</h1><script>
+
+var onchangecalls = 0;
+var onsubmitcalls = 0;
+var oncancelcalls = 0;
+var onresizecalls = 0;
+
+var value = "";
+var verbatim = false;
+var height = 0;
+
+var suggestion = [ { value: "query suggestion" } ];
+var behavior = "now";
+
+chrome.searchBox.onchange = function() {
+ onchangecalls++;
+ value = chrome.searchBox.value;
+ verbatim = chrome.searchBox.verbatim;
+ chrome.searchBox.setSuggestions({
+ suggestions: suggestion,
+ complete_behavior: behavior
+ });
};
-window.beforeLoadSearchBox = window.chrome.searchBox.clone();
-window.lastSearchBox = window.chrome.searchBox.clone();
-
-window.setSuggestionsArgument = {
- suggestions: [
- { value: "defghi" }
- ]
+chrome.searchBox.onsubmit = function() {
+ onsubmitcalls++;
+ value = chrome.searchBox.value;
+ verbatim = chrome.searchBox.verbatim;
};
-window.chrome.searchBox.onsubmit = function() {
- window.chrome.searchBox.setSuggestions(setSuggestionsArgument);
- window.lastSearchBox = window.chrome.searchBox.clone();
- window.onsubmitcalls++;
+chrome.searchBox.oncancel = function() {
+ oncancelcalls++;
+ value = chrome.searchBox.value;
+ verbatim = chrome.searchBox.verbatim;
};
-window.chrome.searchBox.onchange = function() {
- window.chrome.searchBox.setSuggestions(setSuggestionsArgument);
- window.lastSearchBox = window.chrome.searchBox.clone();
- window.onchangecalls++;
+chrome.searchBox.onresize = function() {
+ onresizecalls++;
+ height = chrome.searchBox.height;
};
-window.chrome.searchBox.oncancel = function() {
- window.chrome.searchBox.setSuggestions(setSuggestionsArgument);
- window.lastSearchBox = window.chrome.searchBox.clone();
- window.oncancelcalls++;
-};
+if (chrome.searchBox.value != "")
+ chrome.searchBox.onchange();
-window.chrome.searchBox.onresize = function() {
- window.onresizecalls++;
-};
-</script>
-</body>
-</html>
+</script></body></html>
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS
index a2fa0a5..46a0a73 100644
--- a/chrome/test/functional/PYAUTO_TESTS
+++ b/chrome/test/functional/PYAUTO_TESTS
@@ -150,12 +150,6 @@
'-infobars.OneClickInfobarTest.testNoSameIDSigninForTwoProfiles',
# crbug.com/124280
'-downloads.DownloadsTest.testPauseAndResume',
- # crbug.com/137042
- '-instant.InstantTest.testFindInCanDismissInstant',
- '-instant.InstantTest.testInstantLoadsFor100CharsLongQuery',
- '-instant.InstantTest.testInstantNavigation',
- '-instant.InstantTest.testNTPCanDismissInstant',
- '-instant.InstantTest.testNewWindowCanDismissInstant',
# Mysteriously broken?
# crbug.com/138857
@@ -285,8 +279,6 @@
# ==================================================
# Disabled tests that need to be investigated/fixed.
# ==================================================
- # crbug.com/85310
- '-instant',
# crbug.com/91033
'-omnibox.OmniboxTest.testOmniboxSearchHistory',
# crbug.com/103379
@@ -380,8 +372,6 @@
'-infobars.InfobarTest.testPluginCrashForMultiTabs',
# crbug.com/109035
'-infobars.InfobarTest.testPluginCrashInfobar',
- # Flaky: crosbug.com/14439
- '-instant',
# crosbug.com/14256
'-ntp.NTPTest.testLaunchAppFullScreen',
# Content history broken in omnibox. crosbug.com/14416
@@ -578,7 +568,6 @@
# Add back the omnibox tests excluded from the CONTINUOUS suite above
# because they do not produce omnibox results under virtual X on linux.
# crbug.com/85310
- 'instant',
'omnibox.OmniboxTest.testAppComboNameWithSpecialCharSearch',
'omnibox.OmniboxTest.testAppNameWithNumberSearch',
'omnibox.OmniboxTest.testAppNameWithSpaceSearch',
@@ -609,9 +598,6 @@
# crbug.com/109035
'-youtube.YoutubeTest.testPlayerBytes',
'-youtube.YoutubeTest.testPlayerResolution',
- # crbug.com/135211
- '-instant.InstantTest.testExtnPageCanDismissInstant',
- '-instant.InstantSettingsTest.testEnableDisableInstant',
],
'chromeos': [
diff --git a/chrome/test/functional/instant.py b/chrome/test/functional/instant.py
index 66817f5c..48829aa 100755
--- a/chrome/test/functional/instant.py
+++ b/chrome/test/functional/instant.py
@@ -9,7 +9,6 @@ import os
import pyauto_functional # Must be imported before pyauto
import pyauto
-
class InstantSettingsTest(pyauto.PyUITest):
"""Test Chrome Instant settings."""
@@ -18,19 +17,21 @@ class InstantSettingsTest(pyauto.PyUITest):
Check if the setting can be enabled and disabled."""
self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled),
msg='Instant is enabled by default.')
- # Enable instant.
- self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'instant');
+
+ # Enable Instant.
self.SetPrefs(pyauto.kInstantEnabled, True)
self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled),
msg='Instant is not enabled.')
+
+ # Make sure Instant works.
self.SetOmniboxText('google')
self.assertTrue(self.WaitUntil(
lambda: self.GetInstantInfo().get('current') and not
self.GetInstantInfo().get('loading')))
title = self.GetInstantInfo()['title']
self.assertEqual('Google', title, msg='Instant did not load.')
+
# Disable Instant.
- self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'disabled');
self.SetPrefs(pyauto.kInstantEnabled, False)
self.assertFalse(self.GetInstantInfo()['enabled'],
msg='Instant is not disabled.')
@@ -41,7 +42,6 @@ class InstantTest(pyauto.PyUITest):
def setUp(self):
pyauto.PyUITest.setUp(self)
- self.AppendSwitchASCIIToCommandLine('instant-field-trial', 'instant');
self.SetPrefs(pyauto.kInstantEnabled, True)
def _DoneLoading(self):
@@ -64,9 +64,9 @@ class InstantTest(pyauto.PyUITest):
return True
return False
- def testInstantNavigation(self):
- """Test that instant navigates based on omnibox input."""
- # Initiate instant search (at default google.com).
+ def testInstantLoadsSearchResults(self):
+ """Test that Instant loads search results based on omnibox input."""
+ # Initiate Instant search (at default google.com).
self.SetOmniboxText('chrome instant')
self.assertTrue(self.WaitUntil(self._DoneLoading))
location = self.GetInstantInfo()['location']
@@ -74,74 +74,74 @@ class InstantTest(pyauto.PyUITest):
msg='No google.com in %s' % location)
def testInstantCaseSensitivity(self):
- """Verify that Chrome Instant results case insensitive."""
+ """Verify that Chrome Instant results are case insensitive."""
# Text in lowercase letters.
self.SetOmniboxText('google')
self.assertTrue(self.WaitUntil(self._DoneLoading))
lowercase_instant_info = self.GetInstantInfo()
+
# Text in uppercase letters.
self.SetOmniboxText('GOOGLE')
self.assertTrue(self.WaitUntil(self._DoneLoading))
uppercase_instant_info = self.GetInstantInfo()
+
# Check lowercase and uppercase text results are same.
self.assertEquals(lowercase_instant_info, uppercase_instant_info,
- msg='Lowercase and Uppercase instant info doesn\'t match')
+ msg='Lowercase and uppercase Instant info do not match.')
+
# Text in mixed case letters.
self.SetOmniboxText('GooGle')
self.assertTrue(self.WaitUntil(self._DoneLoading))
mixedcase_instant_info = self.GetInstantInfo()
+
# Check mixedcase and uppercase text results are same.
self.assertEquals(mixedcase_instant_info, uppercase_instant_info,
- msg='Mixedcase and Uppercase instant info doesn\'t match')
+ msg='Mixedcase and uppercase Instant info do not match.')
- def testInstantWithSearchEngineOtherThanGoogle(self):
- """Verify that Instant is inactive for search engines other than Google."""
- # Check with Yahoo!.
+ def testInstantWithNonInstantSearchEngine(self):
+ """Verify that Instant is inactive for non-Instant search engines."""
+ # Check with Yahoo!, which doesn't support Instant yet.
self.MakeSearchEngineDefault('yahoo.com')
self.assertFalse(self.GetInstantInfo()['active'],
msg='Instant is active for Yahoo!')
- # Check with Bing.
+
+ # Check with Bing, which doesn't support Instant yet.
self.MakeSearchEngineDefault('bing.com')
self.assertFalse(self.GetInstantInfo()['active'],
msg='Instant is active for Bing.')
def testInstantDisabledInIncognito(self):
- """Test that instant is disabled in Incognito mode."""
+ """Test that Instant is disabled in incognito mode."""
self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
self.SetOmniboxText('google', windex=1)
self.assertFalse(self.GetInstantInfo()['active'],
- 'Instant enabled in Incognito mode.')
-
- def testInstantOverlayNotStoredInHistory(self):
- """Test that instant overlay page is not stored in history."""
- self.SetOmniboxText('google')
- self.assertTrue(self.WaitUntil(self._DoneLoading))
- history = self.GetHistoryInfo().History()
- self.assertEqual(0, len(history))
+ 'Instant enabled in incognito mode.')
def testInstantDisabledForURLs(self):
- """Test that instant is disabled for non-search URLs."""
+ """Test that Instant is disabled for non-search URLs."""
self.SetOmniboxText('http://www.google.com/')
self.WaitUntilOmniboxQueryDone()
self.assertFalse(self.GetInstantInfo()['current'],
'Instant enabled for non-search URLs.')
+
self.SetOmniboxText('google.es')
self.WaitUntilOmniboxQueryDone()
self.assertFalse(self.GetInstantInfo()['current'],
'Instant enabled for non-search URLs.')
+
self.SetOmniboxText(self.GetFileURLForDataPath('title2.html'))
self.WaitUntilOmniboxQueryDone()
self.assertFalse(self.GetInstantInfo()['current'],
'Instant enabled for non-search URLs.')
def testInstantDisabledForJavaScript(self):
- """Test that instant is disabled for javascript URLs."""
+ """Test that Instant is disabled for JavaScript URLs."""
self.SetOmniboxText('javascript:')
self.assertFalse(self.GetInstantInfo()['current'],
- 'Instant enabled for javascript URL.')
+ 'Instant enabled for JavaScript URL.')
def testInstantLoadsFor100CharsLongQuery(self):
- """Test that instant loads for search query of 100 characters."""
+ """Test that Instant loads for search query of 100 characters."""
query = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' \
'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv'
self.assertEqual(100, len(query))
@@ -149,49 +149,43 @@ class InstantTest(pyauto.PyUITest):
self.assertTrue(self.WaitUntil(self._DoneLoadingGoogleQuery, args=[query]))
def _BringUpInstant(self):
- """Helper function to bring up instant."""
+ """Helper function to bring up Instant."""
self.SetOmniboxText('google')
self.assertTrue(self.WaitUntil(self._DoneLoading))
self.assertTrue('www.google.com' in self.GetInstantInfo()['location'],
msg='No www.google.com in %s' %
self.GetInstantInfo()['location'])
+ def testInstantOverlayNotStoredInHistory(self):
+ """Test that Instant overlay page is not stored in history."""
+ self._BringUpInstant()
+ history = self.GetHistoryInfo().History()
+ self.assertEqual(0, len(history), msg='Instant URL stored in history.')
+
def testFindInCanDismissInstant(self):
- """Test that instant preview is dismissed by find-in-page."""
+ """Test that Instant preview is dismissed by find-in-page."""
self._BringUpInstant()
self.OpenFindInPage()
- self.assertEqual(self.GetActiveTabTitle(), 'New Tab')
+ self.assertFalse(self.GetInstantInfo()['current'],
+ 'Find-in-page does not dismiss Instant.')
def testNTPCanDismissInstant(self):
- """Test that instant preview is dismissed by adding new tab page."""
+ """Test that Instant preview is dismissed by adding new tab page."""
self.NavigateToURL('about:blank');
self._BringUpInstant()
self.AppendTab(pyauto.GURL('chrome://newtab'))
- self.CloseTab(tab_index=1)
- self.assertEqual(self.GetActiveTabTitle(), 'about:blank')
+ self.assertFalse(self.GetInstantInfo()['current'],
+ 'NTP does not dismiss Instant.')
def testExtnPageCanDismissInstant(self):
- """Test that instant preview is dismissed by extension page."""
+ """Test that Instant preview is dismissed by extension page."""
self._BringUpInstant()
self.AppendTab(pyauto.GURL('chrome://extensions'))
- self.CloseTab(tab_index=1)
- self.assertEqual(self.GetActiveTabTitle(), 'New Tab')
-
- def testNewWindowCanDismissInstant(self):
- """Test that instant preview is dismissed by New Window."""
- self._BringUpInstant()
- self.OpenNewBrowserWindow(True)
- self.CloseBrowserWindow(1)
- self.assertEqual(self.GetActiveTabTitle(), 'New Tab')
-
- def testPreFetchInstantURLNotInHistory(self):
- """Test that pre-fetched URLs are not saved in History."""
- self._BringUpInstant()
- history = self.GetHistoryInfo().History()
- self.assertFalse(history, msg='Pre-feteched URL saved in History')
+ self.assertFalse(self.GetInstantInfo()['current'],
+ 'Extension page does not dismiss Instant.')
def _AssertInstantDoesNotDownloadFile(self, path):
- """Asserts instant does not download the specified file.
+ """Asserts Instant does not download the specified file.
Args:
path: Path to file.
@@ -205,14 +199,13 @@ class InstantTest(pyauto.PyUITest):
msg='Should not download: %s' % filepath)
def testInstantDoesNotDownloadZipFile(self):
- """Test that instant does not download zip file."""
+ """Test that Instant does not download zip file."""
self._AssertInstantDoesNotDownloadFile(os.path.join('zip', 'test.zip'))
def testInstantDoesNotDownloadPDFFile(self):
- """Test that instant does not download PDF file."""
+ """Test that Instant does not download PDF file."""
self._AssertInstantDoesNotDownloadFile(os.path.join('printing',
'cloud_print_unittest.pdf'))
-
if __name__ == '__main__':
pyauto_functional.Main()