Пример #1
0
 def testDisplayAndSavePasswordInfobar(self):
     """Verify password infobar displays and able to save password."""
     test_utils.ClearPasswords(self)
     creds = self.GetPrivateInfo()['test_google_account']
     username = creds['username']
     password = creds['password']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     test_utils.GoogleAccountsLogin(self, username, password)
     # Wait until page completes loading.
     self.WaitUntil(lambda: self.GetDOMValue('document.readyState'),
                    expect_retval='complete')
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.NavigateToURL(self.URL_LOGOUT)
     self.NavigateToURL(self.URL_HTTPS)
     self._ClickOnLoginPage(0, 0)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=0)
     test_utils.ClearPasswords(self)
Пример #2
0
 def testSavedPasswordInTabsAndWindows(self):
     """Verify saved username/password shows in window and tab."""
     creds = self.GetPrivateInfo()['test_google_account']
     username = creds['username']
     password = creds['password']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     # Login to Google a/c
     test_utils.GoogleAccountsLogin(self, username, password)
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.NavigateToURL(self.URL_LOGOUT)
     self.NavigateToURL(self.URL)
     self._ClickOnLoginPage(0, 0)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=0,
                                               windex=0)
     self.AppendTab(pyauto.GURL(self.URL))
     self._ClickOnLoginPage(0, 1)
     test_utils.VerifyGoogleAccountCredsFilled(self,
                                               username,
                                               password,
                                               tab_index=1,
                                               windex=0)
Пример #3
0
    def testOneClickInfobarShownWhenWinLoseFocus(self):
        """Verify one-click infobar still shows when window loses focus.

    This test verifies the following bug: crbug.com/121739
    """
        self._LogIntoGoogleAccount()
        test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
        # Open new window to shift focus away.
        self.OpenNewBrowserWindow(True)
        test_utils.GetInfobarIndexByType(self, self.OC_INFOBAR_TYPE)
Пример #4
0
 def testProtocolHandlerRegisteredCorrectly(self):
     """Verify sites that ask to be default handlers registers correctly."""
     url = self.GetHttpURLForDataPath('settings', 'protocol_handler.html')
     self.NavigateToURL(url)
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     driver = self.NewWebDriver()
     driver.find_element_by_id('test_protocol').click()
     self.assertTrue(
         driver.execute_script('return verifyQueryConformsToProtocol();'),
         msg='Protocol did not register correctly.')
Пример #5
0
 def testInfoBarDisappearByReload(self):
     """Test that Password infobar disappears by the page reload."""
     creds = self.GetPrivateInfo()['test_google_account']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     # Login to Google a/c
     test_utils.GoogleAccountsLogin(self, creds['username'],
                                    creds['password'])
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.ReloadTab()
     test_utils.AssertInfobarTypeDoesNotAppear(self, self.INFOBAR_TYPE)
Пример #6
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))
Пример #7
0
    def testDisplayOneClickInfobarAfterDismiss(self):
        """Verify one-click infobar appears again after clicking dismiss button.

    The one-click infobar should display again after logging into an
    account and clicking to dismiss the infobar the first time.

    This test also verifies that the password infobar does not display.
    The one-click infobar should supersede the password infobar.
    """
        self._DisplayOneClickInfobar()
        self._PerformActionOnInfobar(action='dismiss')  # Click 'x' button.
        self.NavigateToURL(self.URL_LOGOUT)
        self._LogIntoGoogleAccount()
        test_utils.WaitForInfobarTypeAndGetIndex(self, self.OC_INFOBAR_TYPE)
        test_utils.AssertInfobarTypeDoesNotAppear(self, self.PW_INFOBAR_TYPE)
Пример #8
0
    def _PerformActionOnInfobar(self, action):
        """Perform an action on the infobar: accept, cancel, or dismiss.

    The one-click sign in infobar must show in the first tab of the first
    window. If action is 'accept' then the account is synced. If the action is
    'cancel' then the infobar should be dismissed and never shown again. The
    account will not be synced. If the action is 'dismiss' then the infobar will
    shown again after the next login.

    Args:
      action: The action to perform on the infobar.
    """
        infobar_index = test_utils.WaitForInfobarTypeAndGetIndex(
            self, self.OC_INFOBAR_TYPE)
        self.PerformActionOnInfobar(action, infobar_index)
