From 33fed291f230927c85c636287d87f99bbabf03d1 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 8 Dec 2018 09:40:25 +0100 Subject: behavior: Dump script options to file as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit click.js’s data was part of the script before 22adde79940d32c5f094f26f3e18b7160e7ccafc. Now it is injected dynamically, but it still would be nice to have the data available. --- crocoite/behavior.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'crocoite') diff --git a/crocoite/behavior.py b/crocoite/behavior.py index e731bcd..eb5478b 100644 --- a/crocoite/behavior.py +++ b/crocoite/behavior.py @@ -34,9 +34,8 @@ controller. This allows storing captured screenshots inside WARC files, for instance. """ -import asyncio +import asyncio, json, os.path from urllib.parse import urlsplit -import os.path from base64 import b64decode from collections import OrderedDict import pkg_resources @@ -66,9 +65,10 @@ class Script: return self.data @classmethod - def fromStr (cls, data): + def fromStr (cls, data, path=None): s = Script () s.data = data + s.path = path return s class Behavior: @@ -147,6 +147,8 @@ class JsOnload (Behavior): assert result.get ('subtype') != 'error', exception constructor = result['objectId'] + if self.options: + yield Script.fromStr (json.dumps (self.options, indent=2), '{}/options'.format (self.script.path)) result = await tab.Runtime.callFunctionOn ( functionDeclaration='function(options){return new this(options);}', objectId=constructor, -- cgit v1.2.3