summaryrefslogtreecommitdiff
path: root/crocoite
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2019-01-04 19:23:22 +0100
committerLars-Dominik Braun <lars@6xq.net>2019-01-04 19:23:22 +0100
commitcf83c608bf2fb4e9f458cc0ee31f87cc0948345d (patch)
tree7cdeea1aa39e41c68ad19644ec1486cb814df2ae /crocoite
parent3fb47a7286a8153660bad8cf44a0662d8fd537ca (diff)
downloadcrocoite-cf83c608bf2fb4e9f458cc0ee31f87cc0948345d.tar.gz
crocoite-cf83c608bf2fb4e9f458cc0ee31f87cc0948345d.tar.bz2
crocoite-cf83c608bf2fb4e9f458cc0ee31f87cc0948345d.zip
behavior: Ignore onstop() failure
Fails if the page is reloaded/redirected. See issue #13.
Diffstat (limited to 'crocoite')
-rw-r--r--crocoite/behavior.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py
index dff1439..2c94bb8 100644
--- a/crocoite/behavior.py
+++ b/crocoite/behavior.py
@@ -46,7 +46,7 @@ import yaml
from .util import getFormattedViewportMetrics
from . import html
from .html import StripAttributeFilter, StripTagFilter, ChromeTreeWalker
-from .devtools import Crashed
+from .devtools import Crashed, TabException
class Script:
""" A JavaScript resource """
@@ -150,9 +150,19 @@ class JsOnload (Behavior):
async def onstop (self):
tab = self.loader.tab
- assert self.context is not None
- await tab.Runtime.callFunctionOn (functionDeclaration='function(){return this.stop();}', objectId=self.context)
- await tab.Runtime.releaseObject (objectId=self.context)
+ try:
+ assert self.context is not None
+ await tab.Runtime.callFunctionOn (functionDeclaration='function(){return this.stop();}',
+ objectId=self.context)
+ await tab.Runtime.releaseObject (objectId=self.context)
+ except TabException as e:
+ # cannot do anything about that. Ignoring should be fine.
+ self.logger.error ('jsonload onstop failed',
+ uuid='1786726f-c8ec-4f79-8769-30954d4e32f5',
+ exception=e.args,
+ objectId=self.context,
+ context=self.__class__.__name__)
+
return
yield # pragma: no cover