summaryrefslogtreecommitdiffstats
path: root/WebKitTools/WebKitTestRunner
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-07-30 10:46:49 +0100
committerKristian Monsen <kristianm@google.com>2010-08-04 13:01:34 +0100
commit0617145a89917ae7735fe1c9538688ab9a577df5 (patch)
tree56206078694427c37ed7bdf27eb5221398b833c0 /WebKitTools/WebKitTestRunner
parentef1adcdfc805d4d13103f6f15cc5b4d96828a60f (diff)
downloadexternal_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.zip
external_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.tar.gz
external_webkit-0617145a89917ae7735fe1c9538688ab9a577df5.tar.bz2
Merge WebKit at r64264 : Initial merge by git.
Change-Id: Ic42bef02efef8217a0f84c47176a9c617c28d1f1
Diffstat (limited to 'WebKitTools/WebKitTestRunner')
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm20
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h5
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl25
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp20
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h6
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp407
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h69
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp149
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h62
-rw-r--r--WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj21
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.cpp10
-rw-r--r--WebKitTools/WebKitTestRunner/TestController.h4
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.cpp2
-rw-r--r--WebKitTools/WebKitTestRunner/TestInvocation.h2
-rw-r--r--WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp2
15 files changed, 666 insertions, 138 deletions
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
index d72d4fc..fa47143 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
@@ -260,7 +260,7 @@ EOF
push(@contents, " " . $self->_platformTypeVariableDeclaration($parameter, $parameter->name, "arguments[$i]", "argumentCount > $i") . "\n");
- push(@parameters, $self->_paramterExpression($parameter));
+ push(@parameters, $self->_parameterExpression($parameter));
}
my $isVoidReturn = $function->signature->type eq "void";
@@ -343,7 +343,10 @@ sub _includeHeaders
my ($self, $headers, $idlType, $signature) = @_;
return unless defined $idlType;
- return if $idlType eq "boolean" or $$self{codeGenerator}->IsNonPointerType($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;
@@ -385,6 +388,7 @@ sub _platformType
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);
@@ -396,8 +400,9 @@ sub _platformTypeConstructor
my $idlType = $signature->type;
- return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType);
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)";
}
@@ -413,6 +418,7 @@ sub _platformTypeVariableDeclaration
"bool" => 1,
"double" => 1,
"JSRetainPtr<JSStringRef>" => 1,
+ "JSValueRef" => 1,
);
my $nullValue = "0";
@@ -429,19 +435,17 @@ sub _returnExpression
{
my ($self, $signature, $expression) = @_;
- my $convertNullStringAttribute = $signature->extendedAttributes->{"ConvertNullStringTo"};
- my $nullOrEmptyString = "NullStringAsEmptyString";
- $nullOrEmptyString = "NullStringAsNull" if defined $convertNullStringAttribute && $convertNullStringAttribute eq "Null";
-
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 _paramterExpression
+sub _parameterExpression
{
my ($self, $parameter) = @_;
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
index cf56c5d..9cb97af 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/JSWrappable.h
@@ -37,6 +37,11 @@ public:
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/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
index 7da2e81..a0fbb85 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
@@ -26,18 +26,35 @@
module WTR {
interface LayoutTestController {
+ // The basics.
void dumpAsText();
- void dumpStatusCallbacks();
-
+ void dumpChildFramesAsText();
void waitUntilDone();
void notifyDone();
- // Repaint testing
+ // Other dumping.
+ void dumpChildFrameScrollPositions();
+ void dumpEditingCallbacks();
+ void dumpSelectionRect();
+ void dumpStatusCallbacks();
+
+ // Special options.
+ void keepWebHistory();
+ void setAcceptsEditing(in boolean value);
+
+ // Special DOM functions.
+ object computedStyleIncludingVisitedInfo(in object element);
+ DOMString counterValueForElementById(in DOMString elementId);
+ DOMString markerTextForListItem(in object element);
+ void execCommand(in DOMString name, in DOMString argument);
+ boolean isCommandEnabled(in DOMString name);
+
+ // Repaint testing.
void testRepaint();
void repaintSweepHorizontally();
void display();
- // Animation testing
+ // Animation testing.
int numberOfActiveAnimations();
boolean pauseAnimationAtTimeOnElementWithId(in DOMString animationName, in double time, in DOMString elementId);
};
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index d3c66fd..0e99dde 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -27,11 +27,12 @@
#include "ActivateFonts.h"
#include "InjectedBundlePage.h"
+#include <WebKit2/WebKit2.h>
#include <WebKit2/WKBundle.h>
#include <WebKit2/WKBundlePage.h>
+#include <WebKit2/WKBundlePrivate.h>
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKStringCF.h>
-#include <WebKit2/WebKit2.h>
#include <wtf/RetainPtr.h>
namespace WTR {
@@ -57,9 +58,9 @@ void InjectedBundle::_willDestroyPage(WKBundleRef bundle, WKBundlePageRef page,
static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page);
}
-void InjectedBundle::_didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
+void InjectedBundle::_didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo)
{
- static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didRecieveMessage(message);
+ static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didReceiveMessage(message);
}
void InjectedBundle::initialize(WKBundleRef bundle)
@@ -71,7 +72,7 @@ void InjectedBundle::initialize(WKBundleRef bundle)
this,
_didCreatePage,
_willDestroyPage,
- _didRecieveMessage
+ _didReceiveMessage
};
WKBundleSetClient(m_bundle, &client);
@@ -98,7 +99,7 @@ void InjectedBundle::willDestroyPage(WKBundlePageRef page)
delete m_pages.take(page);
}
-void InjectedBundle::didRecieveMessage(WKStringRef message)
+void InjectedBundle::didReceiveMessage(WKStringRef message)
{
CFStringRef cfMessage = WKStringCopyCFString(0, message);
if (CFEqual(cfMessage, CFSTR("BeginTest"))) {
@@ -116,7 +117,14 @@ void InjectedBundle::didRecieveMessage(WKStringRef message)
void InjectedBundle::reset()
{
m_outputStream.str("");
- m_layoutTestController = LayoutTestController::create(std::string(""));
+ m_layoutTestController = LayoutTestController::create();
+ WKBundleSetShouldTrackVisitedLinks(m_bundle, false);
+ WKBundleRemoveAllVisitedLinks(m_bundle);
+}
+
+void InjectedBundle::setShouldTrackVisitedLinks()
+{
+ WKBundleSetShouldTrackVisitedLinks(m_bundle, true);
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index 1581ebc..9bda922 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -52,17 +52,19 @@ public:
std::ostringstream& os() { return m_outputStream; }
+ void setShouldTrackVisitedLinks();
+
private:
InjectedBundle();
~InjectedBundle();
static void _didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
static void _willDestroyPage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo);
- static void _didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
+ static void _didReceiveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo);
void didCreatePage(WKBundlePageRef page);
void willDestroyPage(WKBundlePageRef page);
- void didRecieveMessage(WKStringRef message);
+ void didReceiveMessage(WKStringRef message);
void reset();
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
index cbba470..3632fb9 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
@@ -26,28 +26,96 @@
#include "InjectedBundlePage.h"
#include "InjectedBundle.h"
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <WebKit2/WKArray.h>
#include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKBundleNode.h>
#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKBundleRange.h>
#include <WebKit2/WKString.h>
#include <WebKit2/WKStringCF.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
+using namespace std;
+
namespace WTR {
-static PassOwnPtr<Vector<char> > WKStringToUTF8(WKStringRef wkStringRef)
+static ostream& operator<<(ostream& out, CFStringRef stringRef)
+{
+ if (!stringRef)
+ return out;
+ CFIndex bufferLength = CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef), kCFStringEncodingUTF8) + 1;
+ Vector<char> buffer(bufferLength);
+ if (!CFStringGetCString(stringRef, buffer.data(), bufferLength, kCFStringEncodingUTF8))
+ return out;
+ return out << buffer.data();
+}
+
+static ostream& operator<<(ostream& out, const RetainPtr<CFStringRef>& stringRef)
+{
+ return out << stringRef.get();
+}
+
+static ostream& operator<<(ostream& out, WKStringRef stringRef)
+{
+ if (!stringRef)
+ return out;
+ RetainPtr<CFStringRef> cfString(AdoptCF, WKStringCopyCFString(0, stringRef));
+ return out << cfString;
+}
+
+static ostream& operator<<(ostream& out, const WKRetainPtr<WKStringRef>& stringRef)
+{
+ return out << stringRef.get();
+}
+
+static ostream& operator<<(ostream& out, JSStringRef stringRef)
+{
+ if (!stringRef)
+ return out;
+ CFIndex bufferLength = JSStringGetMaximumUTF8CStringSize(stringRef) + 1;
+ Vector<char> buffer(bufferLength);
+ JSStringGetUTF8CString(stringRef, buffer.data(), bufferLength);
+ return out << buffer.data();
+}
+
+static ostream& operator<<(ostream& out, const JSRetainPtr<JSStringRef>& stringRef)
+{
+ return out << stringRef.get();
+}
+
+static string dumpPath(WKBundleNodeRef node)
{
- RetainPtr<CFStringRef> cfString(AdoptCF, WKStringCopyCFString(0, wkStringRef));
- CFIndex bufferLength = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfString.get()), kCFStringEncodingUTF8) + 1;
- OwnPtr<Vector<char> > buffer(new Vector<char>(bufferLength));
- if (!CFStringGetCString(cfString.get(), buffer->data(), bufferLength, kCFStringEncodingUTF8)) {
- buffer->shrink(1);
- (*buffer)[0] = 0;
- } else
- buffer->shrink(strlen(buffer->data()) + 1);
- return buffer.release();
+ if (!node)
+ return "(null)";
+ WKRetainPtr<WKStringRef> nodeName(AdoptWK, WKBundleNodeCopyNodeName(node));
+ ostringstream out;
+ out << nodeName;
+ if (WKBundleNodeRef parent = WKBundleNodeGetParent(node))
+ out << " > " << dumpPath(parent);
+ return out.str();
+}
+
+static ostream& operator<<(ostream& out, WKBundleRangeRef rangeRef)
+{
+ if (rangeRef)
+ out << "range from " << WKBundleRangeGetStartOffset(rangeRef) << " of " << dumpPath(WKBundleRangeGetStartContainer(rangeRef)) << " to " << WKBundleRangeGetEndOffset(rangeRef) << " of " << dumpPath(WKBundleRangeGetEndContainer(rangeRef));
+ else
+ out << "(null)";
+
+ return out;
+}
+
+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;
}
InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
@@ -78,6 +146,23 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
_willRunJavaScriptPrompt
};
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()
@@ -121,9 +206,9 @@ void InjectedBundlePage::_didReceiveTitleForFrame(WKBundlePageRef page, WKString
static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReceiveTitleForFrame(title, frame);
}
-void InjectedBundlePage::_didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSContextRef ctx, JSObjectRef window, const void *clientInfo)
+void InjectedBundlePage::_didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window, const void *clientInfo)
{
- static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didClearWindowForFrame(frame, ctx, window);
+ static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didClearWindowForFrame(frame, context, window);
}
void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame)
@@ -144,20 +229,128 @@ void InjectedBundlePage::didCommitLoadForFrame(WKBundleFrameRef frame)
{
}
+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 JSRetainPtr<JSStringRef> propertyString(JSContextRef context, JSObjectRef object, const char* propertyName)
+{
+ JSValueRef value = propertyValue(context, object, propertyName);
+ if (!value)
+ return 0;
+ JSValueRef exception;
+ return JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, value, &exception));
+}
+
+static double numericWindowPropertyValue(WKBundleFrameRef frame, const char* propertyName)
+{
+ JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
+ JSValueRef value = propertyValue(context, JSContextGetGlobalObject(context), propertyName);
+ if (!value)
+ return 0;
+ JSValueRef exception;
+ return JSValueToNumber(context, value, &exception);
+}
+
+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) {
+ // FIXME: I don't like that we have to const_cast here. Can we change WKArray?
+ WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(const_cast<void*>(WKArrayGetItemAtIndex(childFrames.get(), i)));
+ dumpFrameScrollPosition(subframe, ShouldIncludeFrameName);
+ dumpDescendantFrameScrollPositions(subframe);
+ }
+}
+
+void InjectedBundlePage::dumpAllFrameScrollPositions()
+{
+ WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page);
+ dumpFrameScrollPosition(frame);
+ dumpDescendantFrameScrollPositions(frame);
+}
+
+static void dumpFrameText(WKBundleFrameRef frame)
+{
+ JSGlobalContextRef context = WKBundleFrameGetJavaScriptContext(frame);
+ JSObjectRef document = propertyObject(context, JSContextGetGlobalObject(context), "document");
+ JSObjectRef documentElement = propertyObject(context, document, "documentElement");
+ InjectedBundle::shared().os() << propertyString(context, documentElement, "innerText") << "\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) {
+ // FIXME: I don't like that we have to const_cast here. Can we change WKArray?
+ WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(const_cast<void*>(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()
{
InjectedBundle::shared().layoutTestController()->invalidateWaitToDumpWatchdog();
- if (InjectedBundle::shared().layoutTestController()->shouldDumpAsText()) {
- // FIXME: Support dumping subframes when layoutTestController()->dumpChildFramesAsText() is true.
- WKRetainPtr<WKStringRef> innerText(AdoptWK, WKBundleFrameCopyInnerText(WKBundlePageGetMainFrame(m_page)));
- OwnPtr<Vector<char> > utf8InnerText = WKStringToUTF8(innerText.get());
- InjectedBundle::shared().os() << utf8InnerText->data() << "\n";
- } else {
- WKRetainPtr<WKStringRef> externalRepresentation(AdoptWK, WKBundlePageCopyRenderTreeExternalRepresentation(m_page));
- OwnPtr<Vector<char> > utf8externalRepresentation = WKStringToUTF8(externalRepresentation.get());
- InjectedBundle::shared().os() << utf8externalRepresentation->data();
+ 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));
+
InjectedBundle::shared().done();
}
@@ -188,10 +381,10 @@ void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFram
{
}
-void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, JSContextRef ctx, JSObjectRef window)
+void InjectedBundlePage::didClearWindowForFrame(WKBundleFrameRef frame, JSGlobalContextRef context, JSObjectRef window)
{
JSValueRef exception = 0;
- InjectedBundle::shared().layoutTestController()->makeWindowObject(ctx, window, &exception);
+ InjectedBundle::shared().layoutTestController()->makeWindowObject(context, window, &exception);
}
// UI Client Callbacks
@@ -224,8 +417,7 @@ void InjectedBundlePage::_willRunJavaScriptPrompt(WKBundlePageRef page, WKString
void InjectedBundlePage::willAddMessageToConsole(WKStringRef message, uint32_t lineNumber)
{
// FIXME: Strip file: urls.
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
- InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << utf8Message->data() << "\n";
+ InjectedBundle::shared().os() << "CONSOLE MESSAGE: line " << lineNumber << ": " << message << "\n";
}
void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText)
@@ -233,27 +425,174 @@ void InjectedBundlePage::willSetStatusbarText(WKStringRef statusbarText)
if (!InjectedBundle::shared().layoutTestController()->shouldDumpStatusCallbacks())
return;
- OwnPtr<Vector<char> > utf8StatusbarText = WKStringToUTF8(statusbarText);
- InjectedBundle::shared().os() << "UI DELEGATE STATUS CALLBACK: setStatusText:" << utf8StatusbarText->data() << "\n";
+ InjectedBundle::shared().os() << "UI DELEGATE STATUS CALLBACK: setStatusText:" << statusbarText << "\n";
}
void InjectedBundlePage::willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef)
{
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
- InjectedBundle::shared().os() << "ALERT: " << utf8Message->data() << "\n";
+ InjectedBundle::shared().os() << "ALERT: " << message << "\n";
}
void InjectedBundlePage::willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef)
{
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
- InjectedBundle::shared().os() << "CONFIRM: " << utf8Message->data() << "\n";
+ InjectedBundle::shared().os() << "CONFIRM: " << message << "\n";
}
void InjectedBundlePage::willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef)
{
- OwnPtr<Vector<char> > utf8Message = WKStringToUTF8(message);
- OwnPtr<Vector<char> > utf8DefaultValue = WKStringToUTF8(defaultValue);
- InjectedBundle::shared().os() << "PROMPT: " << utf8Message->data() << ", default text: " << utf8DefaultValue->data() << "\n";
+ InjectedBundle::shared().os() << "PROMPT: " << message << ", default text: " << defaultValue << "\n";
+}
+
+// Editor Client Callbacks
+
+bool InjectedBundlePage::_shouldBeginEditing(WKBundlePageRef page, WKBundleRangeRef range, const void* clientInfo)
+{
+ return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldBeginEditing(range);
}
+bool InjectedBundlePage::_shouldEndEditing(WKBundlePageRef page, WKBundleRangeRef range, const void* clientInfo)
+{
+ return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldEndEditing(range);
+}
+
+bool InjectedBundlePage::_shouldInsertNode(WKBundlePageRef page, WKBundleNodeRef node, WKBundleRangeRef 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, WKBundleRangeRef rangeToReplace, WKInsertActionType action, const void* clientInfo)
+{
+ return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldInsertText(text, rangeToReplace, action);
+}
+
+bool InjectedBundlePage::_shouldDeleteRange(WKBundlePageRef page, WKBundleRangeRef range, const void* clientInfo)
+{
+ return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldDeleteRange(range);
+}
+
+bool InjectedBundlePage::_shouldChangeSelectedRange(WKBundlePageRef page, WKBundleRangeRef fromRange, WKBundleRangeRef 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, WKBundleRangeRef 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(WKBundleRangeRef range)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldBeginEditingInDOMRange:" << range << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldEndEditing(WKBundleRangeRef range)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldEndEditingInDOMRange:" << range << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldInsertNode(WKBundleNodeRef node, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
+{
+ static const char *insertactionstring[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
+ };
+
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertNode:" << dumpPath(node) << " replacingDOMRange:" << rangeToReplace << " givenAction:" << insertactionstring[action] << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeRef rangeToReplace, WKInsertActionType action)
+{
+ static const char *insertactionstring[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
+ };
+
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertText:" << text << " replacingDOMRange:" << rangeToReplace << " givenAction:" << insertactionstring[action] << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeRef range)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << range << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType affinity, bool stillSelecting)
+{
+ static const char *affinitystring[] = {
+ "NSSelectionAffinityUpstream",
+ "NSSelectionAffinityDownstream"
+ };
+ static const char *boolstring[] = {
+ "FALSE",
+ "TRUE"
+ };
+
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldChangeSelectedDOMRange:" << fromRange << " toDOMRange:" << toRange << " affinity:" << affinitystring[affinity] << " stillSelecting:" << boolstring[stillSelecting] << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef range)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << range << "\n";
+ return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
+}
+
+void InjectedBundlePage::didBeginEditing(WKStringRef notificationName)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidBeginEditing:" << notificationName << "\n";
+}
+
+void InjectedBundlePage::didEndEditing(WKStringRef notificationName)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidEndEditing:" << notificationName << "\n";
+}
+
+void InjectedBundlePage::didChange(WKStringRef notificationName)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChange:" << notificationName << "\n";
+}
+
+void InjectedBundlePage::didChangeSelection(WKStringRef notificationName)
+{
+ if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
+ InjectedBundle::shared().os() << "EDITING DELEGATE: webViewDidChangeSelection:" << notificationName << "\n";
+}
+
+
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
index bce9d2c..1b67af0 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
@@ -42,35 +42,62 @@ public:
private:
// Loader Client
- static void _didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
- static void _didReceiveTitleForFrame(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, const void *clientInfo);
- static void _didClearWindowForFrame(WKBundlePageRef page, WKBundleFrameRef frame, JSContextRef ctx, JSObjectRef window, const void *clientInfo);
- void didStartProvisionalLoadForFrame(WKBundleFrameRef frame);
- void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef frame);
- void didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef frame);
- void didCommitLoadForFrame(WKBundleFrameRef frame);
- void didFinishLoadForFrame(WKBundleFrameRef frame);
- void didFailLoadWithErrorForFrame(WKBundleFrameRef frame);
- void didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame);
- void didClearWindowForFrame(WKBundleFrameRef frame, JSContextRef ctx, JSObjectRef window);
+ static void _didStartProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didCommitLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didFinishLoadForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didFailLoadWithErrorForFrame(WKBundlePageRef, WKBundleFrameRef, const void* clientInfo);
+ static void _didReceiveTitleForFrame(WKBundlePageRef, WKStringRef title, WKBundleFrameRef, const void* clientInfo);
+ static void _didClearWindowForFrame(WKBundlePageRef, WKBundleFrameRef, JSGlobalContextRef, JSObjectRef window, const void* clientInfo);
+ void didStartProvisionalLoadForFrame(WKBundleFrameRef);
+ void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef);
+ void didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef);
+ void didCommitLoadForFrame(WKBundleFrameRef);
+ void didFinishLoadForFrame(WKBundleFrameRef);
+ void didFailLoadWithErrorForFrame(WKBundleFrameRef);
+ void didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef);
+ void didClearWindowForFrame(WKBundleFrameRef, JSGlobalContextRef, JSObjectRef window);
// UI Client
- static void _willAddMessageToConsole(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void* clientInfo);
- static void _willSetStatusbarText(WKBundlePageRef page, WKStringRef statusbarText, const void* clientInfo);
- static void _willRunJavaScriptAlert(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
- static void _willRunJavaScriptConfirm(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
- static void _willRunJavaScriptPrompt(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void* clientInfo);
+ 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, WKBundleRangeRef, const void* clientInfo);
+ static bool _shouldEndEditing(WKBundlePageRef, WKBundleRangeRef, const void* clientInfo);
+ static bool _shouldInsertNode(WKBundlePageRef, WKBundleNodeRef, WKBundleRangeRef rangeToReplace, WKInsertActionType, const void* clientInfo);
+ static bool _shouldInsertText(WKBundlePageRef, WKStringRef, WKBundleRangeRef rangeToReplace, WKInsertActionType, const void* clientInfo);
+ static bool _shouldDeleteRange(WKBundlePageRef, WKBundleRangeRef, const void* clientInfo);
+ static bool _shouldChangeSelectedRange(WKBundlePageRef, WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType, bool stillSelecting, const void* clientInfo);
+ static bool _shouldApplyStyle(WKBundlePageRef, WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef 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(WKBundleRangeRef);
+ bool shouldEndEditing(WKBundleRangeRef);
+ bool shouldInsertNode(WKBundleNodeRef, WKBundleRangeRef rangeToReplace, WKInsertActionType);
+ bool shouldInsertText(WKStringRef, WKBundleRangeRef rangeToReplace, WKInsertActionType);
+ bool shouldDeleteRange(WKBundleRangeRef);
+ bool shouldChangeSelectedRange(WKBundleRangeRef fromRange, WKBundleRangeRef toRange, WKAffinityType, bool stillSelecting);
+ bool shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeRef range);
+ void didBeginEditing(WKStringRef notificationName);
+ void didEndEditing(WKStringRef notificationName);
+ void didChange(WKStringRef notificationName);
+ void didChangeSelection(WKStringRef notificationName);
+
+ void dumpAllFramesText();
+ void dumpAllFrameScrollPositions();
+
WKBundlePageRef m_page;
bool m_isLoading;
};
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
index fafa1e3..2f59eb1 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
@@ -30,24 +30,97 @@
#include "JSLayoutTestController.h"
#include <JavaScriptCore/JSRetainPtr.h>
#include <WebKit2/WKBundleFrame.h>
+#include <WebKit2/WKBundleFramePrivate.h>
+#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKRetainPtr.h>
#include <WebKit2/WKStringCF.h>
#include <WebKit2/WebKit2.h>
namespace WTR {
-PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string& testPathOrURL)
+// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures
+// Eventually it should be changed to match.
+static const CFTimeInterval waitToDumpWatchdogInterval = 6.0;
+
+static RetainPtr<CFStringRef> toCF(JSStringRef string)
+{
+ return RetainPtr<CFStringRef>(AdoptCF, JSStringCopyCFString(0, string));
+}
+
+static RetainPtr<CFStringRef> toCF(WKStringRef string)
+{
+ return RetainPtr<CFStringRef>(AdoptCF, WKStringCopyCFString(0, string));
+}
+
+static WKRetainPtr<WKStringRef> toWK(JSStringRef string)
+{
+ return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithCFString(toCF(string).get()));
+}
+
+static JSRetainPtr<JSStringRef> toJS(WKStringRef string)
+{
+ return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithCFString(toCF(string).get()));
+}
+
+static JSRetainPtr<JSStringRef> toJS(const WKRetainPtr<WKStringRef>& string)
+{
+ return toJS(string.get());
+}
+
+static 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);
+}
+
+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)
{
- return adoptRef(new LayoutTestController(testPathOrURL));
+ 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);
}
-LayoutTestController::LayoutTestController(const std::string& testPathOrURL)
- : m_dumpAsText(false)
+PassRefPtr<LayoutTestController> LayoutTestController::create()
+{
+ return adoptRef(new LayoutTestController);
+}
+
+LayoutTestController::LayoutTestController()
+ : m_whatToDump(RenderTree)
+ , m_shouldDumpAllFrameScrollPositions(false)
+ , m_shouldAllowEditing(true)
+ , m_dumpEditingCallbacks(false)
, m_dumpStatusCallbacks(false)
, m_waitToDump(false)
, m_testRepaint(false)
, m_testRepaintSweepHorizontally(false)
- , m_testPathOrURL(testPathOrURL)
{
}
@@ -60,10 +133,6 @@ JSClassRef LayoutTestController::wrapperClass()
return JSLayoutTestController::layoutTestControllerClass();
}
-// This is lower than DumpRenderTree's timeout, to make it easier to work through the failures
-// Eventually it should be changed to match.
-static const CFTimeInterval waitToDumpWatchdogInterval = 6.0;
-
void LayoutTestController::display()
{
// FIXME: actually implement, once we want pixel tests
@@ -109,27 +178,75 @@ void LayoutTestController::notifyDone()
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)
{
- RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, elementId));
- WKRetainPtr<WKStringRef> idWK(AdoptWK, WKStringCreateWithCFString(idCF.get()));
- RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, animationName));
- WKRetainPtr<WKStringRef> nameWK(AdoptWK, WKStringCreateWithCFString(nameCF.get()));
+ // 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::keepWebHistory()
+{
+ InjectedBundle::shared().setShouldTrackVisitedLinks();
+}
+
+JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSValueRef element)
+{
+ // FIXME: Is it OK this works only for the main frame?
WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
- return WKBundleFramePauseAnimationOnElementWithId(mainFrame, nameWK.get(), idWK.get(), time);
+ 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());
}
// Object Creation
void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
{
- JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
- JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), JSWrapper::wrap(context, this), kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, 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
index f9585a3..9f0641b 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h
@@ -28,6 +28,7 @@
#include "JSWrappable.h"
#include <JavaScriptCore/JavaScriptCore.h>
+#include <JavaScriptCore/JSRetainPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RetainPtr.h>
#include <string>
@@ -36,44 +37,73 @@ namespace WTR {
class LayoutTestController : public JSWrappable {
public:
- static PassRefPtr<LayoutTestController> create(const std::string& testPathOrURL);
- ~LayoutTestController();
+ static PassRefPtr<LayoutTestController> create();
+ virtual ~LayoutTestController();
// JSWrappable
- JSClassRef wrapperClass();
+ virtual JSClassRef wrapperClass();
- void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
+ void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
- bool shouldDumpAsText() const { return m_dumpAsText; }
- void dumpAsText() { m_dumpAsText = true; }
+ // The basics.
+ void dumpAsText() { m_whatToDump = MainFrameText; }
+ void dumpChildFramesAsText() { m_whatToDump = AllFramesText; }
+ void waitUntilDone();
+ void notifyDone();
- bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
+ // Other dumping.
+ 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; }
- bool waitToDump() const { return m_waitToDump; }
- void waitToDumpWatchdogTimerFired();
- void invalidateWaitToDumpWatchdog();
- void waitUntilDone();
- void notifyDone();
+ // Special options.
+ void keepWebHistory();
+ void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
+
+ // Special DOM functions.
+ JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element);
+ JSRetainPtr<JSStringRef> counterValueForElementById(JSStringRef elementId);
+ JSRetainPtr<JSStringRef> markerTextForListItem(JSValueRef element);
+ void execCommand(JSStringRef name, JSStringRef argument);
+ bool isCommandEnabled(JSStringRef name);
+ // 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);
+ enum WhatToDump { RenderTree, MainFrameText, AllFramesText };
+ WhatToDump whatToDump() const { return m_whatToDump; }
+
+ bool shouldDumpAllFrameScrollPositions() const { return m_shouldDumpAllFrameScrollPositions; }
+ bool shouldDumpEditingCallbacks() const { return m_dumpEditingCallbacks; }
+ bool shouldDumpMainFrameScrollPosition() const { return m_whatToDump == RenderTree; }
+
+ bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
+
+ bool waitToDump() const { return m_waitToDump; }
+ void waitToDumpWatchdogTimerFired();
+ void invalidateWaitToDumpWatchdog();
+
+ bool shouldAllowEditing() const { return m_shouldAllowEditing; }
+
private:
- LayoutTestController(const std::string& testPathOrURL);
+ LayoutTestController();
- bool m_dumpAsText;
+ WhatToDump m_whatToDump;
+ bool m_shouldDumpAllFrameScrollPositions;
+ bool m_shouldAllowEditing;
+ bool m_dumpEditingCallbacks;
bool m_dumpStatusCallbacks;
bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
bool m_testRepaint;
bool m_testRepaintSweepHorizontally;
- std::string m_testPathOrURL;
-
RetainPtr<CFRunLoopTimerRef> m_waitToDumpWatchdog;
};
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj b/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj
index 601a4ac..be20bab 100644
--- a/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj
+++ b/WebKitTools/WebKitTestRunner/InjectedBundle/win/InjectedBundle.vcproj
@@ -23,7 +23,6 @@
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
@@ -39,8 +38,6 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -53,7 +50,6 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile=""
/>
<Tool
Name="VCALinkTool"
@@ -78,7 +74,6 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine=""
/>
</Configuration>
<Configuration
@@ -90,7 +85,6 @@
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
@@ -106,8 +100,6 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -120,7 +112,6 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile=""
/>
<Tool
Name="VCALinkTool"
@@ -145,7 +136,6 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine=""
/>
</Configuration>
<Configuration
@@ -156,7 +146,6 @@
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
@@ -172,9 +161,6 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- RuntimeLibrary="3"
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -187,7 +173,6 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile=""
/>
<Tool
Name="VCALinkTool"
@@ -212,7 +197,6 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine=""
/>
</Configuration>
<Configuration
@@ -223,7 +207,6 @@
>
<Tool
Name="VCPreBuildEventTool"
- CommandLine=""
/>
<Tool
Name="VCCustomBuildTool"
@@ -239,8 +222,6 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -253,7 +234,6 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile=""
/>
<Tool
Name="VCALinkTool"
@@ -278,7 +258,6 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine=""
/>
</Configuration>
</Configurations>
diff --git a/WebKitTools/WebKitTestRunner/TestController.cpp b/WebKitTools/WebKitTestRunner/TestController.cpp
index fec6b56..4f8cd6b 100644
--- a/WebKitTools/WebKitTestRunner/TestController.cpp
+++ b/WebKitTools/WebKitTestRunner/TestController.cpp
@@ -82,7 +82,7 @@ void TestController::initialize(int argc, const char* argv[])
WKContextInjectedBundleClient injectedBundlePathClient = {
0,
this,
- _didRecieveMessageFromInjectedBundle
+ _didReceiveMessageFromInjectedBundle
};
WKContextSetInjectedBundleClient(m_context.get(), &injectedBundlePathClient);
@@ -126,14 +126,14 @@ bool TestController::run()
return true;
}
-void TestController::_didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
+void TestController::_didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo)
{
- static_cast<TestController*>(const_cast<void*>(clientInfo))->didRecieveMessageFromInjectedBundle(message);
+ static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveMessageFromInjectedBundle(message);
}
-void TestController::didRecieveMessageFromInjectedBundle(WKStringRef message)
+void TestController::didReceiveMessageFromInjectedBundle(WKStringRef message)
{
- m_currentInvocation->didRecieveMessageFromInjectedBundle(message);
+ m_currentInvocation->didReceiveMessageFromInjectedBundle(message);
}
} // namespace WTR
diff --git a/WebKitTools/WebKitTestRunner/TestController.h b/WebKitTools/WebKitTestRunner/TestController.h
index 7e829b6..bd073bf 100644
--- a/WebKitTools/WebKitTestRunner/TestController.h
+++ b/WebKitTools/WebKitTestRunner/TestController.h
@@ -67,8 +67,8 @@ private:
void initializeTestPluginPath();
// WKContextInjectedBundleClient
- static void _didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
- void didRecieveMessageFromInjectedBundle(WKStringRef message);
+ static void _didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void*);
+ void didReceiveMessageFromInjectedBundle(WKStringRef message);
OwnPtr<TestInvocation> m_currentInvocation;
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.cpp b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
index 1434d50..b6e950f 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.cpp
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.cpp
@@ -139,7 +139,7 @@ void TestInvocation::dump(const char* stringToDump)
fflush(stderr);
}
-void TestInvocation::didRecieveMessageFromInjectedBundle(WKStringRef message)
+void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef message)
{
RetainPtr<CFStringRef> cfMessage(AdoptCF, WKStringCopyCFString(0, message));
diff --git a/WebKitTools/WebKitTestRunner/TestInvocation.h b/WebKitTools/WebKitTestRunner/TestInvocation.h
index b5fc041..e064a8f 100644
--- a/WebKitTools/WebKitTestRunner/TestInvocation.h
+++ b/WebKitTools/WebKitTestRunner/TestInvocation.h
@@ -37,7 +37,7 @@ public:
~TestInvocation();
void invoke();
- void didRecieveMessageFromInjectedBundle(WKStringRef message);
+ void didReceiveMessageFromInjectedBundle(WKStringRef message);
private:
void dump(const char*);
diff --git a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
index 232c396..987481a 100644
--- a/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
+++ b/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp
@@ -41,7 +41,7 @@ void TestController::initializeInjectedBundlePath()
{
CFStringRef exeContainerPath = CFURLCopyFileSystemPath(CFURLCreateCopyDeletingLastPathComponent(0, CFBundleCopyExecutableURL(CFBundleGetMainBundle())), kCFURLWindowsPathStyle);
CFMutableStringRef bundlePath = CFStringCreateMutableCopy(0, 0, exeContainerPath);
-#ifndef NDEBUG
+#ifdef DEBUG_ALL
CFStringAppendCString(bundlePath, "\\InjectedBundle_debug.dll", kCFStringEncodingWindowsLatin1);
#else
CFStringAppendCString(bundlePath, "\\InjectedBundle.dll", kCFStringEncodingWindowsLatin1);