Bug 22602

Summary: Enable Java in DumpRenderTree
Product: WebKit Reporter: Pam Greene (IRC:pamg) <pam>
Component: Tools / TestsAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Hypothetical patch to allow Java to be enabled
none
proposed patch mrowe: review+

Description Pam Greene (IRC:pamg) 2008-12-02 14:17:55 PST
DumpRenderTree currently has Java disabled.  If it's enabled, however, and a test is run that contains an <applet> element, DRT hangs.

For a test case, see the new layout test java-applet-calls.html attached to bug 22601.
Comment 1 Pam Greene (IRC:pamg) 2008-12-02 14:23:18 PST
Created attachment 25682 [details]
Hypothetical patch to allow Java to be enabled

This patch would allow a layout test to enable Java by calling layoutTestController.setJavaEnabled(true). But when a test (specifically, the one in bug 22601) does that, DRT hangs.  (Commenting out the line in DumpRenderTreemac.mm that disables Java in the first place has the same effect, so I assume it has nothing to do with this patch itself.)

Java was disabled in DRT in r10323, but I don't see details about why, nor do I know where to start looking to track this down.  (Or if it's worth the effort.)
Comment 2 Alexey Proskuryakov 2010-02-23 16:14:49 PST
Created attachment 49339 [details]
proposed patch
Comment 3 Mark Rowe (bdash) 2010-02-23 17:00:50 PST
Comment on attachment 49339 [details]
proposed patch

> Index: WebKitTools/DumpRenderTree/DumpRenderTree.h
> ===================================================================
> --- WebKitTools/DumpRenderTree/DumpRenderTree.h	(revision 55174)
> +++ WebKitTools/DumpRenderTree/DumpRenderTree.h	(working copy)
> @@ -53,6 +53,7 @@ std::wstring urlSuitableForTestResult(co
>  class LayoutTestController;
>  
>  extern volatile bool done;
> +void exitApplicationRunLoop();

It looks like this is no longer used outside of DumpRenderTreeMac.mm.  It can be removed from this header and marked as static.

> Index: WebKitTools/DumpRenderTree/LayoutTestController.cpp
> ===================================================================
> --- WebKitTools/DumpRenderTree/LayoutTestController.cpp	(revision 55174)
> +++ WebKitTools/DumpRenderTree/LayoutTestController.cpp	(working copy)
> @@ -1278,6 +1278,15 @@ static JSValueRef apiTestNewWindowDataLo
>      return JSValueMakeUndefined(context);
>  }
>  
> +
> +static JSValueRef enableJavaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
> +{
> +    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
> +    controller->setJavaEnabled(true);
> +
> +    return JSValueMakeUndefined(context);
> +}

Can the tests make use of LayoutTestController.overridePreference rather than these Java-specific methods?  It is what is used to enable the WebGL preference in each of those tests.

> +void exitApplicationRunLoop()
> +{
> +    [[NSApplication sharedApplication] stop:nil];
> +    [[NSApplication sharedApplication] postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 windowNumber:0 context:0 subtype:0 data1:0 data2:0] atStart:NO];
> +}

The postEvent: call here is a little bit mysterious until you realize that the run loop is blocked waiting on an event.  A comment could make this less mysterious.

> Index: WebKitTools/Scripts/run-webkit-tests
> ===================================================================
> --- WebKitTools/Scripts/run-webkit-tests	(revision 55174)
> +++ WebKitTools/Scripts/run-webkit-tests	(working copy)
> @@ -398,6 +398,16 @@ $expectedDirectory = $ENV{"WebKitExpecte
>  $testResultsDirectory = File::Spec->rel2abs($testResultsDirectory);
>  my $testResults = File::Spec->catfile($testResultsDirectory, "results.html");
>  
> +if (isAppleMacWebKit()) {
> +    print STDERR "Compiling Java tests\n";
> +    my $javaTestsDirectory = catdir($testDirectory, "java");
> +
> +    if (system("/usr/bin/make -C $javaTestsDirectory")) {
> +        exit 1;
> +    }
> +}

This will break if $testDirectory happens to contain a space or shell meta-character.  You can avoid this by using: system “/usr/bin/make”, “-C”, $javaTestsDirectory

> +        * java/Makefile: Added. Compile all .java files in the directory.

Please make sure that you add .class files to the svn:ignore property.


> Index: LayoutTests/java/Makefile
> ===================================================================
> --- LayoutTests/java/Makefile	(revision 0)
> +++ LayoutTests/java/Makefile	(revision 0)
> @@ -0,0 +1,41 @@
> +# Copyright (C) 2010 Apple Inc. All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +#
> +# 1.  Redistributions of source code must retain the above copyright
> +#     notice, this list of conditions and the following disclaimer. 
> +# 2.  Redistributions in binary form must reproduce the above copyright
> +#     notice, this list of conditions and the following disclaimer in the
> +#     documentation and/or other materials provided with the distribution. 
> +# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
> +#     its contributors may be used to endorse or promote products derived
> +#     from this software without specific prior written permission. 

This looks like the old license header.

r=me, but I’d suggest checking whether you can use overridePreference rather than introducing a new call on LayoutTestController.
Comment 4 Alexey Proskuryakov 2010-02-23 17:23:39 PST
Committed <http://trac.webkit.org/changeset/55177>, addressing review comments. I forgot about overridePreference!