[webkit-dev] Calling JavaScript function from within DumpRenderTree

Chris Fleizach cfleizach at apple.com
Fri Jan 1 19:13:17 PST 2010

I need to have a layout test register a callback with DRT, then have that callback be called at the appropriate time (in order to test accessibility notifications)

I can't figure out the right incantations to do so. 

I'd like to do something like this in the LayoutTest

var addedNotification = liveRegion.addNotificationListener("ariaCallback");

then have a function in the test like

function ariaCallback(notification) {
   // do stuff with notification

DRT knows when to call this method, but I'm not sure how.. This is what I have so far, which does not work.

// The JavaScript callback we'll use when we get a notification
static JSStringRef AXNotificationFunctionCallback = 0;

static void _accessibilityNotificationCallback(id element, NSString* notification)
    if (!AXNotificationFunctionCallback)
    JSObjectRef function = JSObjectMakeFunction([mainFrame globalContext], NULL, 0, NULL, AXNotificationFunctionCallback, NULL, 1, NULL);
    JSValueRef argument = JSValueMakeString([mainFrame globalContext], JSStringCreateWithCFString((CFStringRef)notification));
    JSObjectCallAsFunction([mainFrame globalContext], function, NULL, 1, &argument, NULL);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100101/eeabb8c6/attachment.html>

More information about the webkit-dev mailing list