Пример #9
0
    def testRemoveMailProtocolHandler(self):
        """Verify the mail protocol handler is added and removed successfully."""
        url = self.GetHttpURLForDataPath('settings', 'protocol_handler.html')
        self.NavigateToURL(url)
        # Returns a dictionary with the mail handler that was asked for
        # registration.
        asked_handler_dict = self._driver.execute_script(
            'return registerMailClient()')
        self.PerformActionOnInfobar(
            'accept',
            infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
                self, self.INFOBAR_TYPE))
        self._driver.find_element_by_id('test_mail_protocol').click()

        protocol_handlers_list = (self.GetPrefsInfo().Prefs(
            pyauto.kRegisteredProtocolHandlers))
        registered_mail_handler = {}
        for handler_dict in protocol_handlers_list:
            if (handler_dict['protocol'] == 'mailto'
                    and handler_dict['url'] == asked_handler_dict['url']
                    and handler_dict['title'] == asked_handler_dict['title']
                    and handler_dict.get('default')):
                registered_mail_handler = handler_dict
                break
            # Verify the mail handler is registered as asked.
            self.assertNotEqual(
                registered_mail_handler, {},
                msg='Mail protocol handler was not registered correctly.')
            # Verify the registered mail handler works as expected.
            self.assertTrue(self._driver.execute_script(
                'return doesQueryConformsToProtocol("%s", "%s")' %
                (asked_handler_dict['query_key'],
                 asked_handler_dict['query_value'])),
                            msg='Mail protocol did not register correctly.')

        self._driver.get('chrome://settings-frame/handlers')
        # There are 3 DIVs in a handler entry. The last one acts as a remove button.
        # The remove button is also equivalent to setting the site to NONE.
        self._driver.find_element_by_id('handlers-list').\
            find_element_by_xpath('.//div[@role="listitem"]').\
            find_element_by_xpath('.//div[@class="handlers-site-column"]').\
            find_element_by_xpath('.//option[@value="-1"]').click()

        self._driver.get(url)
        self._driver.find_element_by_id('test_mail_protocol').click()
        self.assertEqual(url,
                         self._driver.current_url,
                         msg='Mail protocol still registered.')
Пример #10
0
    def testPasswordInfobarShowsForBlockedDomain(self):
        """Verify that password infobar shows when cookies are blocked.

    Password infobar should be shown if cookies are blocked for Google
    accounts domain.
    """
        creds = self.GetPrivateInfo()['test_google_account']
        username = creds['username']
        password = creds['password']
        # Block cookies for Google accounts domain.
        self.SetPrefs(pyauto.kContentSettingsPatternPairs,
                      {'https://accounts.google.com/': {
                          'cookies': 2
                      }})
        test_utils.GoogleAccountsLogin(self, username, password)
        test_utils.WaitForInfobarTypeAndGetIndex(self, self.INFOBAR_TYPE)
Пример #11
0
 def testProtocolHandlerRegisteredCorrectly(self):
     """Verify sites that ask to be default handlers registers correctly."""
     url = self.GetHttpURLForDataPath('settings', 'protocol_handler.html')
     self.NavigateToURL(url)
     # Returns a dictionary with the custom handler.
     asked_handler_dict = self._driver.execute_script(
         'return registerCustomHandler()')
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self._driver.find_element_by_id('test_protocol').click()
     self.assertTrue(self._driver.execute_script(
         'return doesQueryConformsToProtocol("%s", "%s")' %
         (asked_handler_dict['query_key'],
          asked_handler_dict['query_value'])),
                     msg='Protocol did not register correctly.')
Пример #12
0
 def testInfoBarDisappearByNavigatingPage(self):
     """Test password infobar is dismissed when navigating to different page."""
     creds = self.GetPrivateInfo()['test_google_account']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     # Login to Google account.
     test_utils.GoogleAccountsLogin(self, creds['username'],
                                    creds['password'])
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.NavigateToURL('chrome://version')
     self.assertTrue(self.WaitForInfobarCount(0))
     # To make sure user is navigated to Version page.
     self.assertEqual('About Version', self.GetActiveTabTitle())
     test_utils.AssertInfobarTypeDoesNotAppear(self, self.INFOBAR_TYPE)
Пример #13
0
  def testNoOneClickInfobarAfterCancel(self):
    """Verify one-click infobar does not appear again after clicking cancel.

    The one-click infobar should not display again after logging into an
    account and selecting to reject sync the first time. The test covers
    restarting the browser with the same profile and verifying the one-click
    infobar does not show after login.

    This test also verifies that the password infobar displays.
    """
    self._DisplayOneClickInfobar()
    self._PerformActionOnInfobar(action='cancel')  # Click 'No thanks' button.
    self.NavigateToURL(self.URL_LOGOUT)
    self._LogIntoGoogleAccount()
    test_utils.WaitForInfobarTypeAndGetIndex(self, self.PW_INFOBAR_TYPE)
    test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
    # Restart browser with the same profile.
    self.RestartBrowser(clear_profile=False)
    self.NavigateToURL(self.URL_LOGOUT)
    self._LogIntoGoogleAccount()
    test_utils.AssertInfobarTypeDoesNotAppear(self, self.OC_INFOBAR_TYPE)
