Пример #1
0
    def start_runner(self):
        """start the MozRunner"""

        # if user restart we don't need to start the browser back up
        if not (self.shutdownMode.get('user', False)
                and self.shutdownMode.get('restart', False)):
            if self.shutdownMode.get('resetProfile'):
                self.runner.reset() # reset the profile
            self.runner.start()
            
        # create the network
        self.create_network()

        # fetch the application info
        if not self.results.appinfo:
            self.results.appinfo = self.get_appinfo(self.bridge)

        frame = jsbridge.JSObject(self.bridge,
                                  "Components.utils.import('resource://mozmill/modules/frame.js')")

        # set some state
        self.shutdownMode = {}
        self.endRunnerCalled = False 
        frame.persisted = self.persisted # transfer persisted data

        # return the frame
        return frame
Пример #2
0
    def start_runner(self):
        """Start the MozRunner."""

        # if user restart we don't need to start the browser back up
        if not (self.shutdownMode.get('user', False)
                and self.shutdownMode.get('restart', False)):
            if self.shutdownMode.get('resetProfile'):
                # reset the profile
                self.runner.reset()
            self.runner.start(debug_args=self.debugger,
                              interactive=self.interactive)

        # set initial states for next test
        self.framework_failure = None
        self.shutdownMode = {}
        self.endRunnerCalled = False

        # create the network
        self.create_network()

        # fetch the application info
        if not self.results.appinfo:
            self.results.appinfo = self.get_appinfo()

        try:
            frame = jsbridge.JSObject(self.bridge, js_module_frame)

            # transfer persisted data
            frame.persisted = self.persisted
        except:
            self.report_disconnect(self.framework_failure)
            raise

        # return the frame
        return frame
Пример #3
0
def test(options):
    """Run test suite."""

    remote = start_jsbridge(options)

    import jsbridge

    MAX_TIMEOUT = 25.0

    result = {'is_successful': False}
    is_done = threading.Event()

    def listener(event_name, obj):
        if event_name == 'ubiquity:success':
            result['is_successful'] = obj
            is_done.set()

    remote.back_channel.add_global_listener(listener)

    uri = 'resource://ubiquity/tests/systemtests.js'
    tests = jsbridge.JSObject(remote.bridge,
                              "Components.utils.import('%s')" % uri)
    tests.start()

    is_done.wait(MAX_TIMEOUT)
    remote.runner.stop()

    if result['is_successful']:
        print "Success!"
    else:
        print "Failure."
        if not is_done.isSet():
            print "Timeout occurred."
        sys.exit(-1)
Пример #4
0
    def run_tests(self, test, sleeptime=4):
        """
        run a test file or directory
        - test : test file or directory to run
        - sleeptime : initial time to sleep [s] (not sure why the default is 4)
        """

        # Reset our Zombie Because we are still active
        #self.zombieDetector.resetTimer()

        self.test = test

        frame = jsbridge.JSObject(
            self.bridge,
            "Components.utils.import('resource://mozmill/modules/frame.js')")
        sleep(sleeptime)

        # transfer persisted data
        frame.persisted = self.persisted

        # run the test directory or file
        if os.path.isdir(test):
            frame.runTestDirectory(test)
        else:
            frame.runTestFile(test)

        # Give a second for any callbacks to finish.
        sleep(1)
Пример #5
0
    def start_runner(self):

        # if user_restart we don't need to start the browser back up
        if self.currentShutdownMode != self.shutdownModes.user_restart:
            self.runner.start()

        self.create_network()
        self.appinfo = self.get_appinfo(self.bridge)
        frame = jsbridge.JSObject(self.bridge,
                                  "ChromeUtils.import('resource://mozmill/modules/frame.js')")
        return frame
