def METHOD_NAME(self, js_name):
    with open(os.path.join(TEST_DIR, js_name)) as f:
        js = f.read()
    # WebKit.run_javascript() needs some serializable return value
    js += '\ntrue\n'
    result = None
    def on_done(_group, name, value):
        # cockpit-client resets the value to '' initially, to guarantee that a Changed signal happens
        # even when two consecutive run-js calls have the same result
        v = value.get_string()
        if v == '':
            return
        nonlocal result
        result = v
    def on_timeout():
        nonlocal result
        result = "timed out waiting for JavaScript result"
    handler = self.win_actions.connect('action-state-changed::run-js', on_done)
    self.win_actions.activate_action("run-js", GLib.Variant.new_string(self.testlib + js))
    main = GLib.MainContext.default()
    GLib.timeout_add_seconds(JS_TIMEOUT, on_timeout)
    while not result:
        main.iteration(may_block=True)
    self.win_actions.disconnect(handler)
    return result