Esempio n. 1
0
 def testFetchHistoryResultItems(self):
     """Verify omnibox fetches history items in second tab, win and Incognito."""
     url = self.GetFileURLForDataPath('title2.html')
     title = 'Title Of Awesomeness'
     desc = 'Google Search'
     # fetch history page item in the second tab.
     self.AppendTab(pyauto.GURL(url))
     self._VerifyOmniboxURLMatches(url, title)
     # fetch history page items in the second window.
     self.OpenNewBrowserWindow(True)
     self.NavigateToURL(url, 1, 0)
     self._VerifyOmniboxURLMatches(url, title, windex=1)
     # fetch google search items in Incognito window.
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(url, 2, 0)
     self._VerifyOmniboxURLMatches(url, desc, windex=2)
  def testApprtcTabToTabCall(self):
    # Randomize the call session id. If we would use the same id we would risk
    # getting problems with hung calls and lingering state in AppRTC.
    random_call_id = 'pyauto%d' % random.randint(0, 65536)
    apprtc_url = 'http://apprtc.appspot.com/?r=%s' % random_call_id

    self.NavigateToURL(apprtc_url)
    self.AppendTab(pyauto.GURL(apprtc_url))

    self.WaitForInfobarCount(1, tab_index=0)
    self.WaitForInfobarCount(1, tab_index=1)

    self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=0)
    self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=1)

    self._WaitForCallEstablishment(tab_index=0)
    self._WaitForCallEstablishment(tab_index=1)
Esempio n. 3
0
 def testNeverSavePasswords(self):
     """Verify passwords not saved/deleted when 'never for this site' chosen."""
     creds1 = self.GetPrivateInfo()['test_google_account']
     test_utils.GoogleAccountsLogin(self, creds1['username'],
                                    creds1['password'])
     self.assertTrue(self.WaitForInfobarCount(1))
     self.PerformActionOnInfobar('accept', infobar_index=0)
     self.assertEquals(1, len(self.GetSavedPasswords()))
     self.AppendTab(pyauto.GURL(creds1['logout_url']))
     creds2 = self.GetPrivateInfo()['test_google_account_2']
     test_utils.GoogleAccountsLogin(self,
                                    creds2['username'],
                                    creds2['password'],
                                    tab_index=1)
     self.assertTrue(self.WaitForInfobarCount(1, tab_index=1))
     # Selecting 'Never for this site' option on password infobar.
     self.PerformActionOnInfobar('cancel', infobar_index=0, tab_index=1)
Esempio n. 4
0
 def testCloseOneWindow(self):
   """Tests that closing a window populates the recently closed list"""
   self.RemoveNTPDefaultThumbnails()
   self.OpenNewBrowserWindow(True)
   self.NavigateToURL(self.PAGES[0]['url'], 1, 0)
   self.AppendTab(pyauto.GURL(self.PAGES[1]['url']), 1)
   self.CloseBrowserWindow(1)
   expected = [{ u'type': u'window',
                 u'tabs': [
                 { u'type': u'tab',
                   u'url': self.PAGES[0]['url'],
                   u'direction': u'ltr' },
                 { u'type': u'tab',
                   u'url': self.PAGES[1]['url']}]
               }]
   self.assertEquals(expected, test_utils.StripUnmatchedKeys(
       self.GetNTPRecentlyClosed(), expected))
Esempio n. 5
0
 def testPreferencesBackupInvalidRestoreLastSession(self):
     """Test that session restore setting is not reset if backup is invalid."""
     # Set startup prefs to restore the last session.
     self.SetPrefs(pyauto.kRestoreOnStartup, self._SESSION_STARTUP_LAST)
     previous_urls = ['chrome://version/', 'http://news.google.com/']
     self.NavigateToURL(previous_urls[0])
     for url in previous_urls[1:]:
         self.AppendTab(pyauto.GURL(url))
     self.RestartBrowser(clear_profile=False,
                         pre_launch_hook=self._InvalidatePreferencesBackup)
     # The change must be detected by Protector.
     self.assertTrue(self.GetProtectorState()['showing_change'])
     # Startup settings are left unchanged.
     self.assertEqual(self._SESSION_STARTUP_LAST,
                      self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup))
     # Session has been restored.
     self._AssertTabsOpen(previous_urls)