Пример #6
0
def start_jetpack(options, listener):
    remote = start_jsbridge(options)

    import jsbridge

    code = ("((function() { var extension = {}; "
            "Components.utils.import('resource://jetpack/modules/init.js', "
            "extension); return extension; })())")

    remote.back_channel.add_global_listener(listener)
    extension = jsbridge.JSObject(remote.bridge, code)

    INTERVAL = 0.1
    MAX_STARTUP_TIME = 5.0

    is_done = False
    time_elapsed = 0.0

    try:
        while not is_done:
            time.sleep(INTERVAL)
            time_elapsed += INTERVAL

            if time_elapsed > MAX_STARTUP_TIME:
                raise Exception('Maximum startup time exceeded.')

            url = 'chrome://jetpack/content/index.html'
            window = extension.get(url)
            if window is None:
                #print "Waiting for index to load."
                continue
            if hasattr(window, 'frameElement'):
                #print "Window is in an iframe."
                continue
            if window.closed:
                #print "Window is closed."
                continue
            if not hasattr(window, 'JSBridge'):
                #print "window.JSBridge does not exist."
                continue
            if not window.JSBridge.isReady:
                #print "Waiting for about:jetpack to be ready."
                continue
            is_done = True
    except:
        remote.runner.stop()
        raise

    remote.window = window
    return remote
Пример #7
0
    def get_appinfo(self, bridge):
        """ Collect application specific information """

        mozmill = jsbridge.JSObject(bridge, mozmillModuleJs)
        appInfo = mozmill.appInfo

        results = {'application_id': str(appInfo.ID),
                   'application_name': str(appInfo.name),
                   'application_version': str(appInfo.version),
                   'application_locale': str(mozmill.locale),
                   'platform_buildid': str(appInfo.platformBuildID),
                   'platform_version': str(appInfo.platformVersion),
                  }

        return results
Пример #8
0
    def get_appinfo(self):
        """Collect application specific information."""
        app_info = {}

        try:
            mozmill = jsbridge.JSObject(self.bridge, js_module_mozmill)
            app_info = json.loads(mozmill.getApplicationDetails())
            app_info.update(self.runner.get_repositoryInfo())

        except JSBridgeDisconnectError:
            # We don't have to call report_disconnect here because
            # start_runner() will handle this exception
            pass

        return app_info
Пример #9
0
    def get_appinfo(self):
        """Collect application specific information."""
        app_info = { }

        try:
            mozmill = jsbridge.JSObject(self.bridge, js_module_mozmill)
            app_info = json.loads(mozmill.getApplicationDetails())
            app_info.update(self.runner.get_repositoryInfo())

            # Bug 793764: The addons object is encoded twice so json.loads()
            # has to be called once more on it.
            app_info['addons'] = json.loads(app_info['addons'])
        except JSBridgeDisconnectError:
            # We don't have to call report_disconnect here because
            # start_runner() will handle this exception
            pass

        return app_info
Пример #10
0
 def get_build(self, bridge):
     appInfo = jsbridge.JSObject(bridge, appInfoJs)
     buildid = appInfo.appBuildID
     query = self.db.views.sitecompare.firefoxByBuildid(startkey=buildid,
                                                        endkey=buildid +
                                                        "0")
     if len(query) is 0:
         build = {}
         build['appInfo.id'] = str(appInfo.ID)
         build['type'] = 'productBuild'
         build['productType'] = 'firefox'
         build['buildid'] = str(appInfo.appBuildID)
         build['appInfo.platformVersion'] = appInfo.platformVersion
         build['appInfo.platformBuildID'] = appInfo.platformBuildID
         if self.store:
             build = self.db.get(self.db.create(build)['id'])
         return build
     else:
         return query[0]
Пример #11
0
    def start_runner(self):
        """Start the MozRunner."""

        # if user restart we don't need to start the browser back up
        if not self.shutdownMode.get('restart', False):
            if self.shutdownMode.get('resetProfile'):
                # reset the profile
                self.runner.reset()

            self.runner.start(debug_args=self.debugger,
                              interactive=self.interactive)

        # set initial states for next test
        self.framework_failure = None
        self.shutdownMode = {}
        self.endRunnerCalled = False

        # create the network
        self.create_network()

        # fetch the application info
        if not self.results.appinfo:
            appinfo = self.get_appinfo()

            self.results.appinfo = appinfo

            # We got the application appdata path. Use it for minidump backups.
            paths = appinfo.get('paths', {})
            if paths:
                self.minidump_save_path = os.path.join(paths['appdata'],
                                                       'Crash Reports',
                                                       'pending')

        try:
            frame = jsbridge.JSObject(self.bridge, js_module_frame)

            # transfer persisted data
            frame.persisted = self.persisted
        except:
            raise

        # return the frame
        return frame
