예제 #1
0
/*!
    Evaluates the JavaScript defined by \a scriptSource using this frame as context
    and returns the result of the last executed statement.

    \sa addToJavaScriptWindowObject(), javaScriptWindowObjectCleared()
*/
QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
{
    ScriptController *proxy = d->frame->script();
    QVariant rc;
    if (proxy) {
        JSC::JSValuePtr v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue();
        if (v) {
            int distance = 0;
            rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
        }
    }
    return rc;
}
예제 #2
0
bool InspectorClient::doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message)
{
    if (!frontendPage)
        return false;

    Frame* frame = frontendPage->mainFrame();
    if (!frame)
        return false;

    ScriptController* scriptController = frame->script();
    if (!scriptController)
        return false;

    String dispatchToFrontend = "InspectorFrontendAPI.dispatchMessageAsync(" + message + ");";

    // FIXME: This should execute the script in the appropriate world.
    scriptController->evaluate(ScriptSourceCode(dispatchToFrontend));
    return true;
}