summaryrefslogtreecommitdiff
path: root/crocoite
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2017-11-22 09:37:19 +0100
committerLars-Dominik Braun <lars@6xq.net>2017-11-22 09:37:19 +0100
commit9cff3074e52b91c49298f80fd3e73d77f1f1c7dd (patch)
tree0a3bb05be212023362c0f5900cdf92319afb1e05 /crocoite
parent82d779208d208c225e7b3deefc3aa45bb0aedce8 (diff)
downloadcrocoite-9cff3074e52b91c49298f80fd3e73d77f1f1c7dd.tar.gz
crocoite-9cff3074e52b91c49298f80fd3e73d77f1f1c7dd.tar.bz2
crocoite-9cff3074e52b91c49298f80fd3e73d77f1f1c7dd.zip
Emulate different screen sizes
Causes the browser to load CSS assets and <img> srcset, for example.
Diffstat (limited to 'crocoite')
-rw-r--r--crocoite/cli.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/crocoite/cli.py b/crocoite/cli.py
index 9a22d24..f9e0fd2 100644
--- a/crocoite/cli.py
+++ b/crocoite/cli.py
@@ -321,6 +321,29 @@ def main ():
'X-Chrome-Viewport': viewport})
writer.write_record (record)
+ def emulateScreenMetrics (tab):
+ """
+ Emulate different screen sizes, causing the site to fetch assets (img
+ srcset and css, for example) for different screen resolutions.
+ """
+ sizes = [
+ {'width': 1920, 'height': 1080, 'deviceScaleFactor': 1.5, 'mobile': False},
+ {'width': 1920, 'height': 1080, 'deviceScaleFactor': 2, 'mobile': False},
+ # very dense display
+ {'width': 1920, 'height': 1080, 'deviceScaleFactor': 4, 'mobile': False},
+ # just a few samples:
+ # 1st gen iPhone (portrait mode)
+ {'width': 320, 'height': 480, 'deviceScaleFactor': 1.8, 'mobile': True},
+ # 6th gen iPhone (portrait mode)
+ {'width': 750, 'height': 1334, 'deviceScaleFactor': 326/90, 'mobile': True},
+ ]
+ for s in sizes:
+ tab.Emulation.setDeviceMetricsOverride (**s)
+ tab.wait (1)
+ # wait until assets finished loading
+ while len (requests) != 0:
+ tab.wait (1)
+
logging.basicConfig (level=logging.DEBUG)
parser = argparse.ArgumentParser(description='Save website to WARC using Google Chrome.')
@@ -415,6 +438,8 @@ def main ():
while len (requests) != 0:
tab.wait (1)
+ emulateScreenMetrics (tab)
+
tab.Page.stopLoading ()
tab.Network.disable ()
tab.Page.disable ()