Esempio n. 6
0
    def testHandlesNewGetUserMediaRequestSeparately(self):
        """Ensures WebRTC doesn't allow new requests to piggy-back on old ones."""
        url = self.GetFileURLForDataPath('webrtc', 'webrtc_test.html')
        self.NavigateToURL(url)
        self.AppendTab(pyauto.GURL(url))

        self._GetUserMedia(tab_index=0)
        self._GetUserMedia(tab_index=1)
        self._Connect("user_1", tab_index=0)
        self._Connect("user_2", tab_index=1)

        self._EstablishCall(from_tab_with_index=0)

        self.assertEquals('failed-with-error-1',
                          self._GetUserMedia(tab_index=0, action='deny'))
        self.assertEquals('failed-with-error-1',
                          self._GetUserMedia(tab_index=0, action='dismiss'))
Esempio n. 7
0
  def _SetupCall(self, test_page):
    url = self.GetFileURLForDataPath('webrtc', test_page)
    self.NavigateToURL(url)
    self.AppendTab(pyauto.GURL(url))

    self.assertEquals('ok-got-stream', self.GetUserMedia(tab_index=0))
    self.assertEquals('ok-got-stream', self.GetUserMedia(tab_index=1))
    self.Connect('user_1', tab_index=0)
    self.Connect('user_2', tab_index=1)

    self.EstablishCall(from_tab_with_index=0)

    self._StartDetectingVideo(tab_index=0, video_element='remote-view')
    self._StartDetectingVideo(tab_index=1, video_element='remote-view')

    self._WaitForVideo(tab_index=0, expect_playing=True)
    self._WaitForVideo(tab_index=1, expect_playing=True)
Esempio n. 8
0
    def testBlockCookies(self):
        """Verify that cookies are being blocked."""
        file_url = self.GetFileURLForDataPath('setcookie.html')
        http_url = 'http://%s' % self.test_host
        https_url = 'https://%s' % self.test_host
        self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
                         msg='There should be no cookie for file url %s' %
                         file_url)

        # Set the preference to block all cookies.
        self.SetPrefs(pyauto.kDefaultContentSettings, {u'cookies': 2})
        # Regular window
        self.NavigateToURL(http_url)
        self.AppendTab(pyauto.GURL(https_url))
        self.AppendTab(pyauto.GURL(file_url))
        self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
                         msg='Cookies are not blocked.')
        self.assertFalse(self.GetCookie(pyauto.GURL(http_url)),
                         msg='Cookies are not blocked.')
        self.assertFalse(self.GetCookie(pyauto.GURL(https_url)),
                         msg='Cookies are not blocked.')

        # Incognito window
        self._CookieCheckIncognitoWindow(http_url, cookies_enabled=False)

        # Restart and verify that cookie setting persists and there are no cookies.
        self.SetPrefs(pyauto.kRestoreOnStartup, 1)
        self.RestartBrowser(clear_profile=False)
        self.assertEquals(
            {u'cookies': 2},
            self.GetPrefsInfo().Prefs(pyauto.kDefaultContentSettings),
            msg='Cookie setting did not persist after restarting session.')
        self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
                         msg='Cookies are not blocked.')
        self.assertFalse(self.GetCookie(pyauto.GURL(http_url)),
                         msg='Cookies are not blocked.')
        self.assertFalse(self.GetCookie(pyauto.GURL(https_url)),
                         msg='Cookies are not blocked.')
Esempio n. 9
0
 def testV8BenchmarkSuite(self):
     """Measures score from online v8 benchmark suite."""
     url = self.GetFileURLForDataPath('v8_benchmark_v6', 'run.html')
     self.assertTrue(self.AppendTab(pyauto.GURL(url)),
                     msg='Failed to append tab for v8 benchmark suite.')
     js = """
     var val = document.getElementById("status").innerHTML;
     window.domAutomationController.send(val);
 """
     self.assertTrue(self.WaitUntil(
         lambda: 'Score:' in self.ExecuteJavascript(js, tab_index=1),
         timeout=300,
         expect_retval=True,
         retry_sleep=0.10),
                     msg='Timed out when waiting for v8 benchmark score.')
     val = self.ExecuteJavascript(js, tab_index=1)
     score = int(val.split(':')[1].strip())
     self._PrintSummaryResults('V8Benchmark', [score], 'score')
 def testSessionRestore(self):
     """Test session restore preference."""
     url1 = 'http://www.google.com/'
     url2 = 'http://news.google.com/'
     self.NavigateToURL(url1)
     self.AppendTab(pyauto.GURL(url2))
     num_tabs = self.GetTabCount()
     # Set pref to restore session on startup.
     self.SetPrefs(pyauto.kRestoreOnStartup, 1)
     logging.debug('Setting %s to 1' % pyauto.kRestoreOnStartup)
     self.RestartBrowser(clear_profile=False)
     self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup),
                      1)
     self.assertEqual(num_tabs, self.GetTabCount())
     self.ActivateTab(0)
     self.assertEqual(url1, self.GetActiveTabURL().spec())
     self.ActivateTab(1)
     self.assertEqual(url2, self.GetActiveTabURL().spec())
