diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-10-22 19:39:33 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-10-22 19:39:33 +0200 |
commit | 513dfcc432ce20e62623c97ca44352211c1422a0 (patch) | |
tree | d21584e01cef13441645af97e3d556af93e01a3b /crocoite | |
parent | 958563a3602780b48599c27acf212139c2e6904d (diff) | |
download | crocoite-513dfcc432ce20e62623c97ca44352211c1422a0.tar.gz crocoite-513dfcc432ce20e62623c97ca44352211c1422a0.tar.bz2 crocoite-513dfcc432ce20e62623c97ca44352211c1422a0.zip |
behavior: Unload script only if the handle is valid
For some reason with Google Chrome 70 this is not the case any more.
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/behavior.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py index 8c24c59..119248e 100644 --- a/crocoite/behavior.py +++ b/crocoite/behavior.py @@ -114,10 +114,12 @@ class JsOnload (Behavior): def onload (self): yield self.script - self.scriptHandle = self.loader.tab.Page.addScriptToEvaluateOnNewDocument (source=str (self.script))['identifier'] + result = self.loader.tab.Page.addScriptToEvaluateOnNewDocument (source=str (self.script)) + self.scriptHandle = result['identifier'] def onstop (self): - self.loader.tab.Page.removeScriptToEvaluateOnNewDocument (identifier=self.scriptHandle) + if self.scriptHandle: + self.loader.tab.Page.removeScriptToEvaluateOnNewDocument (identifier=self.scriptHandle) yield from () ### Generic scripts ### |