Ejemplo n.º 1
0
    def create(cls, jsbridge_timeout=JSBRIDGE_TIMEOUT,
               handlers=None, app='firefox', profile_args=None,
               runner_args=None):

        jsbridge_port = jsbridge.find_port()

        # select runner and profile class for the given app
        try:
            runner_class = mozrunner.runners[app]
        except KeyError:
            msg = 'Application "%s" unknown (should be one of %s)'
            raise NotImplementedError(msg % (app, mozrunner.runners.keys()))

        # get the necessary arguments to construct the profile and
        # runner instance
        profile_args = profile_args or {}
        profile_args.setdefault('addons', []).extend(ADDONS)

        preferences = profile_args.setdefault('preferences', {})
        if isinstance(preferences, dict):
            preferences['extensions.jsbridge.port'] = jsbridge_port
        elif isinstance(preferences, list):
            preferences.append(('extensions.jsbridge.port', jsbridge_port))
        else:
            raise Exception('Invalid type for preferences in profile_args')

        runner_args = runner_args or {}
        runner_args['profile_args'] = profile_args

        # create an equipped runner
        runner = runner_class.create(**runner_args)

        # create a mozmill
        return cls(runner, jsbridge_port, jsbridge_timeout=jsbridge_timeout,
                   handlers=handlers)
Ejemplo n.º 2
0
    def create(cls,
               jsbridge_timeout=JSBRIDGE_TIMEOUT,
               handlers=None,
               app='firefox',
               profile_args=None,
               runner_args=None,
               screenshots_path=None,
               server_root=None):

        jsbridge_port = jsbridge.find_port()

        # select runner and profile class for the given app
        try:
            runner_class = mozrunner.runners[app]
        except KeyError:
            msg = 'Application "%s" unknown (should be one of %s)'
            raise NotImplementedError(msg % (app, mozrunner.runners.keys()))

        # get the necessary arguments to construct the profile and
        # runner instance
        profile_args = copy.deepcopy(profile_args) or {}
        profile_args.setdefault('addons', []).extend(ADDONS)

        preferences = profile_args.setdefault('preferences', {})
        if isinstance(preferences, dict):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences['browser.tabs.remote'] = False
            preferences['browser.tabs.autostart'] = False
            preferences['browser.displayedE10SPrompt'] = 5

            preferences['extensions.jsbridge.port'] = jsbridge_port
            preferences['focusmanager.testmode'] = True
        elif isinstance(preferences, list):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences.append(('browser.tabs.remote', False))
            preferences.append(('browser.tabs.autostart', False))
            preferences.append(('browser.displayedE10SPrompt', 5))

            preferences.append(('extensions.jsbridge.port', jsbridge_port))
            preferences.append(('focusmanager.testmode', True))
        else:
            raise Exception('Invalid type for preferences in profile_args')

        runner_args = copy.deepcopy(runner_args) or {}
        runner_args['profile_args'] = profile_args

        # update environment variables for API usage
        os.environ.update(ENVIRONMENT)

        # create an equipped runner
        runner = runner_class.create(**runner_args)

        # create a mozmill
        return cls(runner,
                   jsbridge_port,
                   jsbridge_timeout=jsbridge_timeout,
                   handlers=handlers,
                   screenshots_path=screenshots_path,
                   server_root=server_root)