Esempio n. 11
0
 def testSingleGpuProcess(self):
     """Verify there's only one gpu process shared across all uses."""
     self.assertTrue(self._IsHardwareAccelerated('WebGL'))
     url = self.GetFileURLForDataPath('pyauto_private', 'gpu',
                                      'WebGLField.html')
     self.AppendTab(pyauto.GURL(url))
     # Open a new window.
     self.OpenNewBrowserWindow(True)
     self.NavigateToURL(url, 1, 0)
     # Open a new incognito window.
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(url, 1, 0)
     # Verify there's only 1 gpu process.
     gpu_process_count = 0
     for x in self.GetBrowserInfo()['child_processes']:
         if x['type'] == 'GPU':
             gpu_process_count += 1
     self.assertEqual(1, gpu_process_count)
Esempio n. 12
0
 def testUseCurrentPagesForStartup(self):
     """Verify user can start up browser using current pages."""
     page = settings.BasicSettingsPage.FromNavigation(self._driver)
     self.OpenNewBrowserWindow(True)
     url1 = self.GetHttpURLForDataPath('title2.html')
     url2 = self.GetHttpURLForDataPath('title3.html')
     self.NavigateToURL(url1, 1, 0)
     self.AppendTab(pyauto.GURL(url2), 1)
     title_list = ['Title Of Awesomeness', 'Title Of More Awesomeness']
     page.UseCurrentPageForStartup()
     page.VerifyStartupURLs(title_list)
     self.assertEqual(RestoreOnStartupType.RESTORE_URLS,
                      self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup))
     startup_urls = self.GetPrefsInfo().Prefs(
         pyauto.kURLsToRestoreOnStartup)
     self.assertEqual(len(startup_urls), 3)
     self.assertEqual(startup_urls[1], url1)
     self.assertEqual(startup_urls[2], url2)
Esempio n. 13
0
    def _OpenExamplesAndStartTest(self, examples):
        """Open each example and verify that it's working.

    Args:
      examples: A dict of name to url of examples.
    """
        self._EnableNaClPlugin()

        # Open all examples.
        for name, url in examples.items():
            self.AppendTab(pyauto.GURL(url))
            self._CheckForCrashes()

        # Verify all examples are working.
        for name, url in examples.items():
            self._VerifyAnExample(name, url)
        self._CheckForCrashes()

        # Reload all examples.
        for _ in range(2):
            for tab_index in range(self.GetTabCount()):
                self.GetBrowserWindow(0).GetTab(tab_index).Reload()
        self._CheckForCrashes()

        # Verify all examples are working.
        for name, url in examples.items():
            self._VerifyAnExample(name, url)
        self._CheckForCrashes()

        # Close each tab, check for crashes and verify all open
        # examples operate correctly.
        tab_count = self.GetTabCount()
        for index in xrange(tab_count - 1, 0, -1):
            self.GetBrowserWindow(0).GetTab(index).Close(True)
            self._CheckForCrashes()

            tabs = self.GetBrowserInfo()['windows'][0]['tabs']
            for tab in tabs:
                if tab['index'] > 0:
                    for name, url in examples.items():
                        if url == tab['url']:
                            self._VerifyAnExample(name, url)
                            break
