Skip to content

Commit

Permalink
Merge pull request #20 from scivisum/task/RD-36214_memory_leak
Browse files Browse the repository at this point in the history
Task/rd 36214 memory leak
  • Loading branch information
matseymour28590 committed Sep 8, 2019
2 parents 2ffee9e + 546cbf5 commit 7b7761f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
23 changes: 1 addition & 22 deletions browserdebuggertools/chrome/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ def get_result(self, result_id):
"""
return self._socket_handler.find_result(result_id)

def get_results(self):
""" Retrieves a dictionary containing all the results indexed by result_id
"""
self._socket_handler.flush_messages()
return self._socket_handler.results

def clear_results(self):
""" Clears all results in the cache
"""
self._socket_handler.results.clear()

def get_events(self, domain, clear=False):
""" Retrieves all events for a given domain
:param domain: The domain to get the events for.
Expand All @@ -104,16 +93,6 @@ def execute(self, domain, method, args=None):

return self.wait_for_result(result_id)

def execute_async(self, domain, method, args=None):
""" Same as execute but doesn't wait for the result.
:param domain: chrome devtools protocol domain
:param method: domain specific method.
:param args: parameters to be executed
:return: id of the request
"""
return self._socket_handler.execute("{}.{}".format(domain, method), args)

def enable_domain(self, domain):
""" Enables notifications for the given domain.
"""
Expand Down Expand Up @@ -149,7 +128,7 @@ def set_timeout(self, value):
def navigate(self, url):
""" Navigates to the given url asynchronously
"""
return self.execute_async("Page", "navigate", {
return self.execute("Page", "navigate", {
"url": url
})

Expand Down
2 changes: 1 addition & 1 deletion browserdebuggertools/sockethandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def find_result(self, result_id):
if result_id not in self.results:
raise ResultNotFoundError("Result not found for id: {} .".format(result_id))

return self.results[result_id]
return self.results.pop(result_id)

def execute(self, method, params):
self._next_result_id += 1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="browserdebuggertools",
version="3.2.0",
version="4.0.0",
packages=PACKAGES,
install_requires=requires,
license="GNU General Public License v3",
Expand Down
12 changes: 4 additions & 8 deletions tests/e2etests/chrome/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,15 @@ class ChromeInterface_get_document_readystate(object):

def test_get_ready_state_dom_complete(self):

result_id = self.devtools_client.navigate(url="http://localhost:%s" % self.testSite.port)
self.devtools_client.wait_for_result(result_id)
self.devtools_client.navigate(url="http://localhost:%s" % self.testSite.port)
self._assert_dom_complete()
self.assertEqual("complete", self.devtools_client.get_document_readystate())

def test_take_screenshot_incomplete_main_exchange(self):
self.devtools_client.navigate(
url="http://localhost:%s?main_exchange_response_time=10" % self.testSite.port
)
result_id = self.devtools_client.navigate(url="http://localhost:%s" % self.testSite.port)
self.devtools_client.wait_for_result(result_id)
self.devtools_client.navigate(url="http://localhost:%s" % self.testSite.port)
self._assert_dom_complete()
self.assertEqual("complete", self.devtools_client.get_document_readystate())

Expand Down Expand Up @@ -213,10 +211,8 @@ def test_took_expected_time(self):
self.devtools_client.emulate_network_conditions(1, download, upload)

# Page has a default of 1 megabyte response body
result_id = self.devtools_client.navigate(url="http://localhost:%s/big_body"
% self.testSite.port)
self.devtools_client.wait_for_result(result_id)

self.devtools_client.navigate(url="http://localhost:%s/big_body"
% self.testSite.port)
self.assertTrue(self.waitForEventWithMethod("Network.responseReceived"))
# We have received the response header, now measure how long it takes to download the
# response body. It should take approximately 10 seconds.
Expand Down

0 comments on commit 7b7761f

Please sign in to comment.