Bug 42327 - WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolatedWorld
Summary: WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolat...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2010-07-14 20:53 PDT by Maciej Stachowiak
Modified: 2011-01-20 09:16 PST (History)
3 users (show)

See Also:


Attachments
Patch (14.79 KB, patch)
2011-01-20 03:37 PST, Maciej Stachowiak
aroben: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Stachowiak 2010-07-14 20:53:03 PDT
WebKitTestRunner needs to support layoutTestController.evaluateScriptInIsolatedWorld
Comment 1 Maciej Stachowiak 2010-07-14 20:58:45 PDT
<rdar://problem/8193636>
Comment 2 Maciej Stachowiak 2011-01-20 03:37:51 PST
Created attachment 79574 [details]
Patch
Comment 3 Early Warning System Bot 2011-01-20 04:54:04 PST
Attachment 79574 [details] did not build on qt:
Build output: http://queues.webkit.org/results/7617214
Comment 4 Adam Roben (:aroben) 2011-01-20 08:22:30 PST
Comment on attachment 79574 [details]
Patch

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.
Comment 5 Andras Becsi 2011-01-20 08:31:42 PST
(In reply to comment #3)
> Attachment 79574 [details] did not build on qt:
> Build output: http://queues.webkit.org/results/7617214

It builds for me with a clean build, on the EWS the symbol seems to get stripped away somehow.
Adam's suggestion to touch some file would probably work, but I can force a clean build on the bot after the patch was landed.
Comment 6 Maciej Stachowiak 2011-01-20 09:16:17 PST
Committed r76259: <http://trac.webkit.org/changeset/76259>