Esempio n. 14
0
 def testGeolocationInfobarInMultipleTabsAndWindows(self):
     """Verify GeoLocation inforbar in multiple tabs."""
     url = self.GetFileURLForDataPath(  # triggers geolocation
         'geolocation', 'geolocation_on_load.html')
     for tab_index in range(1, 2):
         self.AppendTab(pyauto.GURL(url))
         self.assertTrue(
             self.WaitForInfobarCount(1, windex=0, tab_index=tab_index))
         self._VerifyGeolocationInfobar(windex=0, tab_index=tab_index)
     # Try in a new window
     self.OpenNewBrowserWindow(True)
     self.NavigateToURL(url, 1, 0)
     self.assertTrue(self.WaitForInfobarCount(1, windex=1, tab_index=0))
     self._VerifyGeolocationInfobar(windex=1, tab_index=0)
     # Incognito window
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(url, 2, 0)
     self.assertTrue(self.WaitForInfobarCount(1, windex=2, tab_index=0))
     self._VerifyGeolocationInfobar(windex=2, tab_index=0)
Esempio n. 15
0
  def testAllowPluginException(self):
    """Verify that plugins can be allowed on a domain by adding
    an exception(s)."""
    # Set the preference to block all plugins.
    self.SetPrefs(pyauto.kDefaultContentSettings, {'plugins': 2})

    flash_url = self.GetFileURLForPath(os.path.join(
        self.DataDir(), 'plugin', 'flash-clicktoplay.html'))
    self.NavigateToURL(flash_url)
    # Check that plugins are blocked.
    self.assertFalse(self._GetPluginPID('Shockwave Flash'),
                     msg='Plug-in not blocked.')

    # Add an exception to allow plugins on hulu.com.
    self.SetPrefs(pyauto.kContentSettingsPatternPairs,
                 {'[*.]hulu.com,*': {'plugins': 1}})
    self.AppendTab(pyauto.GURL('http://www.hulu.com'))
    self.assertTrue(self._GetPluginPID('Shockwave Flash'),
                    msg='No plugin process for Shockwave Flash')
Esempio n. 16
0
    def testMediaPerformance(self):
        """Launches HTML test which plays each video and records statistics."""
        for file_name in _TEST_VIDEOS:
            # Append a tab and delete it at the end of the test to free its memory.
            self.AppendTab(
                pyauto.GURL(self.GetFileURLForDataPath(_TEST_HTML_PATH)))

            file_url = self.GetFileURLForDataPath(
                os.path.join(_TEST_MEDIA_PATH, file_name))
            logging.debug('Running perf test for %s.', file_url)

            renderer_process = self._GetChromeRendererProcess()
            # Call to set a starting time to record CPU usage by the renderer.
            renderer_process.get_cpu_percent()

            self.assertTrue(
                self.CallJavascriptFunc('startTest', [file_url], tab_index=1))

            cpu_usage = renderer_process.get_cpu_percent()
            mem_usage_mb = renderer_process.get_memory_info()[0] / 1024
            pyauto_utils.PrintPerfResult('cpu', file_name, cpu_usage, '%')
            pyauto_utils.PrintPerfResult('memory', file_name, mem_usage_mb,
                                         'KB')

            decoded_fps = [
                float(value)
                for value in self.GetDOMValue("decodedFPS.join(',')",
                                              tab_index=1).split(',')
            ]
            dropped_frames = self.GetDOMValue('droppedFrames', tab_index=1)
            dropped_fps = [
                float(value)
                for value in self.GetDOMValue("droppedFPS.join(',')",
                                              tab_index=1).split(',')
            ]

            pyauto_utils.PrintPerfResult('fps', file_name, decoded_fps, 'fps')
            pyauto_utils.PrintPerfResult('dropped_fps', file_name, dropped_fps,
                                         'fps')
            pyauto_utils.PrintPerfResult('dropped_frames', file_name,
                                         dropped_frames, 'frames')

            self.GetBrowserWindow(0).GetTab(1).Close(True)