Пример #12
0
    def stop_runner(self, timeout=10):
        # Give a second for any callbacks to finish.
        sleep(1)

        # reset the shutdown mode
        self.shutdownMode = {}

        # quit the application via JS
        # this *will* cause a disconnect error
        # (not sure what the socket.error is all about)
        try:
            mozmill = jsbridge.JSObject(self.bridge, js_module_mozmill)
            mozmill.cleanQuit()
        except (socket.error, JSBridgeDisconnectError):
            pass

        # wait for the runner to stop
        self.runner.wait(timeout=timeout)
        if self.runner.is_running():
            raise Exception('client process shutdown unsuccessful')
Пример #13
0
 def get_appinfo(self, bridge):
     """ Collect application specific information """
     mozmill = jsbridge.JSObject(bridge, mozmillModuleJs)
     appInfo = mozmill.appInfo
     results = {'application_id': str(appInfo.ID),
                'application_name': str(appInfo.name),
                'application_version': str(appInfo.version),
                'application_locale': str(mozmill.locale),
                'platform_buildid': str(appInfo.platformBuildID),
                'platform_version': str(appInfo.platformVersion),
               }
     try:
         startupInfo = mozmill.startupInfo
         results['startupInfo'] = dict([(i, getattr(startupInfo, i))
                                         for i in startupInfo.__attributes__()])
     except KeyError:
         results['startupInfo'] = None
     results['addons'] = json.loads(mozmill.addons)
     results.update(self.runner.get_repositoryInfo())
     return results
Пример #14
0
    def stop_runner(self):
        # Give a second for any callbacks to finish.
        sleep(1)

        # reset the shutdown mode
        self.shutdownMode = {}

        # quit the application via JS
        # this *will* cause a disconnect error
        # (not sure what the socket.error is all about)
        try:
            frame = jsbridge.JSObject(self.bridge, js_module_frame)
            frame.shutdownApplication()
        except (socket.error, jsbridge.ConnectionError):
            pass

        # wait for the runner to stop
        self.runner.wait(timeout=self.jsbridge_timeout)
        if self.runner.is_running():
            raise errors.ShutdownError('client process shutdown unsuccessful')
Пример #15
0
    def stop_runner(self, timeout=30, close_bridge=False, hard=False):
        sleep(1)
        try:
            mozmill = jsbridge.JSObject(self.bridge, mozmillModuleJs)
            mozmill.cleanQuit()
        except (socket.error, JSBridgeDisconnectError):
            pass
        except:
            self.runner.cleanup()
            raise

        if not close_bridge:
            starttime = datetime.utcnow()
            self.runner.wait(timeout=timeout)
            endtime = datetime.utcnow()
            if (endtime - starttime) > timedelta(seconds=timeout):
                try:
                    self.runner.stop()
                except:
                    pass
                self.runner.wait()
        else:  # TODO: unify this logic with the above better
            if hard:
                self.runner.cleanup()
                return

            # XXX this call won't actually finish in the specified timeout time
            self.runner.wait(timeout=timeout)

            self.back_channel.close()
            self.bridge.close()
            x = 0
            while x < timeout:
                if self.endRunnerCalled:
                    break
                sleep(1)
                x += 1
            else:
                print "WARNING | endRunner was never called. There must have been a failure in the framework."
                self.runner.cleanup()
                sys.exit(1)
