OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Launches Firefox and browses to an URL.""" |
| 7 |
| 8 import os |
| 9 import signal |
| 10 import sys |
| 11 |
| 12 from optparse import OptionParser |
| 13 |
| 14 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 15 THIRD_PARTY_DIR = os.path.abspath(os.path.join(BASE_DIR, 'third_party')) |
| 16 |
| 17 sys.path.append(os.path.join(THIRD_PARTY_DIR, 'manifestdestiny')) |
| 18 sys.path.append(os.path.join(THIRD_PARTY_DIR, 'mozinfo')) |
| 19 sys.path.append(os.path.join(THIRD_PARTY_DIR, 'mozprocess')) |
| 20 sys.path.append(os.path.join(THIRD_PARTY_DIR, 'mozprofile')) |
| 21 sys.path.append(os.path.join(THIRD_PARTY_DIR, 'mozrunner')) |
| 22 |
| 23 from mozprofile import profile |
| 24 from mozrunner import runner |
| 25 |
| 26 WEBRTC_PREFERENCES = { |
| 27 # Automatically gives permission to access the camera/microphone and |
| 28 # bypasses the permission/selection dialog. |
| 29 'media.navigator.permission.disabled': True, |
| 30 } |
| 31 |
| 32 def main(): |
| 33 usage = 'usage: %prog --binary <firefox_executable> --webpage <url>' |
| 34 parser = OptionParser(usage) |
| 35 parser.add_option('-b', '--binary', |
| 36 help=('Firefox executable to run.')) |
| 37 parser.add_option('-w', '--webpage', |
| 38 help=('Web page to browse to.')) |
| 39 options, _args = parser.parse_args() |
| 40 if not options.binary: |
| 41 parser.error('You must specify the Firefox browser executable.') |
| 42 if not options.webpage: |
| 43 parser.error('You must specify the web page to browse to.') |
| 44 |
| 45 firefox_profile = profile.FirefoxProfile(preferences=WEBRTC_PREFERENCES) |
| 46 firefox_runner = runner.FirefoxRunner(profile=firefox_profile, |
| 47 binary=options.binary, |
| 48 cmdargs=[options.webpage]) |
| 49 def KillFirefox(signum, frame): |
| 50 firefox_runner.stop() |
| 51 signal.signal(signal.SIGTERM, KillFirefox) |
| 52 |
| 53 firefox_runner.start() |
| 54 |
| 55 # Run until Chrome kills us. |
| 56 firefox_runner.process_handler.wait(timeout=600) |
| 57 return 0 |
| 58 |
| 59 if __name__ == '__main__': |
| 60 sys.exit(main()) |
OLD | NEW |