Esempio n. 17
0
    def _SimpleWebRtcCall(self, test_page):
        """Tests we can call and hang up with WebRTC using ROAP/JSEP.

    This test exercises pretty much the whole happy-case for the WebRTC
    JavaScript API. Currently, it exercises a normal call setup using the API
    defined at http://dev.w3.org/2011/webrtc/editor/webrtc.html. The API is
    still evolving.

    The test will load the supplied HTML file, which in turn will load different
    javascript files depending on if we are running ROAP or JSEP.
    The supplied HTML file will be loaded in two tabs and tell the web
    pages to start up WebRTC, which will acquire video and audio devices on the
    system. This will launch a dialog in Chrome which we click past using the
    automation controller. Then, we will order both tabs to connect the server,
    which will make the two tabs aware of each other. Once that is done we order
    one tab to call the other. We make sure that the javascript tells us that
    the call succeeded, let it run for a while and try to hang up the call
    after that.
    """
        url = self.GetFileURLForDataPath('webrtc', test_page)
        self.NavigateToURL(url)
        self.AppendTab(pyauto.GURL(url))

        self.assertEquals('ok-got-stream', self._GetUserMedia(tab_index=0))
        self.assertEquals('ok-got-stream', self._GetUserMedia(tab_index=1))
        self._Connect('user_1', tab_index=0)
        self._Connect('user_2', tab_index=1)

        self._EstablishCall(from_tab_with_index=0)

        # Give the call some time to run so video flows through the system.
        time.sleep(5)

        # The hang-up will automatically propagate to the second tab.
        self._HangUp(from_tab_with_index=0)
        self._VerifyHungUp(tab_index=1)

        self._Disconnect(tab_index=0)
        self._Disconnect(tab_index=1)

        # Ensure we didn't miss any errors.
        self._AssertNoFailuresReceivedInTwoTabs()
Esempio n. 18
0
    def testPersonalStuffSyncSection(self):
        """Verify the Sync section in Preferences before and after sync."""
        creds = self.GetPrivateInfo()['test_google_account']
        username = creds['username']
        password = creds['password']
        default_text = 'Keep everything synced or choose what data to sync'
        set_up_button = 'Set Up Sync'
        customize_button = 'Customize'
        stop_button = 'Stop Sync'
        signed_in_text = 'Google Dashboard'
        chrome_personal_stuff_url = 'chrome://settings/personal'
        new_timeout = pyauto.PyUITest.ActionTimeoutChanger(
            self, 2 * 60 * 1000)  # 2 min.
        self.AppendTab(pyauto.GURL(chrome_personal_stuff_url))
        self.assertTrue(
            self.WaitUntil(lambda: self.FindInPage(default_text, tab_index=1)[
                'match_count'],
                           expect_retval=1), 'No default sync text.')
        self.assertTrue(
            self.WaitUntil(lambda: self.FindInPage(set_up_button, tab_index=1)[
                'match_count'],
                           expect_retval=1), 'No set up sync button.')

        self.assertTrue(self.SignInToSync(username, password))
        self.GetBrowserWindow(0).GetTab(1).Reload()
        self.assertTrue(
            self.WaitUntil(
                lambda: self.FindInPage(username, tab_index=1)['match_count'],
                expect_retval=1), 'No sync user account information.')
        self.assertTrue(
            self.WaitUntil(lambda: self.FindInPage(signed_in_text, tab_index=1)
                           ['match_count'],
                           expect_retval=1),
            'No Google Dashboard information after signing in.')
        self.assertTrue(
            self.WaitUntil(lambda: self.FindInPage(stop_button, tab_index=1)[
                'match_count'],
                           expect_retval=1), 'No stop sync button.')
        self.assertTrue(
            self.WaitUntil(lambda: self.FindInPage(customize_button,
                                                   tab_index=1)['match_count'],
                           expect_retval=1), 'No customize sync button.')
Esempio n. 19
0
  def testApprtcTabToTabCall(self):
    # Randomize the call session id. If we would use the same id we would risk
    # getting problems with hung calls and lingering state in AppRTC.
    random_call_id = 'pyauto%d' % random.randint(0, 65536)
    apprtc_url = 'http://apprtc.appspot.com/?r=%s' % random_call_id

    self.NavigateToURL(apprtc_url)
    self.AppendTab(pyauto.GURL(apprtc_url))

    self.WaitForInfobarCount(1, tab_index=0)
    self.WaitForInfobarCount(1, tab_index=1)

    self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=0)
    # TODO(phoglund): workaround for
    # https://code.google.com/p/webrtc/issues/detail?id=1742
    time.sleep(1)
    self.PerformActionOnInfobar('accept', infobar_index=0, tab_index=1)

    self._WaitForCallEstablishment(tab_index=0)
    self._WaitForCallEstablishment(tab_index=1)
