1# Copyright 2014 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4import sys 5import os 6import optparse 7 8from ui import spy_project 9from tvcm import generate 10 11def Main(args): 12 parser = optparse.OptionParser() 13 parser.add_option('--output-file', '-o') 14 options,args = parser.parse_args(args) 15 16 if options.output_file: 17 ofile = open(options.output_file, 'w') 18 else: 19 ofile = sys.stdout 20 GenerateHTML(ofile) 21 if ofile != sys.stdout: 22 ofile.close() 23 24def GenerateHTML(ofile): 25 project = spy_project.SpyProject() 26 load_sequence = project.CalcLoadSequenceForModuleNames( 27 ['ui.spy_shell']) 28 bootstrap_js = """ 29 30 document.addEventListener('DOMContentLoaded', function() { 31 document.body.appendChild(new ui.SpyShell('ws://127.0.0.1:42424')); 32 33 }); 34""" 35 bootstrap_script = generate.ExtraScript(text_content=bootstrap_js) 36 generate.GenerateStandaloneHTMLToFile( 37 ofile, load_sequence, 38 title='Mojo spy', 39 extra_scripts=[bootstrap_script]) 40