Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2497)

Unified Diff: net/tools/testserver/testserver.py

Issue 4664009: All SSL UI tests work with ephemeral ports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/test/test_server.cc ('K') | « net/test/test_server.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 55aa6a9a1e1a297f51108079e00af6c22ccac62c..6c258cfb93a4f34330ba57a3175afaca3fe55bcd 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -576,20 +576,26 @@ class TestPageHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def _ReplaceFileData(self, data, query_parameters):
"""Replaces matching substrings in a file.
- If the 'replace_orig' and 'replace_new' URL query parameters are present,
- a new string is returned with all occasions of the 'replace_orig' value
- replaced by the 'replace_new' value.
+ If the 'replace_text' URL query parameter is present, it is expected to be
+ of the form old_text:new_text, which indicates that any old_text strings in
+ the file are replaced with new_text. Multiple 'replace_text' parameters may
+ be specified.
If the parameters are not present, |data| is returned.
"""
query_dict = cgi.parse_qs(query_parameters)
- orig_values = query_dict.get('replace_orig', [])
- new_values = query_dict.get('replace_new', [])
- if not orig_values or not new_values:
- return data
- orig_value = orig_values[0]
- new_value = new_values[0]
- return data.replace(orig_value, new_value)
+ replace_text_values = query_dict.get('replace_text', [])
+ # TODO(cbentzel): Do all string substitutions in one pass? There are
akalin 2010/11/11 05:20:54 i don't think doing it in one pass is worth it; i
Paweł Hajdan Jr. 2010/11/11 10:40:45 Yeah.
cbentzel 2010/11/11 15:34:09 Done.
+ # not many tests which require multiple string substitutions.
+ for replace_text_value in replace_text_values:
+ replace_text_args = replace_text_value.split(':')
+ if len(replace_text_args) != 2:
akalin 2010/11/11 05:20:54 add warning here?
Paweł Hajdan Jr. 2010/11/11 10:40:45 Just make it explode with an exception, to make su
cbentzel 2010/11/11 15:34:09 Done.
+ continue
+ old_text_b64, new_text_b64 = replace_text_args
+ old_text = base64.urlsafe_b64decode(old_text_b64)
+ new_text = base64.urlsafe_b64decode(new_text_b64)
+ data = data.replace(old_text, new_text)
+ return data
def FileHandler(self):
"""This handler sends the contents of the requested file. Wow, it's like
« net/test/test_server.cc ('K') | « net/test/test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698