Escape double quotes in trace contents

Change-Id: I179eb5ae88f7f4e1992ad4de0e67ae3ac30e58cb
diff --git a/systrace.py b/systrace.py
index 8fd861f..bf47c87 100755
--- a/systrace.py
+++ b/systrace.py
@@ -252,8 +252,11 @@
       html_file = open(html_filename, 'w')
       html_file.write(
         html_prefix.replace("{{SYSTRACE_TRACE_VIEWER_HTML}}", trace_viewer_html))
-      html_out = out.replace('\n', '\\n\\\n')
-      html_file.write(html_out)
+
+      # format newlines and double quotes
+      # for embedding in double-quoted JS string
+      html_file.write(out.replace('\n', '\\n\\\n').replace('\"', '\\\"'))
+
       html_file.write(html_suffix)
       html_file.close()
       print "\n    wrote file://%s\n" % os.path.abspath(options.output_file)