Esempio n. 20
0
 def testBookmarkResultInNewTabAndWindow(self):
     """Verify omnibox finds bookmarks in search options of new tabs/windows."""
     url = self.GetFileURLForDataPath('title2.html')
     self.NavigateToURL(url)
     title = 'This is Awesomeness'
     bookmarks = self.GetBookmarkModel()
     bar_id = bookmarks.BookmarkBar()['id']
     self.AddBookmarkURL(bar_id, 0, title, url)
     bookmarks = self.GetBookmarkModel()
     nodes = bookmarks.FindByTitle(title)
     self.AppendTab(pyauto.GURL(url))
     self._CheckBookmarkResultForVariousInputs(url, title)
     self.OpenNewBrowserWindow(True)
     self.assertEqual(2, self.GetBrowserWindowCount())
     self.NavigateToURL(url, 1, 0)
     self._CheckBookmarkResultForVariousInputs(url, title, windex=1)
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.assertEqual(3, self.GetBrowserWindowCount())
     self.NavigateToURL(url, 2, 0)
     self._CheckBookmarkResultForVariousInputs(url, title, windex=2)
Esempio n. 21
0
 def testPDFRunner(self):
   """Navigate to pdf files and verify that browser doesn't crash"""
   # bail out if not a branded build
   properties = self.GetBrowserInfo()['properties']
   if properties['branding'] != 'Google Chrome':
     return
   pdf_files_path = os.path.join(self.DataDir(), 'pyauto_private', 'pdf')
   pdf_files = glob.glob(os.path.join(pdf_files_path, '*.pdf'))
   for pdf_file in pdf_files:
     # Some pdfs cause known crashes. Exclude them. crbug.com/63549
     if os.path.basename(pdf_file) in ('nullip.pdf', 'sample.pdf'):
       continue
     url = self.GetFileURLForPath(pdf_file)
     self.AppendTab(pyauto.GURL(url))
   for tab_index in range(1, len(pdf_files) + 1):
     self.ActivateTab(tab_index)
     self._PerformPDFAction('fitToHeight', tab_index=tab_index)
     self._PerformPDFAction('fitToWidth', tab_index=tab_index)
   # Assert that there is at least 1 browser window.
   self.assertTrue(self.GetBrowserWindowCount(),
                   'Browser crashed, no window is open')
Esempio n. 22
0
  def testConnectionsClosedOnTabClose(self):
    """Verify that open DB connections are closed when a tab is destroyed."""

    url = self.GetHttpURLForDataPath('indexeddb', 'version_change_blocked.html')

    self.NavigateToURL(url + '#tab1')
    pid = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
    self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
                                   expect_retval='setVersion(1) complete'),
                    msg='Version change failed')

    # Start to a different URL to force a new renderer process
    self.AppendTab(pyauto.GURL('about:blank'))
    self.NavigateToURL(url + '#tab2')
    self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
                                   expect_retval='setVersion(2) blocked'),
                    msg='Version change not blocked as expected')
    self.KillRendererProcess(pid)
    self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
                                    expect_retval='setVersion(2) complete'),
                     msg='Version change never unblocked')
Esempio n. 23
0
    def testScimarkGui(self):
        """Runs the ScimarkGui benchmark tests."""
        webpage_url = self.GetHttpURLForDataPath('pyauto_private', 'flash',
                                                 'scimarkGui.html')
        self.assertTrue(self.AppendTab(pyauto.GURL(webpage_url)),
                        msg='Failed to append tab for webpage.')

        js = 'window.domAutomationController.send("" + tests_done);'
        self.assertTrue(self.WaitUntil(
            lambda: self.ExecuteJavascript(js, tab_index=1),
            timeout=300,
            expect_retval='true',
            retry_sleep=0.25),
                        msg='Timed out when waiting for tests to complete.')

        js_result = """
        var json_result = "{";
        for (var i = 0; i < tests_results.length; ++i) {
          var test_name = tests_results[i][0];
          var mflops = tests_results[i][1];
          var mem = tests_results[i][2];
          json_result += "'" + test_name + "':" + "[" + mflops + "," +
                         mem + "],";
        }
        json_result += "}";
        window.domAutomationController.send(json_result);
    """
        result = eval(self.ExecuteJavascript(js_result, tab_index=1))
        for benchmark in result:
            mflops = result[benchmark][0]
            mem = result[benchmark][1]
            if benchmark.endswith('_mflops'):
                benchmark = benchmark[:benchmark.find('_mflops')]
            logging.info('Results for ScimarkGui_' + benchmark + ':')
            logging.info('  %.2f MFLOPS' % mflops)
            logging.info('  %.2f MB' % mem)
            self._OutputPerfGraphValue(
                '%s_ScimarkGui-%s-MFLOPS' % ('MFLOPS', benchmark), mflops)
            self._OutputPerfGraphValue(
                '%s_ScimarkGui-%s-Mem' % ('MB', benchmark), mem)
