Prepare image comparison in safetynet_compare.py to work in nightly run.

Do not open the html in a browser automatically.

Change-Id: I7394b86f4a46a701dedb4fa0887515211561aee7
Reviewed-on: https://pdfium-review.googlesource.com/32315
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
diff --git a/testing/tools/safetynet_compare.py b/testing/tools/safetynet_compare.py
index 3c5cff8..96691096 100755
--- a/testing/tools/safetynet_compare.py
+++ b/testing/tools/safetynet_compare.py
@@ -116,7 +116,7 @@
           ('before', 'after'),
           self.args.num_workers,
           self.args.png_threshold)
-      image_comparison.Run()
+      image_comparison.Run(open_in_browser=not self.args.machine_readable)
 
     return 0
 
diff --git a/testing/tools/safetynet_image.py b/testing/tools/safetynet_image.py
index 28df3c5..319eeb9 100644
--- a/testing/tools/safetynet_image.py
+++ b/testing/tools/safetynet_image.py
@@ -52,7 +52,7 @@
     self.num_workers = num_workers
     self.threshold = threshold_fraction * 100
 
-  def Run(self):
+  def Run(self, open_in_browser):
     """Runs the comparison and generates an HTML with the results.
 
     Returns:
@@ -94,7 +94,9 @@
       f.write('</table>')
       f.write('</body></html>')
 
-    webbrowser.open(html_path)
+    if open_in_browser:
+      webbrowser.open(html_path)
+
     return 0
 
   def _GenerateDiffs(self):