Ejemplo n.º 3
0
    def create(cls, jsbridge_timeout=JSBRIDGE_TIMEOUT,
               handlers=None, app='firefox', profile_args=None,
               runner_args=None, screenshots_path=None, server_root=None):

        jsbridge_port = jsbridge.find_port()

        # select runner and profile class for the given app
        try:
            runner_class = mozrunner.runners[app]
        except KeyError:
            msg = 'Application "%s" unknown (should be one of %s)'
            raise NotImplementedError(msg % (app, mozrunner.runners.keys()))

        # get the necessary arguments to construct the profile and
        # runner instance
        profile_args = copy.deepcopy(profile_args) or {}
        profile_args.setdefault('addons', []).extend(ADDONS)

        preferences = profile_args.setdefault('preferences', {})
        if isinstance(preferences, dict):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences['browser.tabs.remote'] = False
            preferences['browser.tabs.autostart'] = False
            preferences['browser.displayedE10SPrompt'] = 5

            preferences['extensions.jsbridge.port'] = jsbridge_port
            preferences['focusmanager.testmode'] = True
        elif isinstance(preferences, list):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences.append(('browser.tabs.remote', False))
            preferences.append(('browser.tabs.autostart', False))
            preferences.append(('browser.displayedE10SPrompt', 5))

            preferences.append(('extensions.jsbridge.port', jsbridge_port))
            preferences.append(('focusmanager.testmode', True))
        else:
            raise Exception('Invalid type for preferences in profile_args')

        runner_args = copy.deepcopy(runner_args) or {}
        runner_args['profile_args'] = profile_args

        # update environment variables for API usage
        os.environ.update(ENVIRONMENT)

        # create an equipped runner
        runner = runner_class.create(**runner_args)

        # create a mozmill
        return cls(runner, jsbridge_port, jsbridge_timeout=jsbridge_timeout,
                   handlers=handlers, screenshots_path=screenshots_path,
                   server_root=server_root)
Ejemplo n.º 4
0
    def create(cls,
               jsbridge_timeout=JSBRIDGE_TIMEOUT,
               handlers=None,
               app='firefox',
               profile_args=None,
               runner_args=None,
               screenshots_path=None):

        jsbridge_port = jsbridge.find_port()

        # select runner and profile class for the given app
        try:
            runner_class = mozrunner.runners[app]
        except KeyError:
            msg = 'Application "%s" unknown (should be one of %s)'
            raise NotImplementedError(msg % (app, mozrunner.runners.keys()))

        # get the necessary arguments to construct the profile and
        # runner instance
        profile_args = profile_args or {}
        profile_args.setdefault('addons', []).extend(ADDONS)

        preferences = profile_args.setdefault('preferences', {})
        if isinstance(preferences, dict):
            preferences['extensions.jsbridge.port'] = jsbridge_port
            preferences['focusmanager.testmode'] = True
        elif isinstance(preferences, list):
            preferences.append(('extensions.jsbridge.port', jsbridge_port))
            preferences.append(('focusmanager.testmode', True))
        else:
            raise Exception('Invalid type for preferences in profile_args')

        runner_args = runner_args or {}
        runner_args['profile_args'] = profile_args

        # create an equipped runner
        runner = runner_class.create(**runner_args)

        # create a mozmill
        return cls(runner,
                   jsbridge_port,
                   jsbridge_timeout=jsbridge_timeout,
                   handlers=handlers,
                   screenshots_path=screenshots_path)
Ejemplo n.º 5
0
    def __init__(self, args):

        # event handler plugin names
        self.handlers = {}
        for handler_class in handlers.handlers():
            name = getattr(handler_class, 'name', handler_class.__name__)
            self.handlers[name] = handler_class

        self.jsbridge_port = jsbridge.find_port()

        # add and parse options
        mozrunner.CLI.__init__(self, args)

        # Do not allow manifests and tests specified at the same time
        if self.options.manifests and self.options.tests:
            self.parser.error("Options %s and %s are mutually exclusive." %
                              (self.parser.get_option('-t'),
                               self.parser.get_option('-m')))

        # read tests from manifests (if any)
        self.manifest = TestManifest(manifests=self.options.manifests,
                                     strict=False)

        # expand user directory and check existence for the test
        for test in self.options.tests:
            testpath = os.path.expanduser(test)
            realpath = os.path.realpath(testpath)
            if not os.path.exists(testpath):
                raise Exception("Not a valid test file/directory: %s" % test)

            # collect the tests
            def testname(t):
                if os.path.isdir(realpath):
                    return os.path.join(test, os.path.relpath(t, testpath))
                return test
            tests = [{'name': testname(t), 'path': t}
                     for t in collect_tests(testpath)]
            self.manifest.tests.extend(tests)

        # list the tests and exit if specified
        if self.options.list_tests:
            for test in self.manifest.tests:
                print test['path']
            self.parser.exit()

        # instantiate event handler plugins
        self.event_handlers = []
        for name, handler_class in self.handlers.items():
            if name in self.options.disable:
                continue
            handler = handlers.instantiate_handler(handler_class, self.options)
            if handler is not None:
                self.event_handlers.append(handler)
        for handler in self.options.handlers:
            # user handlers
            try:
                handler_class = handlers.load_handler(handler)
            except BaseException as e:
                self.parser.error(str(e))
            _handler = handlers.instantiate_handler(handler_class,
                                                    self.options)
            if _handler is not None:
                self.event_handlers.append(_handler)

        # if in manual mode, ensure we're interactive
        if self.options.manual:
            self.options.interactive = True