Esempio n. 24
0
 def testSavedPasswordInTabsAndWindows(self):
     """Verify saved username/password displays in Regular/Incognito Window
    and NTP"""
     username = '******'
     password = '******'
     password_dict = {
         u'action_target':
         u'https://www.google.com/accounts/ServiceLoginAuth',
         u'blacklist': False,
         u'origin_url': u'https://www.google.com/accounts/ServiceLogin',
         u'password_element': u'Passwd',
         u'password_value': u'test12345',
         u'signon_realm': u'https://www.google.com/',
         u'submit_element': u'',
         u'time': 1280939865.0,
         u'username_element': u'Email',
         u'username_value': u'test'
     }
     url = 'https://www.google.com/accounts/ServiceLogin'
     self.AddSavedPassword(password_dict)
     self.NavigateToURL(url)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=0)
     self.AppendTab(pyauto.GURL(url))
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=1,
                                               windex=0)
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(url, 1, 0)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=1)
     test_utils.ClearPasswords(self)
Esempio n. 25
0
    def testTriggerPageAction(self):
        """Test triggering page action."""
        dir_path = os.path.abspath(
            os.path.join(self.DataDir(), 'extensions', 'trigger_actions',
                         'page_action'))
        ext_id = self.InstallExtension(dir_path)

        # Page action icon is displayed when a tab is created.
        self.NavigateToURL(self.GetFileURLForDataPath('simple.html'))
        self.AppendTab(pyauto.GURL('chrome://newtab'))
        self.ActivateTab(0)
        self.assertTrue(self.WaitUntil(lambda: ext_id in self.GetBrowserInfo()[
            'windows'][0]['visible_page_actions']),
                        msg='Page action icon is not visible.')

        self.TriggerPageActionById(ext_id)

        # Verify that page action turned the background red.
        self.assertTrue(self.WaitUntil(
            lambda: self.GetDOMValue('document.body.style.backgroundColor'),
            expect_retval='red'),
                        msg='Page action was not triggered.')
Esempio n. 26
0
 def testSessionRestore(self):
     """Test that session restore restores the translate infobar and other
    translate settings.
 """
     # Due to crbug.com/51439, we must open two tabs here.
     self.NavigateToURL("http://www.news.google.com")
     self.AppendTab(pyauto.GURL("http://www.google.com/webhp?hl=es"))
     self.assertTrue(self.WaitForInfobarCount(1, tab_index=1))
     translate_info = self.GetTranslateInfo(tab_index=1)
     self.assertTrue('translate_bar' in translate_info)
     self.SelectTranslateOption('toggle_always_translate', tab_index=1)
     self._ClickTranslateUntilSuccess(tab_index=1)
     self.SetPrefs(pyauto.kRestoreOnStartup, 1)
     self.RestartBrowser(clear_profile=False)
     self.assertTrue(self.WaitForInfobarCount(1, tab_index=1))
     self.WaitUntilTranslateComplete(tab_index=1)
     translate_info = self.GetTranslateInfo(tab_index=1)
     self.assertTrue('translate_bar' in translate_info)
     # Sometimes translation fails. We don't really care whether it succeededs,
     # just that a translation was attempted.
     self.assertNotEqual(self.before_translate,
                         translate_info['translate_bar']['bar_state'])
Esempio n. 27
0
 def testSavedPasswordInTabsAndWindows(self):
     """Verify saved username/password shows in regular/incognito Window, NTP"""
     url = 'https://www.google.com/accounts/ServiceLogin'
     url_logout = 'https://www.google.com/accounts/Logout'
     creds = self.GetPrivateInfo()['test_google_account']
     username = creds['username']
     password = creds['password']
     # Login to Google a/c
     test_utils.GoogleAccountsLogin(self, username, password)
     # Wait for the infobar to appear
     self.assertTrue(self.WaitForInfobarCount(1))
     self.assertTrue(
         self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
     self.PerformActionOnInfobar('accept', infobar_index=0)
     self.NavigateToURL(url_logout)
     self.NavigateToURL(url)
     self._ClickOnLoginPage(0, 0)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=0)
     self.AppendTab(pyauto.GURL(url))
     self._ClickOnLoginPage(0, 1)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=1,
                                               windex=0)
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(url, 1, 0)
     self._ClickOnLoginPage(1, 0)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=1)
     test_utils.ClearPasswords(self)
