Exemplo n.º 1
0
    def run_test(self, testname, testvars={}):
        if not self.ready:
            return self.error("run_test() called before setup")

        self.info("Beginning marionette test '%s'" % testname)

        e10s = testvars.get("e10s", False)

        prefs = {
            # disable network access
            "network.proxy.socks": "localhost",
            "network.proxy.socks_port": testvars.get("proxyPort", 90000),
            "network.proxy.socks_remote_dns": True,
            "network.proxy.type": 1,  # Socks

            # Don't open the first-run dialog, it loads a video
            'startup.homepage_welcome_url': '',
            'startup.homepage_override_url': '',
            'browser.newtab.url': 'about:blank',

            # make sure e10s is enabled
            "browser.tabs.remote.autostart": e10s,
            "browser.tabs.remote.autostart.1": e10s,
            "browser.tabs.remote.autostart.2": e10s,

            # We're not testing flash memory usage. Also: it likes to crash in VNC sessions.
            "plugin.disable": True,

            # Specify a communications port
            "marionette.defaultPrefs.port": self.port,

            # override image expiration in hopes of getting less volatile numbers
            "image.mem.surfacecache.min_expiration_ms": 10000
        }

        # Setup a test runner with our prefs and a default logger.
        # TODO(ER): We might want to use a larger set of "automation" preferences
        #           until marionette sets them for us. See bug 1123683.
        profile = mozprofile.FirefoxProfile(preferences=prefs)

        debug = testvars.get("debug", False)
        if debug:
            commandline.formatter_option_defaults['level'] = 'debug'

        logger = commandline.setup_logging("MarionetteTest", {})
        runner = MarionetteTestRunner(binary=self.tester.binary,
                                      profile=profile,
                                      logger=logger,
                                      address="localhost:%d" % self.port,
                                      gecko_log=self.gecko_log,
                                      startup_timeout=60)

        # Add test
        testpath = os.path.join(*testvars['test'])
        if not os.path.exists(testpath):
            return self.error(
                "Test '%s' specifies a test that doesn't exist: %s" %
                (testname, testpath))

        # Add our testvars
        runner.testvars.update(testvars)

        # Run test
        self.info("Marionette - starting browser")
        try:
            self.info("Marionette - running test")
            runner.run_tests([testpath])
            failures = runner.failed
        except Exception, e:
            try:
                runner.cleanup()
            except:
                pass
            return self.error("Marionette test run failed -- %s: %s" %
                              (type(e), e))
Exemplo n.º 2
0
  def run_test(self, testname, testvars={}):
    if not self.ready:
      return self.error("run_test() called before setup")

    self.info("Beginning marionette test '%s'" % testname)

    e10s = testvars.get("e10s", False)

    prefs = {
      # disable network access
      "network.proxy.socks": "localhost",
      "network.proxy.socks_port": testvars.get("proxyPort", 90000),
      "network.proxy.socks_remote_dns": True,
      "network.proxy.type": 1, # Socks

      # Don't open the first-run dialog, it loads a video
      'startup.homepage_welcome_url': '',
      'startup.homepage_override_url': '',
      'browser.newtab.url': 'about:blank',

      # make sure e10s is enabled
      "browser.tabs.remote.autostart": e10s,
      "browser.tabs.remote.autostart.1": e10s,
      "browser.tabs.remote.autostart.2": e10s,

      # We're not testing flash memory usage. Also: it likes to crash in VNC sessions.
      "plugin.disable": True,

      # Specify a communications port
      "marionette.defaultPrefs.port": self.port,

      # override image expiration in hopes of getting less volatile numbers
      "image.mem.surfacecache.min_expiration_ms": 10000
    }

    # Setup a test runner with our prefs and a default logger.
    # TODO(ER): We might want to use a larger set of "automation" preferences
    #           until marionette sets them for us. See bug 1123683.
    profile = mozprofile.FirefoxProfile(preferences=prefs)

    debug = testvars.get("debug", False)
    if debug:
      commandline.formatter_option_defaults['level'] = 'debug'

    logger = commandline.setup_logging("MarionetteTest", {})
    runner = MarionetteTestRunner(
                    binary=self.tester.binary,
                    profile=profile,
                    logger=logger,
                    address="localhost:%d" % self.port,
                    gecko_log=self.gecko_log,
                    startup_timeout=60)

    # Add test
    testpath = os.path.join(*testvars['test'])
    if not os.path.exists(testpath):
      return self.error("Test '%s' specifies a test that doesn't exist: %s" % (testname, testpath))

    # Add our testvars
    runner.testvars.update(testvars)

    # Run test
    self.info("Marionette - starting browser")
    try:
      self.info("Marionette - running test")
      runner.run_tests([ testpath ])
      failures = runner.failed
    except Exception, e:
      try:
        runner.cleanup()
      except: pass
      return self.error("Marionette test run failed -- %s: %s" % (type(e), e))