Пример #16
0
    def run_tests(self, tests, sleeptime=0):
        """
        run test files or directories
        - test : test files or directories to run
        - sleeptime : initial time to sleep [s] (not sure why the default is 4)
        """

        tests = self.find_tests(tests)
        self.tests.extend(tests)

        frame = jsbridge.JSObject(self.bridge,
                                  "ChromeUtils.import('resource://mozmill/modules/frame.js')")
        sleep(sleeptime)

        # transfer persisted data
        frame.persisted = self.persisted

        # run the test files
        for test in tests:
            frame.runTestFile(test)

        # Give a second for any callbacks to finish.
        sleep(1)
Пример #17
0
    def start(self):
        self.runner1.start()
        self.runner2.start()

        self.back_channel1, self.bridge1 = jsbridge.wait_and_create_network(
            '127.0.0.1', 24242)
        self.back_channel2, self.bridge2 = jsbridge.wait_and_create_network(
            '127.0.0.1', 24243)
        self.back_channel1.add_listener(self.save_release_listener,
                                        eventType='sitecompare.save')
        self.back_channel2.add_listener(self.save_nightly_listener,
                                        eventType='sitecompare.save')

        self.back_channel1.add_listener(self.framebust_listener,
                                        eventType='sitecompare.framebust')
        self.back_channel2.add_listener(self.framebust_listener,
                                        eventType='sitecompare.framebust')

        self.back_channel1.add_listener(self.timeout_listener,
                                        eventType='sitecompare.timeout')
        self.back_channel2.add_listener(self.timeout_listener,
                                        eventType='sitecompare.timeout')

        # def gl(name, obj):
        #     print 'gl', name, obj
        # self.back_channel1.add_global_listener(gl)
        sleep(5)

        js = "Components.utils.import('resource://sitecompare/modules/compare.js')"
        self.c1 = jsbridge.JSObject(self.bridge1, js)
        self.c2 = jsbridge.JSObject(self.bridge2, js)

        if self.store:
            self.build1 = self.get_build(self.bridge1)
            self.build2 = self.get_build(self.bridge2)
            run = {
                "type": "comparison-run",
                "allsites": self.all_sites,
                "starttime": datetime.now().isoformat(),
                "status": "running"
            }
            run.update(self.comparison_info)
            run['release_buildid'] = self.build1.buildid
            run['release_docid'] = self.build1._id
            run['release_buildstring'] = self.build1.productType + '-' + self.build1[
                'appInfo.platformVersion'] + '-' + self.build1.buildid
            run['nightly_buildid'] = self.build2.buildid

            run['nightly_docid'] = self.build2._id
            run['nightly_buildstring'] = self.build2.productType + '-' + self.build2[
                'appInfo.platformVersion'] + '-' + self.build2.buildid

            self.run_info = self.db.create(run)
        else:
            import uuid
            self.run_info = {"id": str(uuid.uuid1())}

        self.directory = os.path.join(self.base_directory, 'static', 'runs',
                                      self.run_info['id'])
        os.mkdir(self.directory)

        self.do_all_images()

        if self.store:
            obj = self.db.get(self.run_info['id'])
            obj = self.db.get(self.run_info['id'])
            obj['endtime'] = datetime.now().isoformat()
            obj['status'] = "done"
            self.db.update(dict(obj))
Пример #18
0
def get_endpoint():
    return jsbridge.JSObject(jsbridge.network.bridge,
                             "Components.utils.import('%s')" %
                             ENDPOINT_URI).Endpoint
Пример #19
0
settings['MOZILLA_PLUGINS'].append(extension_path)

if __name__ == '__main__':
    result = {'is_successful': False}
    is_done = threading.Event()

    def listener(event_name, obj):
        if event_name == 'ubiquity:success':
            result['is_successful'] = obj
            is_done.set()

    jsbridge.events.add_global_listener(listener)

    moz = jsbridge.start_from_settings(settings)

    uri = 'resource://ubiquity/tests/systemtests.js'
    tests = jsbridge.JSObject(jsbridge.network.bridge,
                              "Components.utils.import('%s')" % uri)
    tests.start()

    is_done.wait(MAX_TIMEOUT)
    moz.stop()

    if result['is_successful']:
        print "Success!"
    else:
        print "Failure."
        if not is_done.isSet():
            print "Timeout occurred."
        sys.exit(-1)