Пример #14
0
    def testClearFetchedCredForNewUserName(self):
        """Verify that the fetched credentials are cleared for a new username.

    This test requires sending key events rather than pasting a new username
    into the Email field.
    """
        creds = self.GetPrivateInfo()['test_google_account']
        username = creds['username']
        password = creds['password']
        # Disable one-click login infobar for sync.
        self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
        # Login to Google a/c
        test_utils.GoogleAccountsLogin(self, username, password)
        self.PerformActionOnInfobar(
            'accept',
            infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
                self, self.INFOBAR_TYPE))
        self.NavigateToURL(self.URL_LOGOUT)
        self.NavigateToURL(self.URL)
        self._ClickOnLoginPage(0, 0)
        test_utils.VerifyGoogleAccountCredsFilled(self,
                                                  username,
                                                  password,
                                                  tab_index=0,
                                                  windex=0)
        clear_username_field = ('document.getElementById("Email").value = ""; '
                                'window.domAutomationController.send("done");')
        set_focus = ('document.getElementById("Email").focus(); '
                     'window.domAutomationController.send("done");')
        self.ExecuteJavascript(clear_username_field, 0, 0)
        self.ExecuteJavascript(set_focus, 0, 0)
        self._SendCharToPopulateField('t', tab_index=0, windex=0)
        passwd_value = self.GetDOMValue(
            'document.getElementById("Passwd").value')
        self.assertFalse(passwd_value,
                         msg='Password field not empty for new username.')
        test_utils.ClearPasswords(self)
Пример #15
0
 def testLoginCredsNotShownInIncognito(self):
     """Verify login creds are not shown in Incognito mode."""
     creds = self.GetPrivateInfo()['test_google_account']
     username = creds['username']
     password = creds['password']
     # Disable one-click login infobar for sync.
     self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
     # Login to Google account.
     test_utils.GoogleAccountsLogin(self, username, password)
     self.PerformActionOnInfobar(
         'accept',
         infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
             self, self.INFOBAR_TYPE))
     self.NavigateToURL(self.URL_LOGOUT)
     self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
     self.NavigateToURL(self.URL, 1, 0)
     email_value = self.GetDOMValue(
         'document.getElementById("Email").value', tab_index=0, windex=1)
     passwd_value = self.GetDOMValue(
         'document.getElementById("Passwd").value', tab_index=0, windex=1)
     self.assertEqual(email_value,
                      '',
                      msg='Email creds displayed %s.' % email_value)
     self.assertEqual(passwd_value, '', msg='Password creds displayed.')
Пример #16
0
  def _VerifyFileIoExample(self, tab_index, name, url):
    """Verify File IO Example.

    Args:
      tab_index: Tab index integer that the example is on.
      name: A string name of the example.
      url: A string url of the example.
    """
    def _CheckStatus(substring_expected, fail_msg):
      self.assertTrue(
          self.WaitUntil(
            lambda: self.GetDOMValue(
              'document.getElementById("statusField").innerHTML', tab_index)\
                  .find(substring_expected) != -1, expect_retval=True),
          msg='Example %s failed. URL: %s. Reason: %s' % (name, url, fail_msg))

    # Give permission to use file system by clicking infobar OK
    infobar_index = test_utils.WaitForInfobarTypeAndGetIndex(self,
        'confirm_infobar', 0, tab_index)
    self.PerformActionOnInfobar('accept', infobar_index, 0, tab_index)
    _CheckStatus('Ready!', 'NaCl module load')

    # Check that deleting non-existing files gives file not found
    js_code = """
      document.getElementById('file_name').value = '/abc';
      document.getElementById('file_editor').value = 'test';
      document.getElementById('delete_but').click();
      window.domAutomationController.send('done');
    """
    self.ExecuteJavascript(js_code, tab_index)
    _CheckStatus('File not found', 'Delete non-existing')

    # Check that saving works
    js_code = """
      document.getElementById('save_but').click();
      window.domAutomationController.send('done');
    """
    self.ExecuteJavascript(js_code, tab_index)
    _CheckStatus('Save successful', 'Save test')

    # Check that we load what we saved
    js_code = """
      document.getElementById('file_editor').value = 'different';
      document.getElementById('load_but').click();
      window.domAutomationController.send('done');
    """
    self.ExecuteJavascript(js_code, tab_index)
    _CheckStatus('Load complete', 'Load test')
    self.assertTrue(
        self.GetDOMValue('document.getElementById("file_editor").value',
          tab_index).find('test') != -1, msg='Loaded wrong text or failed')

    # Check that we delete files successfully
    js_code = """
      document.getElementById('delete_but').click();
      window.domAutomationController.send('done');
    """
    self.ExecuteJavascript(js_code, tab_index)
    _CheckStatus('File deleted', 'Delete test')

    # Check that file is deleted and load produces not found
    js_code = """
      document.getElementById('load_but').click();
      window.domAutomationController.send('done');
    """
    self.ExecuteJavascript(js_code, tab_index)
    _CheckStatus('File not found', 'Load deleted test')