~phablet-team/webbrowser-app/trunk

« back to all changes in this revision

Viewing changes to tests/autopilot/webapp_container/tests/fake_servers.py

  • Committer: Olivier Tilloy
  • Date: 2016-03-10 05:56:42 UTC
  • mfrom: (1378 webbrowser-app)
  • mto: This revision was merged to the branch mainline in revision 1380.
  • Revision ID: olivier.tilloy@canonical.com-20160310055642-gcuwehtae8uq8hyr
Merge the latest changes from trunk and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import http.server as http
19
19
import logging
20
20
import threading
 
21
import urllib
21
22
 
22
23
 
23
24
class RequestHandler(http.BaseHTTPRequestHandler):
66
67
</html>
67
68
        """
68
69
 
69
 
    def targetted_click_content(self):
 
70
    def external_href_with_link_content(self, path="open-close-content"):
70
71
        return """
71
72
<html>
72
73
<head>
74
75
</head>
75
76
<body>
76
77
<div>
77
 
<a href="/open-close-content" target="_blank">
 
78
<a href="/{}" target="_blank">
78
79
<div style="height: 100%; width: 100%">
79
80
</div>
80
81
</a>
81
82
</div>
82
83
</body>
83
84
</html>
84
 
        """
 
85
        """.format(path)
85
86
 
86
87
    def display_ua_content(self):
87
88
        return """
213
214
            self.serve_content(html)
214
215
        elif self.path == '/with-targetted-link':
215
216
            self.send_response(200)
216
 
            self.serve_content(self.targetted_click_content())
 
217
            self.serve_content(self.external_href_with_link_content())
217
218
        elif self.path == '/show-user-agent':
218
219
            self.send_response(200)
219
220
            self.serve_content(self.display_ua_content())
255
256
            self.send_response(302)
256
257
            self.send_header("Location", locationTarget)
257
258
            self.end_headers()
 
259
        elif self.path.startswith('/with-overlay-link'):
 
260
            qs = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
 
261
            self.send_response(200)
 
262
            self.serve_content(
 
263
                self.external_href_with_link_content(qs['path'][0]))
258
264
        else:
259
265
            self.send_error(404)
260
266