def __init__(self, backend, platform_backend, archive_path,
                 append_to_existing_wpr, make_javascript_deterministic,
                 credentials_path):
        assert platform_backend.platform != None

        self._browser_backend = backend
        self._platform_backend = platform_backend
        self._wpr_server = None
        self._local_server_controller = local_server.LocalServerController(
            backend)
        self._tabs = tab_list.TabList(backend.tab_list_backend)
        self.credentials = browser_credentials.BrowserCredentials()
        self.credentials.credentials_path = credentials_path
        self._platform_backend.DidCreateBrowser(self, self._browser_backend)

        self.SetReplayArchivePath(archive_path, append_to_existing_wpr,
                                  make_javascript_deterministic)

        browser_options = self._browser_backend.browser_options
        self.platform.FlushDnsCache()
        if browser_options.clear_sytem_cache_for_browser_and_profile_on_start:
            if self.platform.CanFlushIndividualFilesFromSystemCache():
                self.platform.FlushSystemCacheForDirectory(
                    self._browser_backend.profile_directory)
                self.platform.FlushSystemCacheForDirectory(
                    self._browser_backend.browser_directory)
            else:
                self.platform.FlushEntireSystemCache()

        self._browser_backend.SetBrowser(self)
        self._browser_backend.Start()
        self._platform_backend.DidStartBrowser(self, self._browser_backend)
Example #2
0
    def __init__(self, backend, platform_backend, credentials_path):
        super(Browser, self).__init__(app_backend=backend,
                                      platform_backend=platform_backend)
        self._browser_backend = backend
        self._platform_backend = platform_backend
        self._local_server_controller = local_server.LocalServerController(
            platform_backend)
        self._tabs = tab_list.TabList(backend.tab_list_backend)
        self.credentials = browser_credentials.BrowserCredentials()
        self.credentials.credentials_path = credentials_path
        self._platform_backend.DidCreateBrowser(self, self._browser_backend)

        browser_options = self._browser_backend.browser_options
        self.platform.FlushDnsCache()
        if browser_options.clear_sytem_cache_for_browser_and_profile_on_start:
            if self.platform.CanFlushIndividualFilesFromSystemCache():
                self.platform.FlushSystemCacheForDirectory(
                    self._browser_backend.profile_directory)
                self.platform.FlushSystemCacheForDirectory(
                    self._browser_backend.browser_directory)
            else:
                self.platform.FlushEntireSystemCache()

        self._browser_backend.SetBrowser(self)
        self._browser_backend.Start()
        self._platform_backend.DidStartBrowser(self, self._browser_backend)
        self._profiling_controller = profiling_controller.ProfilingController(
            self._browser_backend.profiling_controller_backend)
Example #3
0
 def __init__(self, backend, platform_backend):
     self._browser_backend = backend
     self._http_server = None
     self._wpr_server = None
     self._platform_backend = platform_backend
     self._active_profilers = []
     self._profilers_states = {}
     self._local_server_controller = local_server.LocalServerController(
         backend)
     self._tabs = tab_list.TabList(backend.tab_list_backend)
     self.credentials = browser_credentials.BrowserCredentials()
     self.platform.SetFullPerformanceModeEnabled(True)
Example #4
0
  def __init__(self, backend, platform_backend):
    assert platform_backend.platform != None

    self._browser_backend = backend
    self._platform_backend = platform_backend
    self._wpr_server = None
    self._active_profilers = []
    self._profilers_states = {}
    self._local_server_controller = local_server.LocalServerController(backend)
    self._tabs = tab_list.TabList(backend.tab_list_backend)
    self.credentials = browser_credentials.BrowserCredentials()

    self._platform_backend.DidCreateBrowser(self, self._browser_backend)
Example #5
0
 def __init__(self, backend, platform_backend):
     self._browser_backend = backend
     self._http_server = None
     self._wpr_server = None
     self._platform = platform.Platform(platform_backend)
     self._platform_backend = platform_backend
     self._tabs = tab_list.TabList(backend.tab_list_backend)
     self._extensions = None
     if backend.supports_extensions:
         self._extensions = extension_dict.ExtensionDict(
             backend.extension_dict_backend)
     self.credentials = browser_credentials.BrowserCredentials()
     self._platform.SetFullPerformanceModeEnabled(True)
Example #6
0
 def CheckCredentials(self, page_set):
   """Verify that all pages in page_set use proper credentials"""
   credentials = browser_credentials.BrowserCredentials()
   if page_set.credentials_path:
     credentials.credentials_path = (
         os.path.join(page_set.base_dir, page_set.credentials_path))
   for page in page_set.pages:
     fail_message = ('page %s of %s has invalid credentials %s' %
                     (page.url, page_set.file_path, page.credentials))
     if page.credentials:
       try:
         self.assertTrue(credentials.CanLogin(page.credentials), fail_message)
       except browser_credentials.CredentialsError:
         self.fail(fail_message)
Example #7
0
 def CheckCredentials(self, story_set):
     """Verify that all pages in story_set use proper credentials"""
     for story in story_set.user_stories:
         if not isinstance(story, page.Page):
             continue
         credentials = browser_credentials.BrowserCredentials()
         if story.credentials_path:
             credentials.credentials_path = (os.path.join(
                 story.base_dir, story.credentials_path))
         fail_message = (
             'page %s of %s has invalid credentials %s' %
             (story.url, story_set.file_path, story.credentials))
         if story.credentials:
             try:
                 self.assertTrue(credentials.CanLogin(story.credentials),
                                 fail_message)
             except browser_credentials.CredentialsError:
                 self.fail(fail_message)
Example #8
0
    def testCredentialsInfrastructure(self):
        google_backend = BackendStub("google")
        othersite_backend = BackendStub("othersite")
        browser_cred = browser_credentials.BrowserCredentials(
            [google_backend, othersite_backend])
        try:
            with tempfile.NamedTemporaryFile(delete=False) as f:
                f.write(SIMPLE_CREDENTIALS_STRING)

            browser_cred.credentials_path = f.name

            # Should true because it has a password and a backend.
            self.assertTrue(browser_cred.CanLogin('google'))

            # Should be false succeed because it has no password.
            self.assertFalse(browser_cred.CanLogin('othersite'))

            # Should fail because it has no backend.
            self.assertRaises(Exception,
                              lambda: browser_cred.CanLogin('foobar'))

            tab = {}
            ret = browser_cred.LoginNeeded(tab, 'google')
            self.assertTrue(ret)
            self.assertTrue(google_backend.login_needed_called is not None)
            self.assertEqual(tab, google_backend.login_needed_called[0])
            self.assertEqual("example",
                             google_backend.login_needed_called[1]["username"])
            self.assertEqual("asdf",
                             google_backend.login_needed_called[1]["password"])

            browser_cred.LoginNoLongerNeeded(tab, 'google')
            self.assertTrue(
                google_backend.login_no_longer_needed_called is not None)
            self.assertEqual(tab,
                             google_backend.login_no_longer_needed_called[0])
        finally:
            os.remove(f.name)