Bug 1291320 - Disallow slow loading page to be put into the cache. r=ato,automatedtester
☠☠ backed out by b1f8a4a80d1a ☠ ☠
authorHenrik Skupin <mail@hskupin.info>
Wed, 15 Mar 2017 14:28:21 +0100
changeset 504117 7c06fe3e76fc2b74ec5ad9e9295764ecef556f86
parent 504116 db38ad37d57c98dd9553e494d3255fa1ae99ca04
child 504118 7c314416a41c2c76a16281771f1b3a66cea7d63c
push id50739
push userbmo:emilio+bugs@crisal.io
push dateThu, 23 Mar 2017 23:47:46 +0000
reviewersato, automatedtester
bugs1291320
milestone55.0a1
Bug 1291320 - Disallow slow loading page to be put into the cache. r=ato,automatedtester To delay the page load for our slowly served example page when using the back or forward commands, the page doesn't have to be put into the browser cache. MozReview-Commit-ID: 4xMjR3SakZn
testing/marionette/harness/marionette_harness/runner/httpd.py
--- a/testing/marionette/harness/marionette_harness/runner/httpd.py
+++ b/testing/marionette/harness/marionette_harness/runner/httpd.py
@@ -27,20 +27,29 @@ default_ssl_key = os.path.join(root, "ce
 
 @handlers.handler
 def upload_handler(request, response):
     return 200, [], [request.headers.get("Content-Type")] or []
 
 
 @handlers.handler
 def slow_loading_document(request, response):
-    time.sleep(5)
-    return """<!doctype html>
-<title>ok</title>
-<p>ok"""
+    # Allow the test specify the delay for delivering the content
+    params = dict(urlparse.parse_qsl(request.url_parts.query))
+    delay = int(params.get('delay', 5))
+    time.sleep(delay)
+
+    # Do not allow the page to be cached to circumvent the bfcache of the browser
+    response.headers.set("Cache-Control", "no-cache, no-store")
+    response.content = """<!doctype html>
+<meta charset="UTF-8">
+<title>Slow page loading</title>
+
+<p>Delay: <span id="delay">{}</span></p>
+""".format(delay)
 
 
 class NotAliveError(Exception):
     """Occurs when attempting to run a function that requires the HTTPD
     to have been started, and it has not.
 
     """
     pass