示例#1
0
static JSValueRef console_getSharedValue(JSContextRef ctx, JSObjectRef thisObject, JSStringRef /*propertyName*/, JSValueRef* /*exception*/)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ConsoleClass()))
        return JSValueMakeUndefined(ctx);

    CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
    if (!dlg)
        return JSValueMakeUndefined(ctx);

    JSStringRef jsString = JSStringCreateWithBSTR(dlg->sharedString());
    JSValueRef jsValue = JSValueMakeString(ctx, jsString);
    JSStringRelease(jsString);

    return jsValue;
}
HRESULT STDMETHODCALLTYPE DRTDesktopNotificationPresenter::checkNotificationPermission(
        /* [in] */ BSTR origin, 
        /* [out, retval] */ int* result)
{
#if ENABLE(NOTIFICATIONS)
    JSStringRef jsOrigin = JSStringCreateWithBSTR(origin);
    bool allowed = ::gLayoutTestController->checkDesktopNotificationPermission(jsOrigin);

    if (allowed)
        *result = WebCore::NotificationPresenter::PermissionAllowed;
    else
        *result = WebCore::NotificationPresenter::PermissionDenied;

    JSStringRelease(jsOrigin);
#endif
    return S_OK;
}
示例#3
0
/**
 * The callback from JavaScriptCore.  We told JSC to call this function
 * whenever it sees "console.report".
 */
static JSValueRef console_report(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ConsoleClass()))
        return JSValueMakeUndefined(ctx);

    CallJSDlg* dlg = static_cast<CallJSDlg*>(JSObjectGetPrivate(thisObject));
    if (!dlg)
        return JSValueMakeUndefined(ctx);

    if (argumentCount)
        return JSValueMakeUndefined(ctx);

    JSStringRef jsString = JSStringCreateWithBSTR(dlg->sharedString());
    JSValueRef jsValue = JSValueMakeString(ctx, jsString);
    JSStringRelease(jsString);

    return jsValue;
}
HRESULT DRTDesktopNotificationPresenter::checkNotificationPermission(_In_ BSTR /*origin*/, _Out_ int* result)
{
    if (!result)
        return E_POINTER;

    *result = 0;

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    JSStringRef jsOrigin = JSStringCreateWithBSTR(origin);
    bool allowed = ::gTestRunner->checkDesktopNotificationPermission(jsOrigin);

    if (allowed)
        *result = WebCore::NotificationClient::PermissionAllowed;
    else
        *result = WebCore::NotificationClient::PermissionDenied;

    JSStringRelease(jsOrigin);
#endif
    return S_OK;
}