diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-07-25 09:37:38 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-07-25 09:37:38 +0200 |
commit | 784d19214c569be63efddd36a6d1d5ff440edcd2 (patch) | |
tree | c24accabf0f60a4271d9a467bbc4d1f42f540a28 | |
parent | 4905ac083b5f570988446a2b9dde3a8747020f1a (diff) | |
download | crocoite-784d19214c569be63efddd36a6d1d5ff440edcd2.tar.gz crocoite-784d19214c569be63efddd36a6d1d5ff440edcd2.tar.bz2 crocoite-784d19214c569be63efddd36a6d1d5ff440edcd2.zip |
behavior: Ignore failed onload script injection
Will be re-injected by controller anyway.
-rw-r--r-- | crocoite/behavior.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py index 4d89ae7..a12e9c2 100644 --- a/crocoite/behavior.py +++ b/crocoite/behavior.py @@ -147,16 +147,27 @@ class JsOnload (Behavior): if self.options: yield Script.fromStr (json.dumps (self.options, indent=2), f'{self.script.path}#options') - result = await tab.Runtime.callFunctionOn ( - functionDeclaration='function(options){return new this(options);}', - objectId=constructor, - arguments=[{'value': self.options}]) - self.logger.debug ('behavior onload start', - uuid='6c0605ae-93b3-46b3-b575-ba45790909a7', result=result) - result = result['result'] - assert result['type'] == 'object', result - assert result.get ('subtype') != 'error', result - self.context = result['objectId'] + + try: + result = await tab.Runtime.callFunctionOn ( + functionDeclaration='function(options){return new this(options);}', + objectId=constructor, + arguments=[{'value': self.options}]) + self.logger.debug ('behavior onload start', + uuid='6c0605ae-93b3-46b3-b575-ba45790909a7', result=result) + result = result['result'] + assert result['type'] == 'object', result + assert result.get ('subtype') != 'error', result + self.context = result['objectId'] + except TabException as e: + if e.args[0] == -32000: + # the site probably reloaded. ignore this, since we’ll be + # re-injected into the new site by the controller. + self.logger.error ('jsonload onload failed', + uuid='c151a863-78d1-41f4-a8e6-c022a6c5d252', + exception=e.args) + else: + raise async def onstop (self): tab = self.loader.tab |