Ejemplo n.º 6
0
    def create(cls,
               binary=None,
               jsbridge_timeout=JSBRIDGE_TIMEOUT,
               handlers=None,
               app='firefox',
               profile_args=None,
               runner_args=None,
               screenshots_path=None,
               server_root=None):

        jsbridge_port = jsbridge.find_port()

        # select runner and profile class for the given app
        try:
            runner_class = mozrunner.runners[app]
            profile_class = get_app_context(app).profile_class
        except KeyError:
            msg = 'Application "%s" unknown (should be one of %s)'
            raise NotImplementedError(msg % (app, mozrunner.runners.keys()))

        # get the necessary arguments to construct the profile and
        # runner instance
        profile_args = copy.deepcopy(profile_args) or {}
        profile_args.setdefault('addons', []).extend(ADDONS)

        preferences = profile_args.setdefault('preferences', {})
        if isinstance(preferences, dict):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences['browser.tabs.remote.autostart'] = False
            preferences['browser.displayedE10SPrompt'] = 5

            # Bug 1081996: Separate fixes for each e10s testing duration
            for i in range(1, 10):
                preferences['browser.tabs.remote.autostart.%s' % i] = False
                preferences['browser.displayedE10SPrompt.%s' % i] = 5

            preferences['browser.newtabpage.introShown'] = True
            preferences['browser.uitour.enabled'] = False
            preferences['extensions.jsbridge.port'] = jsbridge_port
            preferences['focusmanager.testmode'] = True
        elif isinstance(preferences, list):
            # Bug 695026 - Re-enable e10s when fully supported
            preferences.append(('browser.tabs.remote.autostart', False))
            preferences.append(('browser.displayedE10SPrompt', 5))

            # Bug 1081996: Separate fixes for each e10s testing duration
            for i in range(1, 10):
                preferences.append(
                    ('browser.tabs.remote.autostart.%s' % i, False))
                preferences.append(('browser.displayedE10SPrompt.%s' % i, 5))

            preferences.append(('browser.newtabpage.introShown', True))
            preferences.append(('browser.uitour.enabled', False))
            preferences.append(('extensions.jsbridge.port', jsbridge_port))
            preferences.append(('focusmanager.testmode', True))
        else:
            raise Exception('Invalid type for preferences in profile_args')

        # update environment variables for API usage
        os.environ.update(ENVIRONMENT)

        # create an equipped runner
        profile = profile_class(**profile_args)

        # if no binary is given, take it from the browser path env variable
        binary = binary or os.environ.get('BROWSER_PATH', None)

        # setup the runner
        runner_args = copy.deepcopy(runner_args) or {}
        runner = runner_class(binary=binary, profile=profile, **runner_args)

        # create a mozmill
        return cls(runner,
                   jsbridge_port,
                   jsbridge_timeout=jsbridge_timeout,
                   handlers=handlers,
                   screenshots_path=screenshots_path,
                   server_root=server_root)