Esempio n. 28
0
 def testNeverSavePasswords(self):
     """Verify passwords not saved/deleted when 'never for this site' chosen."""
     creds1 = self.GetPrivateInfo()['test_google_account']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     test_utils.GoogleAccountsLogin(self, creds1['username'],
                                    creds1['password'])
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.assertEquals(1, len(self.GetSavedPasswords()))
     self.AppendTab(pyauto.GURL(creds1['logout_url']))
     creds2 = self.GetPrivateInfo()['test_google_account_2']
     test_utils.GoogleAccountsLogin(self,
                                    creds2['username'],
                                    creds2['password'],
                                    tab_index=1)
     # Selecting 'Never for this site' option on password infobar.
     self.PerformActionOnInfobar(
         'cancel',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE, tab_index=1))
Esempio n. 29
0
  def _OpenExamplesAndStartTest(self, examples):
    """Open each example and verify that it's working.

    Args:
      examples: A list of example (name, url) tuples.
    """
    example_verify_funcs = {
        'dlopen': self._VerifyDynamicLibraryOpen,
        'file_io': self._VerifyFileIoExample,
        'geturl': self._VerifyGetURLExample,
        'input_events': self._VerifyInputEventsExample,
        'load_progress': self._VerifyLoadProgressExample,
        'mt_input_events': self._VerifyMultithreadedInputEventsExample,
        'pi_generator': self._VerifyPiGeneratorExample,
        'sine_synth': self._VerifySineSynthExample,
        'websocket': self._VerifyWebSocketExample,
    }

    # Remove examples that we don't yet verify
    examples = [(name, url) for name, url in examples
        if name in example_verify_funcs]

    # Open all examples.
    for name, url in examples:
      self.AppendTab(pyauto.GURL(url))
      self._CheckForCrashes()

    # Verify all examples are working.
    for name, url in examples:
      self._VerifyAnExample(name, url, example_verify_funcs[name])
    self._CheckForCrashes()

    # Close each tab and check for crashes.
    tab_count = self.GetTabCount()
    for index in xrange(tab_count - 1, 0, -1):
      self.GetBrowserWindow(0).GetTab(index).Close(True)
      self._CheckForCrashes()
Esempio n. 30
0
  def testPDFRunner(self):
    """Navigate to pdf files and verify that browser doesn't crash"""
    # bail out if not a branded build
    properties = self.GetBrowserInfo()['properties']
    if properties['branding'] != 'Google Chrome':
      return
    breakpad_folder = properties['DIR_CRASH_DUMPS']
    old_dmp_files = glob.glob(os.path.join(breakpad_folder, '*.dmp'))
    pdf_files_path = os.path.join(self.DataDir(), 'pyauto_private', 'pdf')
    pdf_files = map(self.GetFileURLForPath,
                    glob.glob(os.path.join(pdf_files_path, '*.pdf')))
    # Add a pdf file over http:// to the list of pdf files.
    # crbug.com/70454
    pdf_files += ['http://www.irs.gov/pub/irs-pdf/fw4.pdf']

    # Some pdfs cause known crashes. Exclude them. crbug.com/63549
    exclude_list = ('nullip.pdf', 'sample.pdf')
    pdf_files = [x for x in pdf_files if
                 os.path.basename(x) not in exclude_list]

    PDFTest.unloadable_pdfs = []
    for url in pdf_files:
      self.AppendTab(pyauto.GURL(url))
    for tab_index in range(1, len(pdf_files) + 1):
      self.ActivateTab(tab_index)
      self._PerformPDFAction('fitToHeight', tab_index=tab_index)
      self._PerformPDFAction('fitToWidth', tab_index=tab_index)
    # Assert that there is at least 1 browser window.
    self.assertTrue(self.GetBrowserWindowCount(),
                    'Browser crashed, no window is open')
    # Verify there're no crash dump files
    for dmp_file in glob.glob(os.path.join(breakpad_folder, '*.dmp')):
      self.assertTrue(dmp_file in old_dmp_files,
          msg='Crash dump %s found' % dmp_file)
    self.assertEqual(len(PDFTest.unloadable_pdfs), 0, msg='The following PDFs '
                     'did not load: %s' % PDFTest.unloadable_pdfs)