'Create a PAC resolver.
Args:
pac_str: JavaScript code containing PAC resolver.'

def __init__(self, pac_str):

    self._engine = QJSEngine()
    self._ctx = _PACContext(self._engine)
    self._engine.globalObject().setProperty('PAC', self._engine.newQObject(self._ctx))
    self._evaluate(_PACContext.JS_DEFINITIONS, 'pac_js_definitions')
    self._evaluate(utils.read_file('javascript/pac_utils.js'), 'pac_utils')
    proxy_config = self._engine.newObject()
    proxy_config.setProperty('bindings', self._engine.newObject())
    self._engine.globalObject().setProperty('ProxyConfig', proxy_config)
    self._evaluate(pac_str, 'pac')
    global_js_object = self._engine.globalObject()
    self._resolver = global_js_object.property('FindProxyForURL')
    if (not self._resolver.isCallable()):
        err = "Cannot    resolve    FindProxyForURL    function,    got    '{}'    instead"
        raise EvalProxyError(err.format(self._resolver.toString()))
