diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
| commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
| tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Tools/WebKitTestRunner/InjectedBundle/Bindings | |
| parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
| download | WebKitGtk-tarball-master.tar.gz | |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle/Bindings')
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityController.idl (renamed from Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h) | 50 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarker.idl | 29 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarkerRange.idl | 29 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl | 249 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm | 577 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl | 72 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl (renamed from Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h) | 24 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp | 80 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl | 262 | ||||
| -rw-r--r-- | Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl | 32 |
10 files changed, 1273 insertions, 131 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityController.idl index d885801b9..d50a2033f 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.h +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityController.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2011 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,35 +23,23 @@ * 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); +interface AccessibilityController { + void enableEnhancedAccessibility(boolean enable); + readonly attribute boolean enhancedAccessibilityEnabled; + + readonly attribute DOMString platformName; + readonly attribute AccessibilityUIElement rootElement; + readonly attribute AccessibilityUIElement focusedElement; + AccessibilityUIElement elementAtPoint(long x, long y); + AccessibilityUIElement accessibleElementById(DOMString id); + + boolean addNotificationListener(object functionCallback); + boolean removeNotificationListener(); + + void logFocusEvents(); + void logValueChangeEvents(); + void logScrollingStartEvents(); + void logAccessibilityEvents(); + void resetToConsistentState(); }; -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/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarker.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarker.idl new file mode 100644 index 000000000..149c95f34 --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarker.idl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2011 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. + */ + +interface AccessibilityTextMarker { + boolean isEqual(AccessibilityTextMarker otherMarker); +}; + diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarkerRange.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarkerRange.idl new file mode 100644 index 000000000..962c584e6 --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityTextMarkerRange.idl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2011 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. + */ + +interface AccessibilityTextMarkerRange { + boolean isEqual(AccessibilityTextMarkerRange otherMarkerRange); +}; + diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl new file mode 100644 index 000000000..967cb975d --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2011 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. + */ + +interface AccessibilityUIElement { + boolean isEqual(AccessibilityUIElement otherElement); + + // Document information + readonly attribute DOMString documentEncoding; + readonly attribute DOMString documentURI; + + // Element access. + AccessibilityUIElement elementAtPoint(long x, long y); + AccessibilityUIElement childAtIndex(unsigned long index); + unsigned long indexOfChild(AccessibilityUIElement child); + AccessibilityUIElement linkedUIElementAtIndex(unsigned long index); + AccessibilityUIElement selectedChildAtIndex(unsigned long index); + void setSelectedChild(AccessibilityUIElement element); + void setSelectedChildAtIndex(unsigned long index); + void removeSelectionAtIndex(unsigned long index); + void clearSelectedChildren(); + AccessibilityUIElement titleUIElement(); + AccessibilityUIElement parentElement(); + + readonly attribute DOMString role; + readonly attribute DOMString subrole; + readonly attribute DOMString roleDescription; + readonly attribute DOMString computedRoleString; + readonly attribute DOMString title; + readonly attribute DOMString description; + readonly attribute DOMString language; + readonly attribute DOMString helpText; + readonly attribute DOMString valueDescription; + readonly attribute DOMString url; + readonly attribute DOMString speak; + readonly attribute DOMString orientation; + readonly attribute long insertionPointLineNumber; + readonly attribute DOMString selectedTextRange; + + DOMString stringAttributeValue(DOMString attr); + double numberAttributeValue(DOMString attr); + object uiElementArrayAttributeValue(DOMString attr); + AccessibilityUIElement uiElementAttributeValue(DOMString attr); + boolean boolAttributeValue(DOMString attr); + void setBoolAttributeValue(DOMString attr, boolean value); + boolean isAttributeSupported(DOMString attr); + boolean isAttributeSettable(DOMString attr); + boolean isPressActionSupported(); + boolean isIncrementActionSupported(); + boolean isDecrementActionSupported(); + + readonly attribute DOMString stringValue; + readonly attribute long intValue; + readonly attribute long minValue; + readonly attribute long maxValue; + + readonly attribute boolean isEnabled; + readonly attribute boolean isRequired; + readonly attribute boolean isFocused; + readonly attribute boolean isFocusable; + readonly attribute boolean isSelectable; + readonly attribute boolean isSelected; + readonly attribute boolean isSelectedOptionActive; + readonly attribute boolean isMultiSelectable; + readonly attribute boolean isExpanded; + readonly attribute boolean isChecked; + readonly attribute boolean isIndeterminate; + readonly attribute boolean isVisible; + readonly attribute boolean isCollapsed; + readonly attribute boolean hasPopup; + readonly attribute boolean isIgnored; + readonly attribute boolean isSingleLine; + readonly attribute boolean isMultiLine; + readonly attribute boolean isOffScreen; + readonly attribute boolean isValid; + readonly attribute long hierarchicalLevel; + readonly attribute boolean ariaIsGrabbed; + readonly attribute DOMString ariaDropEffects; + readonly attribute DOMString classList; + + readonly attribute long x; + readonly attribute long y; + readonly attribute long width; + readonly attribute long height; + readonly attribute long clickPointX; + readonly attribute long clickPointY; + + readonly attribute long childrenCount; + readonly attribute long selectedChildrenCount; + readonly attribute long rowCount; + readonly attribute long columnCount; + + // Actions. + void increment(); + void decrement(); + void press(); + void showMenu(); + + // Attribute info. + DOMString allAttributes(); + DOMString attributesOfChildren(); + DOMString attributesOfLinkedUIElements(); + DOMString attributesOfDocumentLinks(); + + // Text info. + DOMString characterAtOffset(long offset); + DOMString wordAtOffset(long offset); + DOMString lineAtOffset(long offset); + DOMString sentenceAtOffset(long offset); + + // Table info. + DOMString attributesOfColumnHeaders(); + DOMString attributesOfRowHeaders(); + DOMString attributesOfColumns(); + DOMString attributesOfRows(); + DOMString attributesOfVisibleCells(); + DOMString attributesOfHeader(); + AccessibilityUIElement cellForColumnAndRow(unsigned long column, unsigned long row); + AccessibilityUIElement selectedRowAtIndex(unsigned long index); + AccessibilityUIElement disclosedByRow(); + AccessibilityUIElement disclosedRowAtIndex(unsigned long index); + AccessibilityUIElement rowAtIndex(unsigned long index); + long indexInTable(); + DOMString rowIndexRange(); + DOMString columnIndexRange(); + long rowCount(); + long columnCount(); + object columnHeaders(); + object rowHeaders(); + + AccessibilityUIElement ariaOwnsElementAtIndex(unsigned long index); + AccessibilityUIElement ariaFlowToElementAtIndex(unsigned long index); + AccessibilityUIElement ariaControlsElementAtIndex(unsigned long index); + + // Paramaterized attributes. + DOMString parameterizedAttributeNames(); + long lineForIndex(long index); + DOMString rangeForLine(long index); + DOMString rangeForPosition(long x, long y); + DOMString boundsForRange(unsigned long location, unsigned long length); + DOMString stringForRange(unsigned long location, unsigned long length); + DOMString attributedStringForRange(unsigned long location, unsigned long length); + boolean attributedStringRangeIsMisspelled(unsigned long location, unsigned long length); + [PassContext] unsigned long uiElementCountForSearchPredicate(AccessibilityUIElement startElement, boolean isDirectionNext, object searchKey, DOMString searchText, boolean visibleOnly, boolean immediateDescendantsOnly); + [PassContext] AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement startElement, boolean isDirectionNext, object searchKey, DOMString searchText, boolean visibleOnly, boolean immediateDescendantsOnly); + [PassContext] DOMString selectTextWithCriteria(DOMString ambiguityResolution, object searchStrings, DOMString replacementString, DOMString activity); + boolean setSelectedTextRange(unsigned long location, unsigned long length); + + // Scroll area attributes. + readonly attribute AccessibilityUIElement horizontalScrollbar; + readonly attribute AccessibilityUIElement verticalScrollbar; + + void scrollToMakeVisible(); + void scrollToGlobalPoint(long x, long y); + void scrollToMakeVisibleWithSubFocus(long x, long y, long width, long height); + + void takeFocus(); + boolean scrollPageDown(); + boolean scrollPageUp(); + boolean scrollPageLeft(); + boolean scrollPageRight(); + + // Text markers. + AccessibilityTextMarkerRange lineTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement element); + AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker startMarker, AccessibilityTextMarker endMarker); + AccessibilityTextMarkerRange selectedTextMarkerRange(); + void resetSelectedTextMarkerRange(); + AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange range); + AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange range); + AccessibilityTextMarker endTextMarkerForBounds(long x, long y, long width, long height); + AccessibilityTextMarker startTextMarkerForBounds(long x, long y, long width, long height); + AccessibilityTextMarker textMarkerForPoint(long x, long y); + AccessibilityTextMarker previousTextMarker(AccessibilityTextMarker marker); + AccessibilityTextMarker nextTextMarker(AccessibilityTextMarker marker); + AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker marker); + DOMString stringForTextMarkerRange(AccessibilityTextMarkerRange range); + long textMarkerRangeLength(AccessibilityTextMarkerRange range); + boolean attributedStringForTextMarkerRangeContainsAttribute(DOMString attr, AccessibilityTextMarkerRange range); + long indexForTextMarker(AccessibilityTextMarker marker); + boolean isTextMarkerValid(AccessibilityTextMarker marker); + AccessibilityTextMarker textMarkerForIndex(long textIndex); + readonly attribute AccessibilityTextMarker startTextMarker; + readonly attribute AccessibilityTextMarker endTextMarker; + boolean setSelectedVisibleTextRange(AccessibilityTextMarkerRange range); + AccessibilityTextMarkerRange leftWordTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarkerRange rightWordTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker previousWordStartTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker nextWordEndTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarkerRange paragraphTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker previousParagraphStartTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker nextParagraphEndTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarkerRange sentenceTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker previousSentenceStartTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + AccessibilityTextMarker nextSentenceEndTextMarkerForTextMarker(AccessibilityTextMarker textMarker); + + // Returns an ordered list of supported actions for an element. + readonly attribute DOMString supportedActions; + readonly attribute DOMString mathPostscriptsDescription; + readonly attribute DOMString mathPrescriptsDescription; + + readonly attribute DOMString pathDescription; + + // iOS specific accessibility methods. + readonly attribute DOMString identifier; + readonly attribute DOMString traits; + readonly attribute long elementTextPosition; + readonly attribute long elementTextLength; + readonly attribute DOMString stringForSelection; + object elementsForRange(unsigned long location, unsigned long length); + void increaseTextSelection(); + void decreaseTextSelection(); + AccessibilityUIElement linkedElement(); + AccessibilityUIElement headerElementAtIndex(unsigned long index); + // This will simulate the accessibilityDidBecomeFocused API in UIKit. + void assistiveTechnologySimulatedFocus(); + readonly attribute boolean isSearchField; + readonly attribute boolean isTextArea; + + // Fieldset + readonly attribute boolean hasContainedByFieldsetTrait; + AccessibilityUIElement fieldsetAncestorElement(); + + // Notification support. + boolean addNotificationListener(object callbackFunction); + boolean removeNotificationListener(); +}; + diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm new file mode 100644 index 000000000..98d37dab9 --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm @@ -0,0 +1,577 @@ +# Copyright (C) 2010 Apple Inc. All rights reserved. +# Copyright (C) 2012 Samsung Electronics +# +# 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; + +use Carp qw<longmess>; +use Data::Dumper; + +sub assert +{ + my $message = shift; + + my $mess = longmess(); + print Dumper($mess); + + die $message; +} + +sub new +{ + my ($class, $codeGenerator, $writeDependencies, $verbose, $idlFilePath) = @_; + + my $reference = { + codeGenerator => $codeGenerator, + idlFilePath => $idlFilePath, + }; + + bless($reference, $class); + return $reference; +} + +sub GenerateInterface +{ +} + +sub WriteData +{ + my ($self, $interface, $outputDir) = @_; + + foreach my $file ($self->_generateHeaderFile($interface), $self->_generateImplementationFile($interface)) { + $$self{codeGenerator}->UpdateFile(File::Spec->catfile($outputDir, $$file{name}), join("", @{$$file{contents}})); + } +} + +sub _className +{ + my ($type) = @_; + + return "JS" . _implementationClassName($type); +} + +sub _classRefGetter +{ + my ($self, $type) = @_; + + return $$self{codeGenerator}->WK_lcfirst(_implementationClassName($type)) . "Class"; +} + +sub _parseLicenseBlock +{ + my ($fileHandle) = @_; + + my ($copyright, $readCount, $buffer, $currentCharacter, $previousCharacter); + my $startSentinel = "/*"; + my $lengthOfStartSentinel = length($startSentinel); + $readCount = read($fileHandle, $buffer, $lengthOfStartSentinel); + return "" if ($readCount < $lengthOfStartSentinel || $buffer ne $startSentinel); + $copyright = $buffer; + + while ($readCount = read($fileHandle, $currentCharacter, 1)) { + $copyright .= $currentCharacter; + return $copyright if $currentCharacter eq "/" && $previousCharacter eq "*"; + $previousCharacter = $currentCharacter; + } + + return ""; +} + +sub _parseLicenseBlockFromFile +{ + my ($path) = @_; + open my $fileHandle, "<", $path or die "Failed to open $path for reading: $!"; + my $licenseBlock = _parseLicenseBlock($fileHandle); + close($fileHandle); + return $licenseBlock; +} + +sub _defaultLicenseBlock +{ + 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 _licenseBlock +{ + my ($self) = @_; + return $self->{licenseBlock} if $self->{licenseBlock}; + + my $licenseBlock = _parseLicenseBlockFromFile($self->{idlFilePath}) || _defaultLicenseBlock(); + $self->{licenseBlock} = $licenseBlock; + return $licenseBlock; +} + +sub _generateHeaderFile +{ + my ($self, $interface) = @_; + + my @contents = (); + + my $type = $interface->type; + my $className = _className($type); + my $implementationClassName = _implementationClassName($type); + my $filename = $className . ".h"; + + push(@contents, $self->_licenseBlock()); + + 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($type)]}(); + +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->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->isReadOnly; + } + } + + 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 $type = $interface->type; + my $className = _className($type); + my $implementationClassName = _implementationClassName($type); + my $filename = $className . ".cpp"; + + push(@contentsPrefix, $self->_licenseBlock()); + + my $classRefGetter = $self->_classRefGetter($type); + 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 = "@{[$type->name]}"; + 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->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->extendedAttributes->{"CustomArgumentHandling"}) { + $functionCall = "impl->" . $function->name . "(context, argumentCount, arguments, exception)"; + } else { + my @arguments = (); + my @specifiedArguments = @{$function->arguments}; + + $self->_includeHeaders(\%contentsIncludes, $function->type); + + if ($function->extendedAttributes->{"PassContext"}) { + push(@arguments, "context"); + } + + foreach my $i (0..$#specifiedArguments) { + my $argument = $specifiedArguments[$i]; + + $self->_includeHeaders(\%contentsIncludes, $type); + + push(@contents, " " . $self->_platformTypeVariableDeclaration($argument->type, $argument->name, "arguments[$i]", "argumentCount > $i") . "\n"); + + push(@arguments, $self->_argumentExpression($argument)); + } + + $functionCall = "impl->" . $function->name . "(" . join(", ", @arguments) . ")"; + } + + push(@contents, " ${functionCall};\n\n") if $function->type->name eq "void"; + push(@contents, " return " . $self->_returnExpression($function->type, $functionCall) . ";\n}\n"); + } + } + + if (my @attributes = @{$interface->attributes}) { + push(@contents, "\n// Attributes\n"); + foreach my $attribute (@attributes) { + $self->_includeHeaders(\%contentsIncludes, $attribute->type); + + 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->type, $getterExpression)]}; +} +EOF + + unless ($attribute->isReadOnly) { + 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->type, "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, "#include \"config.h\"\n"); + unshift(@contents, @contentsPrefix); + + return { name => $filename, contents => \@contents }; +} + +sub _getterName +{ + my ($self, $attribute) = @_; + + return $attribute->name; +} + +sub _includeHeaders +{ + my ($self, $headers, $type) = @_; + + return unless defined $type; + return if $type->name eq "boolean"; + return if $type->name eq "object"; + return if $$self{codeGenerator}->IsNonPointerType($type); + return if $$self{codeGenerator}->IsStringType($type); + + $$headers{_className($type) . ".h"} = 1; + $$headers{_implementationClassName($type) . ".h"} = 1; +} + +sub _implementationClassName +{ + my ($type) = @_; + + return $type->name; +} + +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->parentType; +} + +sub _platformType +{ + my ($self, $type) = @_; + + return undef unless defined $type; + + return "bool" if $type->name eq "boolean"; + return "JSValueRef" if $type->name eq "object"; + return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($type); + return "double" if $$self{codeGenerator}->IsNonPointerType($type); + return _implementationClassName($type); +} + +sub _platformTypeConstructor +{ + my ($self, $type, $argumentName) = @_; + + return "JSValueToNullableBoolean(context, $argumentName)" if $type->name eq "boolean" && $type->isNullable; + return "JSValueToBoolean(context, $argumentName)" if $type->name eq "boolean"; + return "$argumentName" if $type->name eq "object"; + return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($type); + return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($type); + return "to" . _implementationClassName($type) . "(context, $argumentName)"; +} + +sub _platformTypeVariableDeclaration +{ + my ($self, $type, $variableName, $argumentName, $condition) = @_; + + my $platformType = $self->_platformType($type); + my $constructor = $self->_platformTypeConstructor($type, $argumentName); + + my %nonPointerTypes = ( + "bool" => 1, + "double" => 1, + "JSRetainPtr<JSStringRef>" => 1, + "JSValueRef" => 1, + ); + + my $nullValue = "0"; + if ($platformType eq "JSValueRef") { + $nullValue = "JSValueMakeUndefined(context)"; + } elsif (defined $nonPointerTypes{$platformType} && $platformType ne "double") { + $nullValue = "$platformType()"; + } + + $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, $returnType, $expression) = @_; + + return "JSValueMakeUndefined(context)" if $returnType->name eq "void"; + return "JSValueMakeBooleanOrNull(context, ${expression})" if $returnType->name eq "boolean" && $returnType->isNullable; + return "JSValueMakeBoolean(context, ${expression})" if $returnType->name eq "boolean"; + return "${expression}" if $returnType->name eq "object"; + return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnType); + return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnType); + return "toJS(context, WTF::getPtr(${expression}))"; +} + +sub _argumentExpression +{ + my ($self, $argument) = @_; + + my $type = $argument->type; + my $name = $argument->name; + + return "${name}.get()" if $$self{codeGenerator}->IsStringType($type); + return $name; +} + +sub _setterName +{ + my ($self, $attribute) = @_; + + my $name = $attribute->name; + + return "set" . $$self{codeGenerator}->WK_ucfirst($name); +} + +sub _staticFunctionsGetterImplementation +{ + my ($self, $interface) = @_; + + my $mapFunction = sub { + my $name = $_->name; + my @attributes = qw(kJSPropertyAttributeDontDelete kJSPropertyAttributeReadOnly); + push(@attributes, "kJSPropertyAttributeDontEnum") if $_->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->type); + 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 $_->extendedAttributes->{"NoImplementation"}; + + my $attributeName = $_->name; + my $getterName = $self->_getterName($_); + my $setterName = $_->isReadOnly ? "0" : $self->_setterName($_); + my @attributes = qw(kJSPropertyAttributeDontDelete); + push(@attributes, "kJSPropertyAttributeReadOnly") if $_->isReadOnly; + push(@attributes, "kJSPropertyAttributeDontEnum") if $_->extendedAttributes->{"DontEnum"}; + + return "{ \"$attributeName\", $getterName, $setterName, " . join(" | ", @attributes) . " }"; + }; + + return $self->_staticFunctionsOrValuesGetterImplementation($interface, "value", "{ 0, 0, 0, 0 }", $mapFunction, $interface->attributes); +} + +1; diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl new file mode 100644 index 000000000..f3280bb94 --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010, 2011, 2014-2015 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. + */ + +interface EventSendingController { + void mouseDown(long buttonNumber, object modifierArray); + void mouseUp(long buttonNumber, object modifierArray); + void mouseMoveTo(long x, long y); + void mouseForceClick(); + void startAndCancelMouseForceClick(); + void mouseForceDown(); + void mouseForceUp(); + void mouseForceChanged(double force); + void mouseScrollBy(long x, long y); + void mouseScrollByWithWheelAndMomentumPhases(long x, long y, DOMString phase, DOMString momentum); + void swipeGestureWithWheelAndMomentumPhases(long x, long y, DOMString phase, DOMString momentum); + void continuousMouseScrollBy(long x, long y, optional boolean paged); + object contextClick(); + void scheduleAsynchronousClick(); + + void leapForward(long milliseconds); + + void keyDown(DOMString key, object modifierArray, long location); + void scheduleAsynchronousKeyDown(DOMString key); + + // Zoom functions. + void textZoomIn(); + void textZoomOut(); + void zoomPageIn(); + void zoomPageOut(); + void scalePageBy(double scale, double x, double y); + + void monitorWheelEvents(); + void callAfterScrollingCompletes(object functionCallback); + +#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS + // Touch events. + void addTouchPoint(long x, long y); + void updateTouchPoint(long index, long x, long y); + void setTouchModifier(DOMString modifier, boolean enable); + void setTouchPointRadius(long radiusX, long radiusY); + void touchStart(); + void touchMove(); + void touchEnd(); + void touchCancel(); + void clearTouchPoints(); + void releaseTouchPoint(long index); + void cancelTouchPoint(long index); +#endif +}; + diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h b/Tools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl index 5ec7197c5..fb933834d 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/GCController.idl @@ -23,25 +23,9 @@ * 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; +interface GCController { + void collect(); + void collectOnAlternateThread(boolean waitUntilDone); + unsigned long long getJSObjectCount(); }; -inline JSValueRef JSValueMakeStringOrNull(JSContextRef context, JSStringRef stringOrNull) -{ - return stringOrNull ? JSValueMakeString(context, stringOrNull) : JSValueMakeNull(context); -} - -} // namespace WTR - -#endif // JSWrappable_h diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp b/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp deleted file mode 100644 index e3cf58c2c..000000000 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/JSWrapper.cpp +++ /dev/null @@ -1,80 +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 "config.h" -#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/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl new file mode 100644 index 000000000..352fa0ae7 --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2010-2017 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. + */ + +interface TestRunner { + readonly attribute boolean isWebKit2; + + // The basics. + void dumpAsText(boolean dumpPixels); + void dumpChildFramesAsText(); + void waitForPolicyDelegate(); + void waitUntilDone(); + void waitUntilDownloadFinished(); + void notifyDone(); + double preciseTime(); + readonly attribute double timeout; + + // Other dumping. + void dumpBackForwardList(); + void dumpChildFrameScrollPositions(); + void dumpEditingCallbacks(); + void dumpSelectionRect(); + void dumpStatusCallbacks(); + void dumpTitleChanges(); + void dumpFullScreenCallbacks(); + void dumpFrameLoadCallbacks(); + void dumpProgressFinishedCallback(); + void dumpResourceLoadCallbacks(); + void dumpResourceResponseMIMETypes(); + void dumpWillCacheResponse(); + void dumpApplicationCacheDelegateCallbacks(); + void dumpDatabaseCallbacks(); + void dumpDOMAsWebArchive(); + void dumpPolicyDelegateCallbacks(); + + // Special options. + void keepWebHistory(); + void setAcceptsEditing(boolean value); + void setCanOpenWindows(boolean value); + void setCloseRemainingWindowsWhenComplete(boolean value); + void setXSSAuditorEnabled(boolean value); + void setAllowUniversalAccessFromFileURLs(boolean value); + void setAllowFileAccessFromFileURLs(boolean value); + void setNeedsStorageAccessFromFileURLsQuirk(boolean value); + void setPluginsEnabled(boolean value); + void setJavaScriptCanAccessClipboard(boolean value); + void setPrivateBrowsingEnabled(boolean value); + void setUseDashboardCompatibilityMode(boolean value); + void setPopupBlockingEnabled(boolean value); + void setAuthorAndUserStylesEnabled(boolean value); + void setCustomPolicyDelegate(boolean enabled, boolean permissive); + void addOriginAccessWhitelistEntry(DOMString sourceOrigin, DOMString destinationProtocol, DOMString destinationHost, boolean allowDestinationSubdomains); + void removeOriginAccessWhitelistEntry(DOMString sourceOrigin, DOMString destinationProtocol, DOMString destinationHost, boolean allowDestinationSubdomains); + void setUserStyleSheetEnabled(boolean value); + void setUserStyleSheetLocation(DOMString location); + void setSpatialNavigationEnabled(boolean value); + void setTabKeyCyclesThroughElements(boolean enabled); + void setSerializeHTTPLoads(); + void dispatchPendingLoadRequests(); + void setCacheModel(long model); + void setAsynchronousSpellCheckingEnabled(boolean value); + void setPrinting(); + void setShouldDecideNavigationPolicyAfterDelay(boolean value); + void setNavigationGesturesEnabled(boolean value); + void setIgnoresViewportScaleLimits(boolean value); + void setShouldDownloadUndisplayableMIMETypes(boolean value); + + // Special DOM functions. + void clearBackForwardList(); + void execCommand(DOMString name, DOMString argument); + boolean isCommandEnabled(DOMString name); + unsigned long windowCount(); + + // Special DOM variables. + attribute boolean globalFlag; + + // Repaint testing. + void testRepaint(); + void repaintSweepHorizontally(); + void display(); + + // Printing + boolean isPageBoxVisible(long pageIndex); + + [PassContext] void setValueForUser(object element, DOMString value); + + // UserContent testing. + void addUserScript(DOMString source, boolean runAtStart, boolean allFrames); + void addUserStyleSheet(DOMString source, boolean allFrames); + + // Local storage API + void clearAllDatabases(); + void setDatabaseQuota(unsigned long long quota); + DOMString pathToLocalResource(DOMString url); + + attribute double databaseDefaultQuota; + attribute double databaseMaxQuota; + + // Application Cache API + void clearAllApplicationCaches(); + void setAppCacheMaximumSize(unsigned long long size); + long long applicationCacheDiskUsageForOrigin(DOMString origin); + void clearApplicationCacheForOrigin(DOMString name); + void disallowIncreaseForApplicationCacheQuota(); + object originsWithApplicationCache(); + + // Text search testing. + boolean findString(DOMString target, object optionsArray); + + // Evaluating script in a special context. + [PassContext] void evaluateScriptInIsolatedWorld(unsigned long worldID, DOMString script); + + // For Web Inspector tests + void showWebInspector(); + void closeWebInspector(); + void evaluateInWebInspector(DOMString script); + readonly attribute DOMString inspectorTestStubURL; + + void setPOSIXLocale(DOMString locale); + + void setTextDirection(DOMString direction); + + void setWillSendRequestReturnsNull(boolean flag); + void setWillSendRequestReturnsNullOnRedirect(boolean flag); + void setWillSendRequestAddsHTTPBody(DOMString body); + + void setShouldStayOnPageAfterHandlingBeforeUnload(boolean flag); + + void setDefersLoading(boolean flag); + void setStopProvisionalFrameLoads(); + + // Focus testing. + void addChromeInputField(object callback); + void removeChromeInputField(object callback); + void focusWebView(object callback); + + // Window/view state + void setBackingScaleFactor(double backingScaleFactor, object callback); + + void setWindowIsKey(boolean isKey); + void setViewSize(double width, double height); + + // Cookies testing + void setAlwaysAcceptCookies(boolean accept); + + void overridePreference(DOMString preference, DOMString value); + + // Page Visibility API + void setPageVisibility(DOMString state); + void resetPageVisibility(); + + // Control full screen behavior. + void setHasCustomFullScreenBehavior(boolean value); + + // Web notifications support + void grantWebNotificationPermission(DOMString origin); + void denyWebNotificationPermission(DOMString origin); + void removeAllWebNotificationPermissions(); + void simulateWebNotificationClick(object notification); + + // Geolocation + void setGeolocationPermission(boolean value); + void setMockGeolocationPosition(double latitude, double longitude, double accuracy, optional object altitude, optional object altitudeAccuracy, optional object heading, optional object speed); + void setMockGeolocationPositionUnavailableError(DOMString errorMessage); + boolean isGeolocationProviderActive(); + + // MediaStream + void setUserMediaPermission(boolean value); + void setUserMediaPersistentPermissionForOrigin(boolean permission, DOMString origin, DOMString parentOrigin); + unsigned long userMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin); + void resetUserMediaPermissionRequestCountForOrigin(DOMString origin, DOMString parentOrigin); + + // Audio testing. + [PassContext] void setAudioResult(object data); + + boolean callShouldCloseOnWebView(); + + // Work queue. + void queueBackNavigation(unsigned long howFarBackward); + void queueForwardNavigation(unsigned long howFarForward); + void queueLoad(DOMString url, DOMString target, optional boolean shouldOpenExternalURLs); + void queueLoadHTMLString(DOMString content, optional DOMString baseURL, optional DOMString unreachableURL); + void queueReload(); + void queueLoadingScript(DOMString script); + void queueNonLoadingScript(DOMString script); + + // Authentication + void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(boolean value); + void setHandlesAuthenticationChallenges(boolean value); + void setShouldLogCanAuthenticateAgainstProtectionSpace(boolean value); + void setAuthenticationUsername(DOMString username); + void setAuthenticationPassword(DOMString password); + + void setAllowsAnySSLCertificate(boolean value); + + // Secure text input mode (Mac only) + readonly attribute boolean secureEventInputIsEnabled; + + // Override plugin load policy. + void setBlockAllPlugins(boolean shouldBlock); + + // Hooks to the JSC compiler. + object failNextNewCodeBlock(); + object numberOfDFGCompiles(object function); + object neverInlineFunction(object function); + + // Swipe gestures + void installDidBeginSwipeCallback(object callback); + void installWillEndSwipeCallback(object callback); + void installDidEndSwipeCallback(object callback); + void installDidRemoveSwipeSnapshotCallback(object callback); + + unsigned long imageCountInGeneralPasteboard(); + + // UI Process Testing + void runUIScript(DOMString script, object callback); + + void clearTestRunnerCallbacks(); + + void accummulateLogsForChannel(DOMString channel); + + // Gamepad + void setMockGamepadDetails(unsigned long index, DOMString id, unsigned long axisCount, unsigned long buttonCount); + void setMockGamepadAxisValue(unsigned long index, unsigned long axisIndex, double value); + void setMockGamepadButtonValue(unsigned long index, unsigned long buttonIndex, double value); + void connectMockGamepad(unsigned long index); + void disconnectMockGamepad(unsigned long index); + + // Resource Load Statistics + void installStatisticsDidModifyDataRecordsCallback(object callback); + void setStatisticsPrevalentResource(DOMString hostName, boolean value); + boolean isStatisticsPrevalentResource(DOMString hostName); + void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value); + boolean isStatisticsHasHadUserInteraction(DOMString hostName); + void setStatisticsTimeToLiveUserInteraction(double seconds); + void statisticsFireDataModificationHandler(); + void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value); + void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(boolean value); + void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds); + void statisticsResetToConsistentState(); +}; diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl new file mode 100644 index 000000000..d95a6985d --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TextInputController.idl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2011 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. + * + * 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. + */ + +interface TextInputController { + void setMarkedText(DOMString string, long from, long length); + boolean hasMarkedText(); + void unmarkText(); + void insertText(DOMString string); +}; + |
