diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebKitTools/WebKitTestRunner/InjectedBundle | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2 |
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'WebKitTools/WebKitTestRunner/InjectedBundle')
26 files changed, 0 insertions, 3529 deletions
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/ActivateFonts.h b/WebKitTools/WebKitTestRunner/InjectedBundle/ActivateFonts.h deleted file mode 100644 index 5ee1276..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/ActivateFonts.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ActivateFonts_h -#define ActivateFonts_h - -namespace WTR { - -void activateFonts(); - -} // namespace WTR - -#endif // ActivateFonts_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm deleted file mode 100644 index 0de2fd0..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm +++ /dev/null @@ -1,530 +0,0 @@ -# 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. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -# THE POSSIBILITY OF SUCH DAMAGE. - -use strict; -use warnings; -use File::Spec; - -package CodeGeneratorTestRunner; - -sub new -{ - my ($class, $codeGenerator, $outputDir) = @_; - - my $reference = { - codeGenerator => $codeGenerator, - outputDir => $outputDir, - }; - - bless($reference, $class); - return $reference; -} - -sub GenerateModule -{ -} - -sub GenerateInterface -{ - my ($self, $interface, $defines) = @_; - - foreach my $file ($self->_generateHeaderFile($interface), $self->_generateImplementationFile($interface)) { - open(FILE, ">", File::Spec->catfile($$self{outputDir}, $$file{name})) or die "Failed to open $$file{name} for writing: $!"; - print FILE @{$$file{contents}}; - close(FILE) or die "Failed to close $$file{name} after writing: $!"; - } -} - -sub finish -{ -} - -sub _className -{ - my ($idlType) = @_; - - return "JS" . _implementationClassName($idlType); -} - -sub _classRefGetter -{ - my ($self, $idlType) = @_; - return $$self{codeGenerator}->WK_lcfirst(_implementationClassName($idlType)) . "Class"; -} - -sub _fileHeaderString -{ - my ($filename) = @_; - - # FIXME: We should pull header out of the IDL file to get the copyright - # year(s) right. - return <<EOF; -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ -EOF -} - -sub _generateHeaderFile -{ - my ($self, $interface) = @_; - - my @contents = (); - - my $idlType = $interface->name; - my $className = _className($idlType); - my $implementationClassName = _implementationClassName($idlType); - my $filename = $className . ".h"; - - push(@contents, _fileHeaderString($filename)); - - my $parentClassName = _parentClassName($interface); - - push(@contents, <<EOF); - -#ifndef ${className}_h -#define ${className}_h - -#include "${parentClassName}.h" -EOF - push(@contents, <<EOF); - -namespace WTR { - -class ${implementationClassName}; - -class ${className} : public ${parentClassName} { -public: - static JSClassRef @{[$self->_classRefGetter($idlType)]}(); - -private: - static const JSStaticFunction* staticFunctions(); - static const JSStaticValue* staticValues(); -EOF - - if (my @functions = @{$interface->functions}) { - push(@contents, "\n // Functions\n\n"); - foreach my $function (@functions) { - push(@contents, " static JSValueRef @{[$function->signature->name]}(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef*);\n"); - } - } - - if (my @attributes = @{$interface->attributes}) { - push(@contents, "\n // Attributes\n\n"); - foreach my $attribute (@attributes) { - push(@contents, " static JSValueRef @{[$self->_getterName($attribute)]}(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*);\n"); - push(@contents, " static bool @{[$self->_setterName($attribute)]}(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSValueRef*);\n") unless $attribute->type =~ /^readonly/; - } - } - - push(@contents, <<EOF); -}; - -${implementationClassName}* to${implementationClassName}(JSContextRef, JSValueRef); - -} // namespace WTR - -#endif // ${className}_h -EOF - - return { name => $filename, contents => \@contents }; -} - -sub _generateImplementationFile -{ - my ($self, $interface) = @_; - - my @contentsPrefix = (); - my %contentsIncludes = (); - my @contents = (); - - my $idlType = $interface->name; - my $className = _className($idlType); - my $implementationClassName = _implementationClassName($idlType); - my $filename = $className . ".cpp"; - - push(@contentsPrefix, _fileHeaderString($filename)); - - my $classRefGetter = $self->_classRefGetter($idlType); - my $parentClassName = _parentClassName($interface); - - $contentsIncludes{"${className}.h"} = 1; - $contentsIncludes{"${implementationClassName}.h"} = 1; - - push(@contentsPrefix, <<EOF); - -EOF - - push(@contents, <<EOF); -#include <JavaScriptCore/JSRetainPtr.h> -#include <wtf/GetPtr.h> - -namespace WTR { - -${implementationClassName}* to${implementationClassName}(JSContextRef context, JSValueRef value) -{ - if (!context || !value || !${className}::${classRefGetter}() || !JSValueIsObjectOfClass(context, value, ${className}::${classRefGetter}())) - return 0; - return static_cast<${implementationClassName}*>(JSWrapper::unwrap(context, value)); -} - -JSClassRef ${className}::${classRefGetter}() -{ - static JSClassRef jsClass; - if (!jsClass) { - JSClassDefinition definition = kJSClassDefinitionEmpty; - definition.className = "${idlType}"; - definition.parentClass = @{[$self->_parentClassRefGetterExpression($interface)]}; - definition.staticValues = staticValues(); - definition.staticFunctions = staticFunctions(); -EOF - - push(@contents, " definition.initialize = initialize;\n") unless _parentInterface($interface); - push(@contents, " definition.finalize = finalize;\n") unless _parentInterface($interface); - - push(@contents, <<EOF); - jsClass = JSClassCreate(&definition); - } - return jsClass; -} - -EOF - - push(@contents, $self->_staticFunctionsGetterImplementation($interface), "\n"); - push(@contents, $self->_staticValuesGetterImplementation($interface)); - - if (my @functions = @{$interface->functions}) { - push(@contents, "\n// Functions\n"); - - foreach my $function (@functions) { - push(@contents, <<EOF); - -JSValueRef ${className}::@{[$function->signature->name]}(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - ${implementationClassName}* impl = to${implementationClassName}(context, thisObject); - if (!impl) - return JSValueMakeUndefined(context); - -EOF - my $functionCall; - if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - $functionCall = "impl->" . $function->signature->name . "(context, argumentCount, arguments, exception)"; - } else { - my @parameters = (); - my @specifiedParameters = @{$function->parameters}; - - $self->_includeHeaders(\%contentsIncludes, $function->signature->type, $function->signature); - - foreach my $i (0..$#specifiedParameters) { - my $parameter = $specifiedParameters[$i]; - - $self->_includeHeaders(\%contentsIncludes, $idlType, $parameter); - - push(@contents, " " . $self->_platformTypeVariableDeclaration($parameter, $parameter->name, "arguments[$i]", "argumentCount > $i") . "\n"); - - push(@parameters, $self->_parameterExpression($parameter)); - } - - $functionCall = "impl->" . $function->signature->name . "(" . join(", ", @parameters) . ")"; - } - - push(@contents, " ${functionCall};\n\n") if $function->signature->type eq "void"; - push(@contents, " return " . $self->_returnExpression($function->signature, $functionCall) . ";\n}\n"); - } - } - - if (my @attributes = @{$interface->attributes}) { - push(@contents, "\n// Attributes\n"); - foreach my $attribute (@attributes) { - $self->_includeHeaders(\%contentsIncludes, $attribute->signature->type, $attribute->signature); - - my $getterName = $self->_getterName($attribute); - my $getterExpression = "impl->${getterName}()"; - - push(@contents, <<EOF); - -JSValueRef ${className}::${getterName}(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef* exception) -{ - ${implementationClassName}* impl = to${implementationClassName}(context, object); - if (!impl) - return JSValueMakeUndefined(context); - - return @{[$self->_returnExpression($attribute->signature, $getterExpression)]}; -} -EOF - - unless ($attribute->type =~ /^readonly/) { - push(@contents, <<EOF); - -bool ${className}::@{[$self->_setterName($attribute)]}(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception) -{ - ${implementationClassName}* impl = to${implementationClassName}(context, object); - if (!impl) - return false; - -EOF - - my $platformValue = $self->_platformTypeConstructor($attribute->signature, "value"); - - push(@contents, <<EOF); - impl->@{[$self->_setterName($attribute)]}(${platformValue}); - - return true; -} -EOF - } - } - } - - push(@contents, <<EOF); - -} // namespace WTR - -EOF - - unshift(@contents, map { "#include \"$_\"\n" } sort keys(%contentsIncludes)); - unshift(@contents, @contentsPrefix); - - return { name => $filename, contents => \@contents }; -} - -sub _getterName -{ - my ($self, $attribute) = @_; - - my $signature = $attribute->signature; - my $name = $signature->name; - - return $name; -} - -sub _includeHeaders -{ - my ($self, $headers, $idlType, $signature) = @_; - - return unless defined $idlType; - return if $idlType eq "boolean"; - return if $idlType eq "object"; - return if $$self{codeGenerator}->IsNonPointerType($idlType); - return if $$self{codeGenerator}->IsStringType($idlType); - - $$headers{_className($idlType) . ".h"} = 1; - $$headers{_implementationClassName($idlType) . ".h"} = 1; -} - -sub _implementationClassName -{ - my ($idlType) = @_; - - return $idlType; -} - -sub _parentClassName -{ - my ($interface) = @_; - - my $parentInterface = _parentInterface($interface); - return $parentInterface ? _className($parentInterface) : "JSWrapper"; -} - -sub _parentClassRefGetterExpression -{ - my ($self, $interface) = @_; - - my $parentInterface = _parentInterface($interface); - return $parentInterface ? $self->_classRefGetter($parentInterface) . "()" : "0"; -} - -sub _parentInterface -{ - my ($interface) = @_; - return $interface->parents->[0]; -} - -sub _platformType -{ - my ($self, $idlType, $signature) = @_; - - return undef unless defined $idlType; - - return "bool" if $idlType eq "boolean"; - return "JSValueRef" if $idlType eq "object"; - return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType); - return "double" if $$self{codeGenerator}->IsNonPointerType($idlType); - return _implementationClassName($idlType); -} - -sub _platformTypeConstructor -{ - my ($self, $signature, $argumentName) = @_; - - my $idlType = $signature->type; - - return "JSValueToBoolean(context, $argumentName)" if $idlType eq "boolean"; - return "$argumentName" if $idlType eq "object"; - return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType); - return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType); - return "to" . _implementationClassName($idlType) . "(context, $argumentName)"; -} - -sub _platformTypeVariableDeclaration -{ - my ($self, $signature, $variableName, $argumentName, $condition) = @_; - - my $platformType = $self->_platformType($signature->type, $signature); - my $constructor = $self->_platformTypeConstructor($signature, $argumentName); - - my %nonPointerTypes = ( - "bool" => 1, - "double" => 1, - "JSRetainPtr<JSStringRef>" => 1, - "JSValueRef" => 1, - ); - - my $nullValue = "0"; - $nullValue = "$platformType()" if defined $nonPointerTypes{$platformType} && $platformType ne "double"; - - $platformType .= "*" unless defined $nonPointerTypes{$platformType}; - - return "$platformType $variableName = $condition && $constructor;" if $condition && $platformType eq "bool"; - return "$platformType $variableName = $condition ? $constructor : $nullValue;" if $condition; - return "$platformType $variableName = $constructor;"; -} - -sub _returnExpression -{ - my ($self, $signature, $expression) = @_; - - my $returnIDLType = $signature->type; - - return "JSValueMakeUndefined(context)" if $returnIDLType eq "void"; - return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType eq "boolean"; - return "${expression}" if $returnIDLType eq "object"; - return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType); - return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType); - return "toJS(context, WTF::getPtr(${expression}))"; -} - -sub _parameterExpression -{ - my ($self, $parameter) = @_; - - my $idlType = $parameter->type; - my $name = $parameter->name; - - return "${name}.get()" if $$self{codeGenerator}->IsStringType($idlType); - return $name; -} - -sub _setterName -{ - my ($self, $attribute) = @_; - - my $name = $attribute->signature->name; - - return "set" . $$self{codeGenerator}->WK_ucfirst($name); -} - -sub _staticFunctionsGetterImplementation -{ - my ($self, $interface) = @_; - - my $mapFunction = sub { - my $name = $_->signature->name; - my @attributes = qw(kJSPropertyAttributeDontDelete kJSPropertyAttributeReadOnly); - push(@attributes, "kJSPropertyAttributeDontEnum") if $_->signature->extendedAttributes->{"DontEnum"}; - - return "{ \"$name\", $name, " . join(" | ", @attributes) . " }"; - }; - - return $self->_staticFunctionsOrValuesGetterImplementation($interface, "function", "{ 0, 0, 0 }", $mapFunction, $interface->functions); -} - -sub _staticFunctionsOrValuesGetterImplementation -{ - my ($self, $interface, $functionOrValue, $arrayTerminator, $mapFunction, $functionsOrAttributes) = @_; - - my $className = _className($interface->name); - my $uppercaseFunctionOrValue = $$self{codeGenerator}->WK_ucfirst($functionOrValue); - - my $result = <<EOF; -const JSStatic${uppercaseFunctionOrValue}* ${className}::static${uppercaseFunctionOrValue}s() -{ -EOF - - my @initializers = map(&$mapFunction, @{$functionsOrAttributes}); - return $result . " return 0;\n}\n" unless @initializers; - - $result .= <<EOF - static const JSStatic${uppercaseFunctionOrValue} ${functionOrValue}s[] = { - @{[join(",\n ", @initializers)]}, - ${arrayTerminator} - }; - return ${functionOrValue}s; -} -EOF -} - -sub _staticValuesGetterImplementation -{ - my ($self, $interface) = @_; - - my $mapFunction = sub { - return if $_->signature->extendedAttributes->{"NoImplementation"}; - - my $attributeName = $_->signature->name; - my $attributeIsReadonly = $_->type =~ /^readonly/; - my $getterName = $self->_getterName($_); - my $setterName = $attributeIsReadonly ? "0" : $self->_setterName($_); - my @attributes = qw(kJSPropertyAttributeDontDelete); - push(@attributes, "kJSPropertyAttributeReadOnly") if $attributeIsReadonly; - push(@attributes, "kJSPropertyAttributeDontEnum") if $_->signature->extendedAttributes->{"DontEnum"}; - - return "{ \"$attributeName\", $getterName, $setterName, " . join(" | ", @attributes) . " }"; - }; - - return $self->_staticFunctionsOrValuesGetterImplementation($interface, "value", "{ 0, 0, 0, 0 }", $mapFunction, $interface->attributes); -} - -1; diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl deleted file mode 100644 index 1e47772..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -module WTR { - - interface EventSendingController { - [CustomArgumentHandling] void mouseDown(); - [CustomArgumentHandling] void mouseUp(); - [CustomArgumentHandling] void mouseMoveTo(); - [CustomArgumentHandling] void keyDown(); - [CustomArgumentHandling] void contextClick(); // CustomArgumentHandling only to throw exception while not implemented. - [CustomArgumentHandling] void leapForward(/*in unsigned long delay*/); // CustomArgumentHandling only to throw exception while not implemented. - - // Zoom functions. - void textZoomIn(); - void textZoomOut(); - void zoomPageIn(); - void zoomPageOut(); - }; - -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl deleted file mode 100644 index eb3ddee..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -module WTR { - - interface GCController { - void collect(); - void collectOnAlternateThread(in boolean waitUntilDone); - unsigned long long getJSObjectCount(); - }; - -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h deleted file mode 100644 index 5ec7197..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSWrappable_h -#define JSWrappable_h - -#include <JavaScriptCore/JavaScript.h> -#include <wtf/RefCounted.h> - -namespace WTR { - -class JSWrappable : public RefCounted<JSWrappable> { -public: - virtual ~JSWrappable() { } - virtual JSClassRef wrapperClass() = 0; -}; - -inline JSValueRef JSValueMakeStringOrNull(JSContextRef context, JSStringRef stringOrNull) -{ - return stringOrNull ? JSValueMakeString(context, stringOrNull) : JSValueMakeNull(context); -} - -} // namespace WTR - -#endif // JSWrappable_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp deleted file mode 100644 index a62cb2e..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "JSWrapper.h" - -#include <JavaScriptCore/JSContextRefPrivate.h> - -namespace WTR { - -JSValueRef JSWrapper::wrap(JSContextRef context, JSWrappable* object) -{ - ASSERT_ARG(context, context); - - if (!object) - return JSValueMakeNull(context); - - JSClassRef objectClass = object->wrapperClass(); - ASSERT(objectClass); - JSObjectRef wrapperObject = JSObjectMake(context, objectClass, object); - ASSERT(wrapperObject); - - return wrapperObject; -} - -JSWrappable* JSWrapper::unwrap(JSContextRef context, JSValueRef value) -{ - ASSERT_ARG(context, context); - ASSERT_ARG(value, value); - if (!context || !value) - return 0; - return static_cast<JSWrappable*>(JSObjectGetPrivate(JSValueToObject(context, value, 0))); -} - -static JSWrappable* unwrapObject(JSObjectRef object) -{ - JSWrappable* wrappable = static_cast<JSWrappable*>(JSObjectGetPrivate(object)); - ASSERT(wrappable); - return wrappable; -} - -void JSWrapper::initialize(JSContextRef ctx, JSObjectRef object) -{ - JSWrappable* wrappable = unwrapObject(object); - if (!wrappable) - return; - wrappable->ref(); -} - -void JSWrapper::finalize(JSObjectRef object) -{ - JSWrappable* wrappable = unwrapObject(object); - if (!wrappable) - return; - wrappable->deref(); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h deleted file mode 100644 index d885801..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSWrapper_h -#define JSWrapper_h - -#include "JSWrappable.h" -#include <JavaScriptCore/JSRetainPtr.h> - -namespace WTR { - -// FIXME: If necessary, we can do wrapper caching here. -class JSWrapper { -public: - static JSValueRef wrap(JSContextRef context, JSWrappable* object); - static JSWrappable* unwrap(JSContextRef context, JSValueRef value); - - static void initialize(JSContextRef, JSObjectRef); - static void finalize(JSObjectRef); -}; - -inline JSValueRef toJS(JSContextRef context, JSWrappable* impl) -{ - return JSWrapper::wrap(context, impl); -} - -inline void setProperty(JSContextRef context, JSObjectRef object, const char* propertyName, JSWrappable* value, JSPropertyAttributes attributes, JSValueRef* exception) -{ - JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName)); - JSObjectSetProperty(context, object, propertyNameString.get(), JSWrapper::wrap(context, value), attributes, exception); -} - -} // namespace WTR - -#endif // JSWrapper_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl deleted file mode 100644 index 583eb0a..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -module WTR { - - interface LayoutTestController { - // The basics. - void dumpAsText(); - void dumpChildFramesAsText(); - void waitUntilDone(); - void notifyDone(); - - // Other dumping. - void dumpBackForwardList(); - void dumpChildFrameScrollPositions(); - void dumpEditingCallbacks(); - void dumpSelectionRect(); - void dumpStatusCallbacks(); - void dumpTitleChanges(); - - // Special options. - void keepWebHistory(); - void setAcceptsEditing(in boolean value); - void setCanOpenWindows(in boolean value); - void setCloseRemainingWindowsWhenComplete(in boolean value); - void setXSSAuditorEnabled(in boolean value); - - // Special DOM functions. - void clearBackForwardList(); - object computedStyleIncludingVisitedInfo(in object element); - DOMString counterValueForElementById(in DOMString elementId); - void execCommand(in DOMString name, in DOMString argument); - boolean isCommandEnabled(in DOMString name); - DOMString markerTextForListItem(in object element); - unsigned long windowCount(); - - // Repaint testing. - void testRepaint(); - void repaintSweepHorizontally(); - void display(); - - // Animation testing. - int numberOfActiveAnimations(); - boolean pauseAnimationAtTimeOnElementWithId(in DOMString animationName, in double time, in DOMString elementId); - void suspendAnimations(); - void resumeAnimations(); - - // UserContent testing. - void addUserScript(in DOMString source, in boolean runAtStart, in boolean allFrames); - void addUserStyleSheet(in DOMString source, in boolean allFrames); - - // Compositing testing. - DOMString layerTreeAsText(); - }; - -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp deleted file mode 100644 index 73de45b..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "EventSendingController.h" - -#include "InjectedBundle.h" -#include "InjectedBundlePage.h" -#include "JSEventSendingController.h" -#include <WebKit2/WKBundlePage.h> -#include <WebKit2/WKBundlePagePrivate.h> -#include <WebKit2/WKBundlePrivate.h> - -namespace WTR { - -static const float ZoomMultiplierRatio = 1.2f; - -PassRefPtr<EventSendingController> EventSendingController::create() -{ - return adoptRef(new EventSendingController); -} - -EventSendingController::EventSendingController() -{ -} - -EventSendingController::~EventSendingController() -{ -} - -JSClassRef EventSendingController::wrapperClass() -{ - return JSEventSendingController::eventSendingControllerClass(); -} - -static void setExceptionForString(JSContextRef context, JSValueRef* exception, const char* string) -{ - JSRetainPtr<JSStringRef> exceptionString(Adopt, JSStringCreateWithUTF8CString(string)); - *exception = JSValueMakeString(context, exceptionString.get()); -} - -void EventSendingController::mouseDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.mouseDown is not yet supported."); -} - -void EventSendingController::mouseUp(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.mouseUp is not yet supported."); -} - -void EventSendingController::mouseMoveTo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.mouseMoveTo is not yet supported."); -} - -void EventSendingController::keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.keyDown is not yet supported."); -} - -void EventSendingController::contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.contextClick is not yet supported."); -} - -void EventSendingController::leapForward(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) -{ - setExceptionForString(context, exception, "EventSender.leapForward is not yet supported."); -} - -void EventSendingController::textZoomIn() -{ - // Ensure page zoom is reset. - WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), 1); - - double zoomFactor = WKBundlePageGetTextZoomFactor(InjectedBundle::shared().page()->page()); - WKBundlePageSetTextZoomFactor(InjectedBundle::shared().page()->page(), zoomFactor * ZoomMultiplierRatio); -} - -void EventSendingController::textZoomOut() -{ - // Ensure page zoom is reset. - WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), 1); - - double zoomFactor = WKBundlePageGetTextZoomFactor(InjectedBundle::shared().page()->page()); - WKBundlePageSetTextZoomFactor(InjectedBundle::shared().page()->page(), zoomFactor / ZoomMultiplierRatio); -} - -void EventSendingController::zoomPageIn() -{ - // Ensure text zoom is reset. - WKBundlePageSetTextZoomFactor(InjectedBundle::shared().page()->page(), 1); - - double zoomFactor = WKBundlePageGetPageZoomFactor(InjectedBundle::shared().page()->page()); - WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), zoomFactor * ZoomMultiplierRatio); -} - -void EventSendingController::zoomPageOut() -{ - // Ensure text zoom is reset. - WKBundlePageSetTextZoomFactor(InjectedBundle::shared().page()->page(), 1); - - double zoomFactor = WKBundlePageGetPageZoomFactor(InjectedBundle::shared().page()->page()); - WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), zoomFactor / ZoomMultiplierRatio); -} - -// Object Creation - -void EventSendingController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) -{ - setProperty(context, windowObject, "eventSender", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.h deleted file mode 100644 index 400f60d..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/EventSendingController.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef EventSendingController_h -#define EventSendingController_h - -#include "JSWrappable.h" -#include <wtf/PassRefPtr.h> - -namespace WTR { - -class EventSendingController : public JSWrappable { -public: - static PassRefPtr<EventSendingController> create(); - virtual ~EventSendingController(); - - void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception); - - // JSWrappable - virtual JSClassRef wrapperClass(); - - void mouseDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void mouseUp(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void mouseMoveTo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void keyDown(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void contextClick(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - void leapForward(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); - - // Zoom functions. - void textZoomIn(); - void textZoomOut(); - void zoomPageIn(); - void zoomPageOut(); - -private: - EventSendingController(); -}; - -} // namespace WTR - -#endif // EventSendingController_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.cpp deleted file mode 100644 index 0eba2df..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "GCController.h" - -#include "InjectedBundle.h" -#include "JSGCController.h" -#include <WebKit2/WKBundlePrivate.h> - -namespace WTR { - -PassRefPtr<GCController> GCController::create() -{ - return adoptRef(new GCController); -} - -GCController::GCController() -{ -} - -GCController::~GCController() -{ -} - -JSClassRef GCController::wrapperClass() -{ - return JSGCController::gCControllerClass(); -} - -void GCController::collect() -{ - WKBundleGarbageCollectJavaScriptObjects(InjectedBundle::shared().bundle()); -} - -void GCController::collectOnAlternateThread(bool waitUntilDone) -{ - WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(InjectedBundle::shared().bundle(), waitUntilDone); -} - -size_t GCController::getJSObjectCount() -{ - return WKBundleGetJavaScriptObjectsCount(InjectedBundle::shared().bundle()); -} - -// Object Creation - -void GCController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) -{ - setProperty(context, windowObject, "GCController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.h deleted file mode 100644 index 760fbb1..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/GCController.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCController_h -#define GCController_h - -#include "JSWrappable.h" -#include <wtf/PassRefPtr.h> - -namespace WTR { - -class GCController : public JSWrappable { -public: - static PassRefPtr<GCController> create(); - virtual ~GCController(); - - void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception); - - // JSWrappable - virtual JSClassRef wrapperClass(); - - void collect(); - void collectOnAlternateThread(bool waitUntilDone); - size_t getJSObjectCount(); - -private: - GCController(); -}; - -} // namespace WTR - -#endif // GCController_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp deleted file mode 100644 index 6bc1802..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "InjectedBundle.h" - -#include "ActivateFonts.h" -#include "InjectedBundlePage.h" -#include "StringFunctions.h" -#include <WebKit2/WKBundle.h> -#include <WebKit2/WKBundlePage.h> -#include <WebKit2/WKBundlePagePrivate.h> -#include <WebKit2/WKBundlePrivate.h> -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> -#include <wtf/PassOwnPtr.h> -#include <wtf/Vector.h> - -namespace WTR { - -InjectedBundle& InjectedBundle::shared() -{ - static InjectedBundle& shared = *new InjectedBundle; - return shared; -} - -InjectedBundle::InjectedBundle() - : m_bundle(0) - , m_state(Idle) -{ -} - -void InjectedBundle::didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) -{ - static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didCreatePage(page); -} - -void InjectedBundle::willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) -{ - static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page); -} - -void InjectedBundle::didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo) -{ - static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(messageName, messageBody); -} - -void InjectedBundle::initialize(WKBundleRef bundle) -{ - m_bundle = bundle; - - WKBundleClient client = { - 0, - this, - didCreatePage, - willDestroyPage, - didReceiveMessage - }; - WKBundleSetClient(m_bundle, &client); - - activateFonts(); - WKBundleActivateMacFontAscentHack(m_bundle); -} - -void InjectedBundle::didCreatePage(WKBundlePageRef page) -{ - m_pages.append(adoptPtr(new InjectedBundlePage(page))); -} - -void InjectedBundle::willDestroyPage(WKBundlePageRef page) -{ - size_t size = m_pages.size(); - for (size_t i = 0; i < size; ++i) { - if (m_pages[i]->page() == page) { - m_pages.remove(i); - break; - } - } -} - -InjectedBundlePage* InjectedBundle::page() const -{ - // It might be better to have the UI process send over a reference to the main - // page instead of just assuming it's the first one. - return m_pages[0].get(); -} - -void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) -{ - if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) { - ASSERT(!messageBody); - - WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack")); - WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); - WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get()); - - beginTesting(); - return; - } - - WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error")); - WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown")); - WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get()); -} - -void InjectedBundle::beginTesting() -{ - m_state = Testing; - - m_outputStream.str(""); - - m_layoutTestController = LayoutTestController::create(); - m_gcController = GCController::create(); - m_eventSendingController = EventSendingController::create(); - - WKBundleSetShouldTrackVisitedLinks(m_bundle, false); - WKBundleRemoveAllVisitedLinks(m_bundle); - - WKBundleRemoveAllUserContent(m_bundle); - - page()->reset(); -} - -void InjectedBundle::done() -{ - m_state = Stopping; - - page()->stopLoading(); - - WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done")); - WKRetainPtr<WKStringRef> doneMessageBody(AdoptWK, WKStringCreateWithUTF8CString(m_outputStream.str().c_str())); - - WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get()); - - m_state = Idle; -} - -void InjectedBundle::closeOtherPages() -{ - Vector<WKBundlePageRef> pagesToClose; - size_t size = m_pages.size(); - for (size_t i = 1; i < size; ++i) - pagesToClose.append(m_pages[i]->page()); - size = pagesToClose.size(); - for (size_t i = 0; i < size; ++i) - WKBundlePageClose(pagesToClose[i]); -} - -void InjectedBundle::dumpBackForwardListsForAllPages() -{ - size_t size = m_pages.size(); - for (size_t i = 0; i < size; ++i) - m_pages[i]->dumpBackForwardList(); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h deleted file mode 100644 index 2c6d14b..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InjectedBundle_h -#define InjectedBundle_h - -#include "EventSendingController.h" -#include "GCController.h" -#include "LayoutTestController.h" -#include <WebKit2/WKBase.h> -#include <wtf/OwnPtr.h> -#include <wtf/RefPtr.h> -#include <wtf/Vector.h> - -#include <sstream> - -namespace WTR { - -class InjectedBundlePage; - -class InjectedBundle { -public: - static InjectedBundle& shared(); - - // Initialize the InjectedBundle. - void initialize(WKBundleRef); - - WKBundleRef bundle() const { return m_bundle; } - - LayoutTestController* layoutTestController() { return m_layoutTestController.get(); } - GCController* gcController() { return m_gcController.get(); } - EventSendingController* eventSendingController() { return m_eventSendingController.get(); } - - InjectedBundlePage* page() const; - size_t pageCount() const { return m_pages.size(); } - void closeOtherPages(); - - void dumpBackForwardListsForAllPages(); - - void done(); - std::ostringstream& os() { return m_outputStream; } - - bool isTestRunning() { return m_state == Testing; } - -private: - InjectedBundle(); - ~InjectedBundle(); - - static void didCreatePage(WKBundleRef, WKBundlePageRef, const void* clientInfo); - static void willDestroyPage(WKBundleRef, WKBundlePageRef, const void* clientInfo); - static void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo); - - void didCreatePage(WKBundlePageRef); - void willDestroyPage(WKBundlePageRef); - void didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody); - - void beginTesting(); - - WKBundleRef m_bundle; - Vector<OwnPtr<InjectedBundlePage> > m_pages; - - RefPtr<LayoutTestController> m_layoutTestController; - RefPtr<GCController> m_gcController; - RefPtr<EventSendingController> m_eventSendingController; - - std::ostringstream m_outputStream; - - enum State { - Idle, - Testing, - Stopping - }; - State m_state; -}; - -} // namespace WTR - -#endif // InjectedBundle_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundleMain.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundleMain.cpp deleted file mode 100644 index c4cf892..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundleMain.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "InjectedBundle.h" -#include <WebKit2/WKBundleInitialize.h> - -#if defined(WIN32) || defined(_WIN32) -extern "C" __declspec(dllexport) -#else -extern "C" -#endif -void WKBundleInitialize(WKBundleRef bundle, WKTypeRef initializationUserData) -{ - WTR::InjectedBundle::shared().initialize(bundle); -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp deleted file mode 100644 index d852dd2..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ /dev/null @@ -1,901 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "InjectedBundlePage.h" - -#include "InjectedBundle.h" -#include "StringFunctions.h" -#include <cmath> -#include <JavaScriptCore/JSRetainPtr.h> -#include <WebKit2/WKArray.h> -#include <WebKit2/WKBundle.h> -#include <WebKit2/WKBundleBackForwardList.h> -#include <WebKit2/WKBundleBackForwardListItem.h> -#include <WebKit2/WKBundleFrame.h> -#include <WebKit2/WKBundleFramePrivate.h> -#include <WebKit2/WKBundlePagePrivate.h> - -using namespace std; - -namespace WTR { - -template<typename T> static inline WKRetainPtr<T> adoptWK(T item) -{ - return WKRetainPtr<T>(AdoptWK, item); -} - -static bool hasPrefix(const string& searchString, const string& prefix) -{ - return searchString.length() >= prefix.length() && searchString.substr(0, prefix.length()) == prefix; -} - -static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const char* propertyName) -{ - if (!object) - return 0; - JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName)); - return JSObjectGetProperty(context, object, propertyNameString.get(), 0); -} - -static double propertyValueDouble(JSContextRef context, JSObjectRef object, const char* propertyName) -{ - JSValueRef value = propertyValue(context, object, propertyName); - if (!value) - return 0; - return JSValueToNumber(context, value, 0); -} - -static int propertyValueInt(JSContextRef context, JSObjectRef object, const char* propertyName) -{ - return static_cast<int>(propertyValueDouble(context, object, propertyName)); -} - -static double numericWindowPropertyValue(WKBundleFrameRef frame, const char* propertyName) -{ - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame); - return propertyValueDouble(context, JSContextGetGlobalObject(context), propertyName); -} - -static string dumpPath(JSGlobalContextRef context, JSObjectRef nodeValue) -{ - JSValueRef nodeNameValue = propertyValue(context, nodeValue, "nodeName"); - JSRetainPtr<JSStringRef> jsStringNodeName(Adopt, JSValueToStringCopy(context, nodeNameValue, 0)); - WKRetainPtr<WKStringRef> nodeName = toWK(jsStringNodeName); - - JSValueRef parentNode = propertyValue(context, nodeValue, "parentNode"); - - ostringstream out; - out << nodeName; - - if (parentNode && JSValueIsObject(context, parentNode)) - out << " > " << dumpPath(context, (JSObjectRef)parentNode); - - return out.str(); -} - -static string dumpPath(WKBundlePageRef page, WKBundleScriptWorldRef world, WKBundleNodeHandleRef node) -{ - if (!node) - return "(null)"; - - WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); - - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world); - JSValueRef nodeValue = WKBundleFrameGetJavaScriptWrapperForNodeForWorld(frame, node, world); - ASSERT(JSValueIsObject(context, nodeValue)); - JSObjectRef nodeObject = (JSObjectRef)nodeValue; - - return dumpPath(context, nodeObject); -} - -static string toStr(WKBundlePageRef page, WKBundleScriptWorldRef world, WKBundleRangeHandleRef rangeRef) -{ - if (!rangeRef) - return "(null)"; - - WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); - - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world); - JSValueRef rangeValue = WKBundleFrameGetJavaScriptWrapperForRangeForWorld(frame, rangeRef, world); - ASSERT(JSValueIsObject(context, rangeValue)); - JSObjectRef rangeObject = (JSObjectRef)rangeValue; - - JSValueRef startNodeValue = propertyValue(context, rangeObject, "startContainer"); - ASSERT(JSValueIsObject(context, startNodeValue)); - JSObjectRef startNodeObject = (JSObjectRef)startNodeValue; - - JSValueRef endNodeValue = propertyValue(context, rangeObject, "endContainer"); - ASSERT(JSValueIsObject(context, endNodeValue)); - JSObjectRef endNodeObject = (JSObjectRef)endNodeValue; - - int startOffset = propertyValueInt(context, rangeObject, "startOffset"); - int endOffset = propertyValueInt(context, rangeObject, "endOffset"); - - ostringstream out; - out << "range from " << startOffset << " of " << dumpPath(context, startNodeObject) << " to " << endOffset << " of " << dumpPath(context, endNodeObject); - return out.str(); -} - -static ostream& operator<<(ostream& out, WKBundleCSSStyleDeclarationRef style) -{ - // DumpRenderTree calls -[DOMCSSStyleDeclaration description], which just dumps class name and object address. - // No existing tests actually hit this code path at the time of this writing, because WebCore doesn't call - // the editing client if the styling operation source is CommandFromDOM or CommandFromDOMWithUserInterface. - out << "<DOMCSSStyleDeclaration ADDRESS>"; - return out; -} - -static ostream& operator<<(ostream& out, WKBundleFrameRef frame) -{ - WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame)); - if (WKBundleFrameIsMainFrame(frame)) { - if (!WKStringIsEmpty(name.get())) - out << "main frame \"" << name << "\""; - else - out << "main frame"; - } else { - if (!WKStringIsEmpty(name.get())) - out << "frame \"" << name << "\""; - else - out << "frame (anonymous)"; - } - - return out; -} - -InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) - : m_page(page) - , m_world(AdoptWK, WKBundleScriptWorldCreateWorld()) - , m_isLoading(false) -{ - WKBundlePageLoaderClient loaderClient = { - 0, - this, - didStartProvisionalLoadForFrame, - didReceiveServerRedirectForProvisionalLoadForFrame, - didFailProvisionalLoadWithErrorForFrame, - didCommitLoadForFrame, - didFinishDocumentLoadForFrame, - didFinishLoadForFrame, - didFailLoadWithErrorForFrame, - didReceiveTitleForFrame, - 0, - 0, - 0, - didDisplayInsecureContentForFrame, - didRunInsecureContentForFrame, - didClearWindowForFrame, - didCancelClientRedirectForFrame, - willPerformClientRedirectForFrame, - didChangeLocationWithinPageForFrame, - didHandleOnloadEventsForFrame - }; - WKBundlePageSetLoaderClient(m_page, &loaderClient); - - WKBundlePageUIClient uiClient = { - 0, - this, - willAddMessageToConsole, - willSetStatusbarText, - willRunJavaScriptAlert, - willRunJavaScriptConfirm, - willRunJavaScriptPrompt, - 0, /*mouseDidMoveOverElement*/ - 0, /*pageDidScroll*/ - }; - WKBundlePageSetUIClient(m_page, &uiClient); - - WKBundlePageEditorClient editorClient = { - 0, - this, - shouldBeginEditing, - shouldEndEditing, - shouldInsertNode, - shouldInsertText, - shouldDeleteRange, - shouldChangeSelectedRange, - shouldApplyStyle, - didBeginEditing, - didEndEditing, - didChange, - didChangeSelection - }; - WKBundlePageSetEditorClient(m_page, &editorClient); -} - -InjectedBundlePage::~InjectedBundlePage() -{ -} - -void InjectedBundlePage::stopLoading() -{ - WKBundlePageStopLoading(m_page); - m_isLoading = false; -} - -void InjectedBundlePage::reset() -{ - WKBundlePageClearMainFrameName(m_page); - - WKBundlePageSetPageZoomFactor(m_page, 1); - WKBundlePageSetTextZoomFactor(m_page, 1); - - m_previousTestBackForwardListItem = adoptWK(WKBundleBackForwardListCopyItemAtIndex(WKBundlePageGetBackForwardList(m_page), 0)); -} - -// Loader Client Callbacks - -void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didStartProvisionalLoadForFrame(frame); -} - -void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveServerRedirectForProvisionalLoadForFrame(frame); -} - -void InjectedBundlePage::didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFailProvisionalLoadWithErrorForFrame(frame, error); -} - -void InjectedBundlePage::didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didCommitLoadForFrame(frame); -} - -void InjectedBundlePage::didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFinishLoadForFrame(frame); -} - -void InjectedBundlePage::didFinishDocumentLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFinishDocumentLoadForFrame(frame); -} - -void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didFailLoadWithErrorForFrame(frame, error); -} - -void InjectedBundlePage::didReceiveTitleForFrame(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveTitleForFrame(title, frame); -} - -void InjectedBundlePage::didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didClearWindowForFrame(frame, world); -} - -void InjectedBundlePage::didCancelClientRedirectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didCancelClientRedirectForFrame(frame); -} - -void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willPerformClientRedirectForFrame(frame, url, delay, date); -} - -void InjectedBundlePage::didChangeLocationWithinPageForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didChangeLocationWithinPageForFrame(frame); -} - -void InjectedBundlePage::didHandleOnloadEventsForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didHandleOnloadEventsForFrame(frame); -} - -void InjectedBundlePage::didDisplayInsecureContentForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didDisplayInsecureContentForFrame(frame); -} - -void InjectedBundlePage::didRunInsecureContentForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didRunInsecureContentForFrame(frame); -} - - -void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (frame == WKBundlePageGetMainFrame(m_page)) - m_isLoading = true; -} - -void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef frame) -{ -} - -void InjectedBundlePage::didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef error) -{ -} - -void InjectedBundlePage::didCommitLoadForFrame(WKBundleFrameRef frame) -{ -} - -enum FrameNamePolicy { ShouldNotIncludeFrameName, ShouldIncludeFrameName }; - -static void dumpFrameScrollPosition(WKBundleFrameRef frame, FrameNamePolicy shouldIncludeFrameName = ShouldNotIncludeFrameName) -{ - double x = numericWindowPropertyValue(frame, "pageXOffset"); - double y = numericWindowPropertyValue(frame, "pageYOffset"); - if (fabs(x) > 0.00000001 || fabs(y) > 0.00000001) { - if (shouldIncludeFrameName) { - WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame)); - InjectedBundle::shared().os() << "frame '" << name << "' "; - } - InjectedBundle::shared().os() << "scrolled to " << x << "," << y << "\n"; - } -} - -static void dumpDescendantFrameScrollPositions(WKBundleFrameRef frame) -{ - WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame)); - size_t size = WKArrayGetSize(childFrames.get()); - for (size_t i = 0; i < size; ++i) { - WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i)); - dumpFrameScrollPosition(subframe, ShouldIncludeFrameName); - dumpDescendantFrameScrollPositions(subframe); - } -} - -void InjectedBundlePage::dumpAllFrameScrollPositions() -{ - WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page); - dumpFrameScrollPosition(frame); - dumpDescendantFrameScrollPositions(frame); -} - -static JSRetainPtr<JSStringRef> toJS(const char* string) -{ - return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString(string)); -} - -static bool hasDocumentElement(WKBundleFrameRef frame) -{ - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame); - JSObjectRef globalObject = JSContextGetGlobalObject(context); - - JSValueRef documentValue = JSObjectGetProperty(context, globalObject, toJS("document").get(), 0); - if (!documentValue) - return false; - - ASSERT(JSValueIsObject(context, documentValue)); - JSObjectRef document = JSValueToObject(context, documentValue, 0); - - JSValueRef documentElementValue = JSObjectGetProperty(context, document, toJS("documentElement").get(), 0); - if (!documentElementValue) - return false; - - return JSValueToBoolean(context, documentElementValue); -} - -static void dumpFrameText(WKBundleFrameRef frame) -{ - // If the frame doesn't have a document element, its inner text will be an empty string, so - // we'll end up just appending a single newline below. But DumpRenderTree doesn't append - // anything in this case, so we shouldn't either. - if (!hasDocumentElement(frame)) - return; - - WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyInnerText(frame)); - InjectedBundle::shared().os() << text << "\n"; -} - -static void dumpDescendantFramesText(WKBundleFrameRef frame) -{ - WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame)); - size_t size = WKArrayGetSize(childFrames.get()); - for (size_t i = 0; i < size; ++i) { - WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i)); - WKRetainPtr<WKStringRef> subframeName(AdoptWK, WKBundleFrameCopyName(subframe)); - InjectedBundle::shared().os() << "\n--------\nFrame: '" << subframeName << "'\n--------\n"; - dumpFrameText(subframe); - dumpDescendantFramesText(subframe); - } -} - -void InjectedBundlePage::dumpAllFramesText() -{ - WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page); - dumpFrameText(frame); - dumpDescendantFramesText(frame); -} - -void InjectedBundlePage::dump() -{ - ASSERT(InjectedBundle::shared().isTestRunning()); - - InjectedBundle::shared().layoutTestController()->invalidateWaitToDumpWatchdogTimer(); - - switch (InjectedBundle::shared().layoutTestController()->whatToDump()) { - case LayoutTestController::RenderTree: { - WKRetainPtr<WKStringRef> text(AdoptWK, WKBundlePageCopyRenderTreeExternalRepresentation(m_page)); - InjectedBundle::shared().os() << text; - break; - } - case LayoutTestController::MainFrameText: - dumpFrameText(WKBundlePageGetMainFrame(m_page)); - break; - case LayoutTestController::AllFramesText: - dumpAllFramesText(); - break; - } - - if (InjectedBundle::shared().layoutTestController()->shouldDumpAllFrameScrollPositions()) - dumpAllFrameScrollPositions(); - else if (InjectedBundle::shared().layoutTestController()->shouldDumpMainFrameScrollPosition()) - dumpFrameScrollPosition(WKBundlePageGetMainFrame(m_page)); - - if (InjectedBundle::shared().layoutTestController()->shouldDumpBackForwardListsForAllWindows()) - InjectedBundle::shared().dumpBackForwardListsForAllPages(); - - InjectedBundle::shared().done(); -} - -void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (!WKBundleFrameIsMainFrame(frame)) - return; - - m_isLoading = false; - - if (this != InjectedBundle::shared().page()) - return; - - if (InjectedBundle::shared().layoutTestController()->waitToDump()) - return; - - dump(); -} - -void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (!WKBundleFrameIsMainFrame(frame)) - return; - - m_isLoading = false; - - if (this != InjectedBundle::shared().page()) - return; - - InjectedBundle::shared().done(); -} - -void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (!InjectedBundle::shared().layoutTestController()->shouldDumpTitleChanges()) - return; - - InjectedBundle::shared().os() << "TITLE CHANGED: " << title << "\n"; -} - -void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (WKBundleScriptWorldNormalWorld() != world) - return; - - JSGlobalContextRef context = WKBundleFrameGetJavaScriptContextForWorld(frame, world); - JSObjectRef window = JSContextGetGlobalObject(context); - - JSValueRef exception = 0; - InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception); - InjectedBundle::shared().gcController()->makeWindowObject(context, window, &exception); - InjectedBundle::shared().eventSendingController()->makeWindowObject(context, window, &exception); -} - -void InjectedBundlePage::didCancelClientRedirectForFrame(WKBundleFrameRef frame) -{ -} - -void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundleFrameRef frame, WKURLRef url, double delay, double date) -{ -} - -void InjectedBundlePage::didChangeLocationWithinPageForFrame(WKBundleFrameRef frame) -{ -} - -void InjectedBundlePage::didFinishDocumentLoadForFrame(WKBundleFrameRef frame) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - unsigned pendingFrameUnloadEvents = WKBundleFrameGetPendingUnloadCount(frame); - if (pendingFrameUnloadEvents) - InjectedBundle::shared().os() << frame << " - has " << pendingFrameUnloadEvents << " onunload handler(s)\n"; -} - -void InjectedBundlePage::didHandleOnloadEventsForFrame(WKBundleFrameRef frame) -{ -} - -void InjectedBundlePage::didDisplayInsecureContentForFrame(WKBundleFrameRef frame) -{ -} - -void InjectedBundlePage::didRunInsecureContentForFrame(WKBundleFrameRef frame) -{ -} - -// UI Client Callbacks - -void InjectedBundlePage::willAddMessageToConsole(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willAddMessageToConsole(message, lineNumber); -} - -void InjectedBundlePage::willSetStatusbarText(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willSetStatusbarText(statusbarText); -} - -void InjectedBundlePage::willRunJavaScriptAlert(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptAlert(message, frame); -} - -void InjectedBundlePage::willRunJavaScriptConfirm(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptConfirm(message, frame); -} - -void InjectedBundlePage::willRunJavaScriptPrompt(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void *clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptPrompt(message, defaultValue, frame); -} - -void InjectedBundlePage::willAddMessageToConsole(WKStringRef message, uint32_t lineNumber) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - // FIXME: Strip file: urls. - InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << message << "\n"; -} - -void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (!InjectedBundle::shared().layoutTestController()->shouldDumpStatusCallbacks()) - return; - - InjectedBundle::shared().os() << "UI DELEGATE STATUS CALLBACK: setStatusText:" << statusbarText << "\n"; -} - -void InjectedBundlePage::willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - InjectedBundle::shared().os() << "ALERT: " << message << "\n"; -} - -void InjectedBundlePage::willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - InjectedBundle::shared().os() << "CONFIRM: " << message << "\n"; -} - -void InjectedBundlePage::willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef) -{ - InjectedBundle::shared().os() << "PROMPT: " << message << ", default text: " << defaultValue << "\n"; -} - -// Editor Client Callbacks - -bool InjectedBundlePage::shouldBeginEditing(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldBeginEditing(range); -} - -bool InjectedBundlePage::shouldEndEditing(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldEndEditing(range); -} - -bool InjectedBundlePage::shouldInsertNode(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldInsertNode(node, rangeToReplace, action); -} - -bool InjectedBundlePage::shouldInsertText(WKBundlePageRef page, WKStringRef text, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldInsertText(text, rangeToReplace, action); -} - -bool InjectedBundlePage::shouldDeleteRange(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldDeleteRange(range); -} - -bool InjectedBundlePage::shouldChangeSelectedRange(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldChangeSelectedRange(fromRange, toRange, affinity, stillSelecting); -} - -bool InjectedBundlePage::shouldApplyStyle(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo) -{ - return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldApplyStyle(style, range); -} - -void InjectedBundlePage::didBeginEditing(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didBeginEditing(notificationName); -} - -void InjectedBundlePage::didEndEditing(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didEndEditing(notificationName); -} - -void InjectedBundlePage::didChange(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didChange(notificationName); -} - -void InjectedBundlePage::didChangeSelection(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo) -{ - static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didChangeSelection(notificationName); -} - -bool InjectedBundlePage::shouldBeginEditing(WKBundleRangeHandleRef range) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldBeginEditingInDOMRange:" << toStr(m_page, m_world.get(), range) << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldEndEditing(WKBundleRangeHandleRef range) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldEndEditingInDOMRange:" << toStr(m_page, m_world.get(), range) << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldInsertNode(WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - static const char* insertactionstring[] = { - "WebViewInsertActionTyped", - "WebViewInsertActionPasted", - "WebViewInsertActionDropped", - }; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertNode:" << dumpPath(m_page, m_world.get(), node) << " replacingDOMRange:" << toStr(m_page, m_world.get(), rangeToReplace) << " givenAction:" << insertactionstring[action] << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - static const char *insertactionstring[] = { - "WebViewInsertActionTyped", - "WebViewInsertActionPasted", - "WebViewInsertActionDropped", - }; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertText:" << text << " replacingDOMRange:" << toStr(m_page, m_world.get(), rangeToReplace) << " givenAction:" << insertactionstring[action] << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeHandleRef range) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << toStr(m_page, m_world.get(), range) << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - static const char *affinitystring[] = { - "NSSelectionAffinityUpstream", - "NSSelectionAffinityDownstream" - }; - static const char *boolstring[] = { - "FALSE", - "TRUE" - }; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldChangeSelectedDOMRange:" << toStr(m_page, m_world.get(), fromRange) << " toDOMRange:" << toStr(m_page, m_world.get(), toRange) << " affinity:" << affinitystring[affinity] << " stillSelecting:" << boolstring[stillSelecting] << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range) -{ - if (!InjectedBundle::shared().isTestRunning()) - return true; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << toStr(m_page, m_world.get(), range) << "\n"; - return InjectedBundle::shared().layoutTestController()->shouldAllowEditing(); -} - -void InjectedBundlePage::didBeginEditing(WKStringRef notificationName) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidBeginEditing:" << notificationName << "\n"; -} - -void InjectedBundlePage::didEndEditing(WKStringRef notificationName) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidEndEditing:" << notificationName << "\n"; -} - -void InjectedBundlePage::didChange(WKStringRef notificationName) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChange:" << notificationName << "\n"; -} - -void InjectedBundlePage::didChangeSelection(WKStringRef notificationName) -{ - if (!InjectedBundle::shared().isTestRunning()) - return; - - if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks()) - InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChangeSelection:" << notificationName << "\n"; -} - -static bool compareByTargetName(WKBundleBackForwardListItemRef item1, WKBundleBackForwardListItemRef item2) -{ - return toSTD(adoptWK(WKBundleBackForwardListItemCopyTarget(item1))) < toSTD(adoptWK(WKBundleBackForwardListItemCopyTarget(item2))); -} - -static void dumpBackForwardListItem(WKBundleBackForwardListItemRef item, unsigned indent, bool isCurrentItem) -{ - unsigned column = 0; - if (isCurrentItem) { - InjectedBundle::shared().os() << "curr->"; - column = 6; - } - for (unsigned i = column; i < indent; i++) - InjectedBundle::shared().os() << ' '; - - string url = toSTD(adoptWK(WKURLCopyString(adoptWK(WKBundleBackForwardListItemCopyURL(item)).get()))); - if (hasPrefix(url, "file:")) { - string directoryName = "/LayoutTests/"; - size_t start = url.find(directoryName); - if (start == string::npos) - start = 0; - else - start += directoryName.size(); - InjectedBundle::shared().os() << "(file test):" << url.substr(start); - } else - InjectedBundle::shared().os() << url; - - string target = toSTD(adoptWK(WKBundleBackForwardListItemCopyTarget(item))); - if (target.length()) - InjectedBundle::shared().os() << " (in frame \"" << target << "\")"; - - // FIXME: Need WKBackForwardListItemIsTargetItem. - if (WKBundleBackForwardListItemIsTargetItem(item)) - InjectedBundle::shared().os() << " **nav target**"; - - InjectedBundle::shared().os() << '\n'; - - if (WKRetainPtr<WKArrayRef> kids = adoptWK(WKBundleBackForwardListItemCopyChildren(item))) { - // Sort to eliminate arbitrary result ordering which defeats reproducible testing. - size_t size = WKArrayGetSize(kids.get()); - Vector<WKBundleBackForwardListItemRef> sortedKids(size); - for (size_t i = 0; i < size; ++i) - sortedKids[i] = static_cast<WKBundleBackForwardListItemRef>(WKArrayGetItemAtIndex(kids.get(), i)); - stable_sort(sortedKids.begin(), sortedKids.end(), compareByTargetName); - for (size_t i = 0; i < size; ++i) - dumpBackForwardListItem(sortedKids[i], indent + 4, false); - } -} - -void InjectedBundlePage::dumpBackForwardList() -{ - InjectedBundle::shared().os() << "\n============== Back Forward List ==============\n"; - - WKBundleBackForwardListRef list = WKBundlePageGetBackForwardList(m_page); - - // Print out all items in the list after m_previousTestBackForwardListItem. - // Gather items from the end of the list, then print them out from oldest to newest. - Vector<WKRetainPtr<WKBundleBackForwardListItemRef> > itemsToPrint; - for (unsigned i = WKBundleBackForwardListGetForwardListCount(list); i; --i) { - WKRetainPtr<WKBundleBackForwardListItemRef> item = adoptWK(WKBundleBackForwardListCopyItemAtIndex(list, i)); - // Something is wrong if the item from the last test is in the forward part of the list. - ASSERT(!WKBundleBackForwardListItemIsSame(item.get(), m_previousTestBackForwardListItem.get())); - itemsToPrint.append(item); - } - - ASSERT(!WKBundleBackForwardListItemIsSame(adoptWK(WKBundleBackForwardListCopyItemAtIndex(list, 0)).get(), m_previousTestBackForwardListItem.get())); - - itemsToPrint.append(adoptWK(WKBundleBackForwardListCopyItemAtIndex(list, 0))); - - int currentItemIndex = itemsToPrint.size() - 1; - - int backListCount = WKBundleBackForwardListGetBackListCount(list); - for (int i = -1; i >= -backListCount; --i) { - WKRetainPtr<WKBundleBackForwardListItemRef> item = adoptWK(WKBundleBackForwardListCopyItemAtIndex(list, i)); - if (WKBundleBackForwardListItemIsSame(item.get(), m_previousTestBackForwardListItem.get())) - break; - itemsToPrint.append(item); - } - - for (int i = itemsToPrint.size() - 1; i >= 0; i--) - dumpBackForwardListItem(itemsToPrint[i].get(), 8, i == currentItemIndex); - - InjectedBundle::shared().os() << "===============================================\n"; -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h deleted file mode 100644 index b95744f9..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef InjectedBundlePage_h -#define InjectedBundlePage_h - -#include <WebKit2/WKBundlePage.h> -#include <WebKit2/WKBundleScriptWorld.h> -#include <WebKit2/WKRetainPtr.h> - -namespace WTR { - -class InjectedBundlePage { -public: - InjectedBundlePage(WKBundlePageRef); - ~InjectedBundlePage(); - - WKBundlePageRef page() const { return m_page; } - void dump(); - - void stopLoading(); - bool isLoading() { return m_isLoading; } - - void reset(); - - void dumpBackForwardList(); - -private: - // Loader Client - static void didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef, WKBundleFrameRef, WKErrorRef, WKTypeRef*, const void*); - static void didCommitLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didFinishLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didFinishDocumentLoadForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didFailLoadWithErrorForFrame(WKBundlePageRef, WKBundleFrameRef, WKErrorRef, WKTypeRef*, const void*); - static void didReceiveTitleForFrame(WKBundlePageRef, WKStringRef title, WKBundleFrameRef, WKTypeRef*, const void*); - static void didClearWindowForFrame(WKBundlePageRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void*); - static void didCancelClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef, const void*); - static void willPerformClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef, WKURLRef url, double delay, double date, const void*); - static void didChangeLocationWithinPageForFrame(WKBundlePageRef, WKBundleFrameRef, const void*); - static void didHandleOnloadEventsForFrame(WKBundlePageRef, WKBundleFrameRef, const void*); - static void didDisplayInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - static void didRunInsecureContentForFrame(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void*); - void didStartProvisionalLoadForFrame(WKBundleFrameRef); - void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef); - void didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef, WKErrorRef); - void didCommitLoadForFrame(WKBundleFrameRef); - void didFinishLoadForFrame(WKBundleFrameRef); - void didFailLoadWithErrorForFrame(WKBundleFrameRef, WKErrorRef); - void didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef); - void didClearWindowForFrame(WKBundleFrameRef, WKBundleScriptWorldRef); - void didCancelClientRedirectForFrame(WKBundleFrameRef); - void willPerformClientRedirectForFrame(WKBundleFrameRef, WKURLRef url, double delay, double date); - void didChangeLocationWithinPageForFrame(WKBundleFrameRef); - void didFinishDocumentLoadForFrame(WKBundleFrameRef); - void didHandleOnloadEventsForFrame(WKBundleFrameRef); - void didDisplayInsecureContentForFrame(WKBundleFrameRef); - void didRunInsecureContentForFrame(WKBundleFrameRef); - - // UI Client - static void willAddMessageToConsole(WKBundlePageRef, WKStringRef message, uint32_t lineNumber, const void* clientInfo); - static void willSetStatusbarText(WKBundlePageRef, WKStringRef statusbarText, const void* clientInfo); - static void willRunJavaScriptAlert(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo); - static void willRunJavaScriptConfirm(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo); - static void willRunJavaScriptPrompt(WKBundlePageRef, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void* clientInfo); - void willAddMessageToConsole(WKStringRef message, uint32_t lineNumber); - void willSetStatusbarText(WKStringRef statusbarText); - void willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef); - void willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef); - void willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef); - - // Editor client - static bool shouldBeginEditing(WKBundlePageRef, WKBundleRangeHandleRef, const void* clientInfo); - static bool shouldEndEditing(WKBundlePageRef, WKBundleRangeHandleRef, const void* clientInfo); - static bool shouldInsertNode(WKBundlePageRef, WKBundleNodeHandleRef, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType, const void* clientInfo); - static bool shouldInsertText(WKBundlePageRef, WKStringRef, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType, const void* clientInfo); - static bool shouldDeleteRange(WKBundlePageRef, WKBundleRangeHandleRef, const void* clientInfo); - static bool shouldChangeSelectedRange(WKBundlePageRef, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType, bool stillSelecting, const void* clientInfo); - static bool shouldApplyStyle(WKBundlePageRef, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo); - static void didBeginEditing(WKBundlePageRef, WKStringRef notificationName, const void* clientInfo); - static void didEndEditing(WKBundlePageRef, WKStringRef notificationName, const void* clientInfo); - static void didChange(WKBundlePageRef, WKStringRef notificationName, const void* clientInfo); - static void didChangeSelection(WKBundlePageRef, WKStringRef notificationName, const void* clientInfo); - bool shouldBeginEditing(WKBundleRangeHandleRef); - bool shouldEndEditing(WKBundleRangeHandleRef); - bool shouldInsertNode(WKBundleNodeHandleRef, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType); - bool shouldInsertText(WKStringRef, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType); - bool shouldDeleteRange(WKBundleRangeHandleRef); - bool shouldChangeSelectedRange(WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType, bool stillSelecting); - bool shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range); - void didBeginEditing(WKStringRef notificationName); - void didEndEditing(WKStringRef notificationName); - void didChange(WKStringRef notificationName); - void didChangeSelection(WKStringRef notificationName); - - void dumpAllFramesText(); - void dumpAllFrameScrollPositions(); - - WKBundlePageRef m_page; - WKRetainPtr<WKBundleScriptWorldRef> m_world; - WKRetainPtr<WKBundleBackForwardListItemRef> m_previousTestBackForwardListItem; - bool m_isLoading; -}; - -} // namespace WTR - -#endif // InjectedBundlePage_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp deleted file mode 100644 index de37383..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "LayoutTestController.h" - -#include "InjectedBundle.h" -#include "InjectedBundlePage.h" -#include "JSLayoutTestController.h" -#include "StringFunctions.h" -#include <WebKit2/WKBundleBackForwardList.h> -#include <WebKit2/WKBundleFrame.h> -#include <WebKit2/WKBundleFramePrivate.h> -#include <WebKit2/WKBundlePagePrivate.h> -#include <WebKit2/WKBundleScriptWorld.h> -#include <WebKit2/WKBundlePrivate.h> -#include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> - -namespace WTR { - -// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures -// Eventually it should be changed to match. -const double LayoutTestController::waitToDumpWatchdogTimerInterval = 6; - -static JSValueRef propertyValue(JSContextRef context, JSObjectRef object, const char* propertyName) -{ - if (!object) - return 0; - JSRetainPtr<JSStringRef> propertyNameString(Adopt, JSStringCreateWithUTF8CString(propertyName)); - JSValueRef exception; - return JSObjectGetProperty(context, object, propertyNameString.get(), &exception); -} - -static JSObjectRef propertyObject(JSContextRef context, JSObjectRef object, const char* propertyName) -{ - JSValueRef value = propertyValue(context, object, propertyName); - if (!value || !JSValueIsObject(context, value)) - return 0; - return const_cast<JSObjectRef>(value); -} - -static JSObjectRef getElementById(WKBundleFrameRef frame, JSStringRef elementId) -{ - JSContextRef context = WKBundleFrameGetJavaScriptContext(frame); - JSObjectRef document = propertyObject(context, JSContextGetGlobalObject(context), "document"); - if (!document) - return 0; - JSValueRef getElementById = propertyObject(context, document, "getElementById"); - if (!getElementById || !JSValueIsObject(context, getElementById)) - return 0; - JSValueRef elementIdValue = JSValueMakeString(context, elementId); - JSValueRef exception; - JSValueRef element = JSObjectCallAsFunction(context, const_cast<JSObjectRef>(getElementById), document, 1, &elementIdValue, &exception); - if (!element || !JSValueIsObject(context, element)) - return 0; - return const_cast<JSObjectRef>(element); -} - -PassRefPtr<LayoutTestController> LayoutTestController::create() -{ - return adoptRef(new LayoutTestController); -} - -LayoutTestController::LayoutTestController() - : m_whatToDump(RenderTree) - , m_shouldDumpAllFrameScrollPositions(false) - , m_shouldDumpBackForwardListsForAllWindows(false) - , m_shouldAllowEditing(true) - , m_shouldCloseExtraWindows(false) - , m_dumpEditingCallbacks(false) - , m_dumpStatusCallbacks(false) - , m_dumpTitleChanges(false) - , m_waitToDump(false) - , m_testRepaint(false) - , m_testRepaintSweepHorizontally(false) -{ - platformInitialize(); -} - -LayoutTestController::~LayoutTestController() -{ -} - -JSClassRef LayoutTestController::wrapperClass() -{ - return JSLayoutTestController::layoutTestControllerClass(); -} - -void LayoutTestController::display() -{ - // FIXME: actually implement, once we want pixel tests -} - -void LayoutTestController::waitUntilDone() -{ - m_waitToDump = true; - initializeWaitToDumpWatchdogTimerIfNeeded(); -} - -void LayoutTestController::waitToDumpWatchdogTimerFired() -{ - invalidateWaitToDumpWatchdogTimer(); - const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; - InjectedBundle::shared().os() << message << "\n"; - InjectedBundle::shared().done(); -} - -void LayoutTestController::notifyDone() -{ - if (m_waitToDump && !InjectedBundle::shared().page()->isLoading()) - InjectedBundle::shared().page()->dump(); - m_waitToDump = false; -} - -unsigned LayoutTestController::numberOfActiveAnimations() const -{ - // FIXME: Is it OK this works only for the main frame? - // FIXME: If this is needed only for the main frame, then why is the function on WKBundleFrame instead of WKBundlePage? - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - return WKBundleFrameGetNumberOfActiveAnimations(mainFrame); -} - -bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId) -{ - // FIXME: Is it OK this works only for the main frame? - // FIXME: If this is needed only for the main frame, then why is the function on WKBundleFrame instead of WKBundlePage? - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - return WKBundleFramePauseAnimationOnElementWithId(mainFrame, toWK(animationName).get(), toWK(elementId).get(), time); -} - -void LayoutTestController::suspendAnimations() -{ - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - WKBundleFrameSuspendAnimations(mainFrame); -} - -void LayoutTestController::resumeAnimations() -{ - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - WKBundleFrameResumeAnimations(mainFrame); -} - -JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const -{ - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyLayerTreeAsText(mainFrame)); - return toJS(text); -} - -void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames) -{ - WKRetainPtr<WKStringRef> sourceWK = toWK(source); - WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); - - WKBundleAddUserScript(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, - (runAtStart ? kWKInjectAtDocumentStart : kWKInjectAtDocumentEnd), - (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); -} - -void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames) -{ - WKRetainPtr<WKStringRef> sourceWK = toWK(source); - WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); - - WKBundleAddUserStyleSheet(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, - (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); -} - -void LayoutTestController::keepWebHistory() -{ - WKBundleSetShouldTrackVisitedLinks(InjectedBundle::shared().bundle(), true); -} - -JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSValueRef element) -{ - // FIXME: Is it OK this works only for the main frame? - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); - if (!JSValueIsObject(context, element)) - return JSValueMakeUndefined(context); - JSValueRef value = WKBundleFrameGetComputedStyleIncludingVisitedInfo(mainFrame, const_cast<JSObjectRef>(element)); - if (!value) - return JSValueMakeUndefined(context); - return value; -} - -JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef elementId) -{ - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - JSObjectRef element = getElementById(mainFrame, elementId); - if (!element) - return 0; - WKRetainPtr<WKStringRef> value(AdoptWK, WKBundleFrameCopyCounterValue(mainFrame, const_cast<JSObjectRef>(element))); - return toJS(value); -} - -JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSValueRef element) -{ - WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); - JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame); - if (!element || !JSValueIsObject(context, element)) - return 0; - WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyMarkerText(mainFrame, const_cast<JSObjectRef>(element))); - if (WKStringIsEmpty(text.get())) - return 0; - return toJS(text); -} - -void LayoutTestController::execCommand(JSStringRef name, JSStringRef argument) -{ - WKBundlePageExecuteEditingCommand(InjectedBundle::shared().page()->page(), toWK(name).get(), toWK(argument).get()); -} - -bool LayoutTestController::isCommandEnabled(JSStringRef name) -{ - return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get()); -} - -void LayoutTestController::setCanOpenWindows(bool) -{ - // It's not clear if or why any tests require opening windows be forbidden. - // For now, just ignore this setting, and if we find later it's needed we can add it. -} - -void LayoutTestController::setXSSAuditorEnabled(bool enabled) -{ - WKBundleOverrideXSSAuditorEnabledForTestRunner(InjectedBundle::shared().bundle(), true); -} - -unsigned LayoutTestController::windowCount() -{ - return InjectedBundle::shared().pageCount(); -} - -void LayoutTestController::clearBackForwardList() -{ - WKBundleBackForwardListClear(WKBundlePageGetBackForwardList(InjectedBundle::shared().page()->page())); -} - -// Object Creation - -void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) -{ - setProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h deleted file mode 100644 index 427d05e..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LayoutTestController_h -#define LayoutTestController_h - -#include "JSWrappable.h" -#include <JavaScriptCore/JSRetainPtr.h> -#include <string> -#include <wtf/PassRefPtr.h> - -#if PLATFORM(MAC) -#include <wtf/RetainPtr.h> -typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef; -#elif PLATFORM(WIN) -typedef UINT_PTR PlatformTimerRef; -#elif PLATFORM(QT) -#include <QTimer> -typedef QTimer PlatformTimerRef; -#endif - -namespace WTR { - -class LayoutTestController : public JSWrappable { -public: - static PassRefPtr<LayoutTestController> create(); - virtual ~LayoutTestController(); - - // JSWrappable - virtual JSClassRef wrapperClass(); - - void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception); - - // The basics. - void dumpAsText() { m_whatToDump = MainFrameText; } - void dumpChildFramesAsText() { m_whatToDump = AllFramesText; } - void waitUntilDone(); - void notifyDone(); - - // Other dumping. - void dumpBackForwardList() { m_shouldDumpBackForwardListsForAllWindows = true; } - void dumpChildFrameScrollPositions() { m_shouldDumpAllFrameScrollPositions = true; } - void dumpEditingCallbacks() { m_dumpEditingCallbacks = true; } - void dumpSelectionRect() { } // Will need to do something when we support pixel tests. - void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; } - void dumpTitleChanges() { m_dumpTitleChanges = true; } - - // Special options. - void keepWebHistory(); - void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; } - void setCanOpenWindows(bool); - void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; } - void setXSSAuditorEnabled(bool); - - // Special DOM functions. - JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element); - JSRetainPtr<JSStringRef> counterValueForElementById(JSStringRef elementId); - void clearBackForwardList(); - void execCommand(JSStringRef name, JSStringRef argument); - bool isCommandEnabled(JSStringRef name); - JSRetainPtr<JSStringRef> markerTextForListItem(JSValueRef element); - unsigned windowCount(); - - // Repaint testing. - void testRepaint() { m_testRepaint = true; } - void repaintSweepHorizontally() { m_testRepaintSweepHorizontally = true; } - void display(); - - // Animation testing. - unsigned numberOfActiveAnimations() const; - bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId); - void suspendAnimations(); - void resumeAnimations(); - - // Compositing testing. - JSRetainPtr<JSStringRef> layerTreeAsText() const; - - // UserContent testing. - void addUserScript(JSStringRef source, bool runAtStart, bool allFrames); - void addUserStyleSheet(JSStringRef source, bool allFrames); - - enum WhatToDump { RenderTree, MainFrameText, AllFramesText }; - WhatToDump whatToDump() const { return m_whatToDump; } - - bool shouldDumpAllFrameScrollPositions() const { return m_shouldDumpAllFrameScrollPositions; } - bool shouldDumpBackForwardListsForAllWindows() const { return m_shouldDumpBackForwardListsForAllWindows; } - bool shouldDumpEditingCallbacks() const { return m_dumpEditingCallbacks; } - bool shouldDumpMainFrameScrollPosition() const { return m_whatToDump == RenderTree; } - bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; } - bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } - - bool waitToDump() const { return m_waitToDump; } - void waitToDumpWatchdogTimerFired(); - void invalidateWaitToDumpWatchdogTimer(); - - bool shouldAllowEditing() const { return m_shouldAllowEditing; } - - bool shouldCloseExtraWindowsAfterRunningTest() const { return m_shouldCloseExtraWindows; } - -private: - static const double waitToDumpWatchdogTimerInterval; - - LayoutTestController(); - - void platformInitialize(); - void initializeWaitToDumpWatchdogTimerIfNeeded(); - - WhatToDump m_whatToDump; - bool m_shouldDumpAllFrameScrollPositions; - bool m_shouldDumpBackForwardListsForAllWindows; - - bool m_shouldAllowEditing; - bool m_shouldCloseExtraWindows; - - bool m_dumpEditingCallbacks; - bool m_dumpStatusCallbacks; - bool m_dumpTitleChanges; - bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called. - bool m_testRepaint; - bool m_testRepaintSweepHorizontally; - - PlatformTimerRef m_waitToDumpWatchdogTimer; -}; - -} // namespace WTR - -#endif // LayoutTestController_h diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm b/WebKitTools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm deleted file mode 100644 index b5bc4a1..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ActivateFonts.h" - -#import <AppKit/AppKit.h> -#import <CoreFoundation/CoreFoundation.h> -#import <Foundation/Foundation.h> - -@interface WKTRFontActivatorDummyClass : NSObject -@end - -@implementation WKTRFontActivatorDummyClass -@end - -namespace WTR { - -void activateFonts() -{ - // Work around <rdar://problem/6698023> by activating fonts from disk - - static const char* fontFileNames[] = { - "AHEM____.TTF", - "ColorBits.ttf", - "WebKitWeightWatcher100.ttf", - "WebKitWeightWatcher200.ttf", - "WebKitWeightWatcher300.ttf", - "WebKitWeightWatcher400.ttf", - "WebKitWeightWatcher500.ttf", - "WebKitWeightWatcher600.ttf", - "WebKitWeightWatcher700.ttf", - "WebKitWeightWatcher800.ttf", - "WebKitWeightWatcher900.ttf", - 0 - }; - - NSMutableArray *fontURLs = [NSMutableArray array]; - NSURL *resourcesDirectory = [[NSBundle bundleForClass:[WKTRFontActivatorDummyClass class]] resourceURL]; - for (unsigned i = 0; fontFileNames[i]; ++i) { - NSURL *fontURL = [resourcesDirectory URLByAppendingPathComponent:[NSString stringWithUTF8String:fontFileNames[i]]]; - [fontURLs addObject:[fontURL absoluteURL]]; - } - - CFArrayRef errors = 0; - if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)fontURLs, kCTFontManagerScopeProcess, &errors)) { - NSLog(@"Failed to activate fonts: %@", errors); - CFRelease(errors); - exit(1); - } -} - -} - diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm b/WebKitTools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm deleted file mode 100644 index 2eb4d5b..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/mac/LayoutTestControllerMac.mm +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "LayoutTestController.h" - -#include "InjectedBundle.h" - -namespace WTR { - -void LayoutTestController::platformInitialize() -{ -} - -void LayoutTestController::invalidateWaitToDumpWatchdogTimer() -{ - if (!m_waitToDumpWatchdogTimer) - return; - - CFRunLoopTimerInvalidate(m_waitToDumpWatchdogTimer.get()); - m_waitToDumpWatchdogTimer = 0; -} - -static void waitUntilDoneWatchdogTimerFired(CFRunLoopTimerRef timer, void* info) -{ - InjectedBundle::shared().layoutTestController()->waitToDumpWatchdogTimerFired(); -} - -void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() -{ - if (m_waitToDumpWatchdogTimer) - return; - - m_waitToDumpWatchdogTimer.adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + waitToDumpWatchdogTimerInterval, 0, 0, 0, WTR::waitUntilDoneWatchdogTimerFired, NULL)); - CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_waitToDumpWatchdogTimer.get(), kCFRunLoopCommonModes); -} - -} // namespace WTR diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp deleted file mode 100644 index ec920dc..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) - * - * 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 SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ActivateFonts.h" - -#include <QByteArray> -#include <QDir> - -#ifdef Q_WS_X11 -#include <fontconfig/fontconfig.h> -#endif - -#include <limits.h> - -namespace WTR { - -void activateFonts() -{ -#if defined(Q_WS_X11) - static int numFonts = -1; - - // Some test cases may add or remove application fonts (via @font-face). - // Make sure to re-initialize the font set if necessary. - FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication); - if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts) - return; - - QByteArray fontDir = getenv("WEBKIT_TESTFONTS"); - if (fontDir.isEmpty() || !QDir(fontDir).exists()) { - fprintf(stderr, - "\n\n" - "----------------------------------------------------------------------\n" - "WEBKIT_TESTFONTS environment variable is not set correctly.\n" - "This variable has to point to the directory containing the fonts\n" - "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n" - "----------------------------------------------------------------------\n" - ); - exit(1); - } - char currentPath[PATH_MAX+1]; - if (!getcwd(currentPath, PATH_MAX)) - qFatal("Couldn't get current working directory"); - QByteArray configFile = currentPath; - FcConfig* config = FcConfigCreate(); - configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf"; - if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true)) - qFatal("Couldn't load font configuration file"); - if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data())) - qFatal("Couldn't add font dir!"); - FcConfigSetCurrent(config); - - appFontSet = FcConfigGetFonts(config, FcSetApplication); - numFonts = appFontSet->nfont; -#endif -} - -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro b/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro deleted file mode 100644 index 2b3cbaf..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/InjectedBundle.pro +++ /dev/null @@ -1,77 +0,0 @@ -TEMPLATE = lib - -isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../../.. - -CONFIG(standalone_package) { - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/../../../../WebCore/generated -} else { - isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = ../../../../WebCore/generated -} - -GENERATED_SOURCES_DIR = ../../generated - -SOURCES += \ - ../InjectedBundle.cpp \ - ../InjectedBundle.h \ - ../InjectedBundleMain.cpp \ - ../InjectedBundlePage.cpp \ - ../InjectedBundlePage.h \ - ../EventSendingController.cpp \ - ../EventSendingController.h \ - ../GCController.cpp \ - ../GCController.h \ - ../LayoutTestController.cpp \ - ../LayoutTestController.h \ - ../Bindings/JSWrapper.cpp \ - ActivateFontsQt.cpp \ - LayoutTestControllerQt.cpp \ - $$GENERATED_SOURCES_DIR/JSEventSendingController.cpp \ - $$GENERATED_SOURCES_DIR/JSGCController.cpp \ - $$GENERATED_SOURCES_DIR/JSLayoutTestController.cpp \ - -HEADERS += \ - ../ActivateFonts.h \ - ../EventSendingController.h \ - ../GCController.h \ - ../InjectedBundle.h \ - ../InjectedBundlePage.h \ - ../LayoutTestController.h \ - -!CONFIG(release, debug|release) { - OBJECTS_DIR = obj/debug -} else { # Release - OBJECTS_DIR = obj/release -} - -include(../../../../WebKit.pri) -include(../../../../JavaScriptCore/JavaScriptCore.pri) -addJavaScriptCoreLib(../../../../JavaScriptCore) -include(../../../../WebKit2/WebKit2.pri) -addWebKit2Lib(../../../../WebKit2) - -INCLUDEPATH += \ - $$PWD \ - $$PWD/.. \ - $$PWD/../.. \ - $$PWD/../Bindings \ - $$PWD/../../../../JavaScriptCore \ - $$PWD/../../../../JavaScriptCore/wtf \ - $$PWD/../../../../WebKit2 \ - $$PWD/../../../../WebKit2/Shared \ - $$GENERATED_SOURCES_DIR - -INCLUDEPATH += \ - $$OUTPUT_DIR/include \ - $$WC_GENERATED_SOURCES_DIR - -PREFIX_HEADER = $$PWD/../../WebKitTestRunnerPrefix.h -QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER" - -unix:!mac { - CONFIG += link_pkgconfig - PKGCONFIG += fontconfig -} - -TARGET = WTRInjectedBundle -DESTDIR = $$OUTPUT_DIR/lib -!CONFIG(standalone_package): CONFIG -= app_bundle diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp deleted file mode 100644 index b515326..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/qt/LayoutTestControllerQt.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 University of Szeged. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "LayoutTestController.h" - -#include "InjectedBundle.h" -#include <QObject> - -namespace WTR { - -class WatchdogTimerHelper : public QObject { - Q_OBJECT - -public: - static WatchdogTimerHelper* instance() - { - static WatchdogTimerHelper* theInstance = new WatchdogTimerHelper; - return theInstance; - } - -public slots: - void timerFired() - { - InjectedBundle::shared().layoutTestController()->waitToDumpWatchdogTimerFired(); - } - -private: - WatchdogTimerHelper() {} -}; - -void LayoutTestController::platformInitialize() -{ - QObject::connect(&m_waitToDumpWatchdogTimer, SIGNAL(timeout()), WatchdogTimerHelper::instance(), SLOT(timerFired())); -} - -void LayoutTestController::invalidateWaitToDumpWatchdogTimer() -{ - m_waitToDumpWatchdogTimer.stop(); -} - -void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() -{ - if (m_waitToDumpWatchdogTimer.isActive()) - return; - - m_waitToDumpWatchdogTimer.start(waitToDumpWatchdogTimerInterval * 1000); -} - -} // namespace WTR - -#include "LayoutTestControllerQt.moc" diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/win/ActivateFonts.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/win/ActivateFonts.cpp deleted file mode 100644 index d9f08c9..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/win/ActivateFonts.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "ActivateFonts.h" - -#include <string> -#include <wtf/Vector.h> - -static LPCWSTR fontsEnvironmentVariable = L"WEBKIT_TESTFONTS"; - -namespace WTR { - -using namespace std; - -static const wstring& fontsPath() -{ - static wstring path; - static bool initialized; - - if (initialized) - return path; - initialized = true; - - DWORD size = ::GetEnvironmentVariableW(fontsEnvironmentVariable, 0, 0); - Vector<WCHAR> buffer(size); - if (!::GetEnvironmentVariableW(fontsEnvironmentVariable, buffer.data(), buffer.size())) - return path; - - path = buffer.data(); - if (path[path.length() - 1] != '\\') - path.append(L"\\"); - - return path; -} - - -void activateFonts() -{ - static LPCWSTR fontsToInstall[] = { - TEXT("AHEM____.ttf"), - TEXT("Apple Chancery.ttf"), - TEXT("Courier Bold.ttf"), - TEXT("Courier.ttf"), - TEXT("Helvetica Bold Oblique.ttf"), - TEXT("Helvetica Bold.ttf"), - TEXT("Helvetica Oblique.ttf"), - TEXT("Helvetica.ttf"), - TEXT("Helvetica Neue Bold Italic.ttf"), - TEXT("Helvetica Neue Bold.ttf"), - TEXT("Helvetica Neue Condensed Black.ttf"), - TEXT("Helvetica Neue Condensed Bold.ttf"), - TEXT("Helvetica Neue Italic.ttf"), - TEXT("Helvetica Neue Light Italic.ttf"), - TEXT("Helvetica Neue Light.ttf"), - TEXT("Helvetica Neue UltraLight Italic.ttf"), - TEXT("Helvetica Neue UltraLight.ttf"), - TEXT("Helvetica Neue.ttf"), - TEXT("Lucida Grande.ttf"), - TEXT("Lucida Grande Bold.ttf"), - TEXT("Monaco.ttf"), - TEXT("Papyrus.ttf"), - TEXT("Times Bold Italic.ttf"), - TEXT("Times Bold.ttf"), - TEXT("Times Italic.ttf"), - TEXT("Times Roman.ttf"), - TEXT("WebKit Layout Tests 2.ttf"), - TEXT("WebKit Layout Tests.ttf"), - TEXT("WebKitWeightWatcher100.ttf"), - TEXT("WebKitWeightWatcher200.ttf"), - TEXT("WebKitWeightWatcher300.ttf"), - TEXT("WebKitWeightWatcher400.ttf"), - TEXT("WebKitWeightWatcher500.ttf"), - TEXT("WebKitWeightWatcher600.ttf"), - TEXT("WebKitWeightWatcher700.ttf"), - TEXT("WebKitWeightWatcher800.ttf"), - TEXT("WebKitWeightWatcher900.ttf") - }; - - wstring resourcesPath = fontsPath(); - - for (unsigned i = 0; i < ARRAYSIZE(fontsToInstall); ++i) - ::AddFontResourceExW(wstring(resourcesPath + fontsToInstall[i]).c_str(), FR_PRIVATE, 0); -} - -} diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp deleted file mode 100644 index 39cd727..0000000 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/win/LayoutTestControllerWin.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "LayoutTestController.h" - -#include "InjectedBundle.h" - -namespace WTR { - -void LayoutTestController::platformInitialize() -{ - m_waitToDumpWatchdogTimer = 0; -} - -void LayoutTestController::invalidateWaitToDumpWatchdogTimer() -{ - if (!m_waitToDumpWatchdogTimer) - return; - - ::KillTimer(0, m_waitToDumpWatchdogTimer); - m_waitToDumpWatchdogTimer = 0; -} - -static void CALLBACK waitToDumpWatchdogTimerFired(HWND, UINT, UINT_PTR, DWORD) -{ - InjectedBundle::shared().layoutTestController()->waitToDumpWatchdogTimerFired(); -} - -static const UINT_PTR waitToDumpWatchdogTimerIdentifier = 1; - -void LayoutTestController::initializeWaitToDumpWatchdogTimerIfNeeded() -{ - if (m_waitToDumpWatchdogTimer) - return; - - m_waitToDumpWatchdogTimer = ::SetTimer(0, waitToDumpWatchdogTimerIdentifier, waitToDumpWatchdogTimerInterval * 1000, WTR::waitToDumpWatchdogTimerFired); -} - -} // namespace WTR |