[webkit-reviews] review granted: [Bug 42327] WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolatedWorld : [Attachment 79574] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 20 08:22:29 PST 2011


Adam Roben (aroben) <aroben at apple.com> has granted Maciej Stachowiak
<mjs at apple.com>'s request for review:
Bug 42327: WebKitTestRunner needs to support
layoutTestController.evaluateScriptInIsolatedWorld
https://bugs.webkit.org/show_bug.cgi?id=42327

Attachment 79574: Patch
https://bugs.webkit.org/attachment.cgi?id=79574&action=review

------- Additional Comments from Adam Roben (aroben) <aroben at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=79574&action=review

You could try to touch some file in JSC in this patch to make the Qt bots
rebuild. (It will help real people, too, not just the bots!)

> Source/WebKit2/WebProcess/WebPage/WebFrame.cpp:463
> +    if (!strcmp(globalObjectObj->classInfo()->className,
"JSDOMWindowShell")) {

An early-return here would be nicer, I think.

> Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:533
> +	   JSObjectSetProperty(context, window, JSRetainPtr<JSStringRef>(Adopt,
JSStringCreateWithUTF8CString("__worldID")).get(), JSValueMakeNumber(context,
LayoutTestController::worldIDForWorld(world)), kJSPropertyAttributeReadOnly,
0);

I think you can use the toJS helper function instead of calling
JSStringCreateWithUTF8CString.

> Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:328
> +unsigned LayoutTestController::worldIDForWorld(WKBundleScriptWorldRef world)

> +{
> +    WorldMap::const_iterator end = worldMap().end();
> +    for (WorldMap::const_iterator it = worldMap().begin(); it != end; ++it)
{
> +	   if (it->second == world)
> +	       return it->first;
> +    }
> +
> +    return 0;
> +}

Maybe someday we'll add a HashMap::findValue function that would do this for
you.

> Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:336
> +    WKBundleScriptWorldRef world;
> +    if (!worldID)
> +	   world = WKBundleScriptWorldCreateWorld();

Looks like you're leaking this newly-created world.

> Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:346
> +    WKBundleFrameRef frame = WKBundleFrameForJavaScriptContext(context);
> +    if (!frame)
> +	   frame =
WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());

DumpRenderTree only ever evaluates the script in the main frame. I guess this
is an improvement, though it could lead to confusing differences in tests that
try to evaluate script in a subframe.


More information about the webkit-reviews mailing list