Bug 1291320 - Disallow slow loading page to be put into the cache. r=ato, r=automatedtester, a=test-only
authorHenrik Skupin <mail@hskupin.info>
Mon, 03 Apr 2017 22:40:48 +0200
changeset 375731 d449920050741d86b6dece2f12d053d01f654173
parent 375730 bffb705f4ca2e1c4995d02f3392336d8afd391c4
child 375732 512980f54f8cec06e824d424f7b1c84bca1546a2
push id11019
push userryanvm@gmail.com
push dateWed, 05 Apr 2017 21:18:17 +0000
treeherdermozilla-aurora@eb0d361dc73c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, automatedtester, test-only
bugs1291320
milestone54.0a2
Bug 1291320 - Disallow slow loading page to be put into the cache. r=ato, r=automatedtester, a=test-only 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
@@ -54,20 +54,29 @@ def http_auth_handler(req, response):
 
 @handlers.handler
 def upload_handler(request, response):
     return 200, [], [request.headers.get("Content-Type")] or []
 
 
 @handlers.handler
 def slow_loading_handler(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